]> Git Repo - J-linux.git/commitdiff
tracing: Prevent bad count for tracing_cpumask_write
authorLizhi Xu <[email protected]>
Mon, 16 Dec 2024 07:32:38 +0000 (15:32 +0800)
committerSteven Rostedt (Google) <[email protected]>
Tue, 24 Dec 2024 02:59:15 +0000 (21:59 -0500)
If a large count is provided, it will trigger a warning in bitmap_parse_user.
Also check zero for it.

Cc: [email protected]
Fixes: 9e01c1b74c953 ("cpumask: convert kernel trace functions")
Link: https://lore.kernel.org/[email protected]
Reported-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
Tested-by: [email protected]
Signed-off-by: Lizhi Xu <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
kernel/trace/trace.c

index 957f941a08e743cc3bb8bc89597b950a6308b42e..f8aebcb01e62cf5e97f98fbeddd862bcf2d9cb9b 100644 (file)
@@ -5087,6 +5087,9 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
        cpumask_var_t tracing_cpumask_new;
        int err;
 
+       if (count == 0 || count > KMALLOC_MAX_SIZE)
+               return -EINVAL;
+
        if (!zalloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
                return -ENOMEM;
 
This page took 0.064217 seconds and 4 git commands to generate.