Patch "samples/landlock: Fix possible NULL dereference in parse_path()" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    samples/landlock: Fix possible NULL dereference in parse_path()

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     samples-landlock-fix-possible-null-dereference-in-pa.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3eb1afce345c1aeeb475551a135951b2e9061729
Author: Zichen Xie <zichenxie0106@xxxxxxxxx>
Date:   Wed Nov 27 21:29:56 2024 -0600

    samples/landlock: Fix possible NULL dereference in parse_path()
    
    [ Upstream commit 078bf9438a31567e2c0587159ccefde835fb1ced ]
    
    malloc() may return NULL, leading to NULL dereference.  Add a NULL
    check.
    
    Fixes: ba84b0bf5a16 ("samples/landlock: Add a sandbox manager example")
    Signed-off-by: Zichen Xie <zichenxie0106@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20241128032955.11711-1-zichenxie0106@xxxxxxxxx
    [mic: Simplify fix]
    Signed-off-by: Mickaël Salaün <mic@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c
index 57565dfd74a26..07fab2ef534e8 100644
--- a/samples/landlock/sandboxer.c
+++ b/samples/landlock/sandboxer.c
@@ -91,6 +91,9 @@ static int parse_path(char *env_path, const char ***const path_list)
 		}
 	}
 	*path_list = malloc(num_paths * sizeof(**path_list));
+	if (!*path_list)
+		return -1;
+
 	for (i = 0; i < num_paths; i++)
 		(*path_list)[i] = strsep(&env_path, ENV_DELIMITER);
 
@@ -127,6 +130,10 @@ static int populate_ruleset_fs(const char *const env_var, const int ruleset_fd,
 	env_path_name = strdup(env_path_name);
 	unsetenv(env_var);
 	num_paths = parse_path(env_path_name, &path_list);
+	if (num_paths < 0) {
+		fprintf(stderr, "Failed to allocate memory\n");
+		goto out_free_name;
+	}
 	if (num_paths == 1 && path_list[0][0] == '\0') {
 		/*
 		 * Allows to not use all possible restrictions (e.g. use




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux