Skip to content

Commit

Permalink
tracing: Prevent bad count for tracing_cpumask_write
Browse files Browse the repository at this point in the history
commit 98feccb upstream.

If a large count is provided, it will trigger a warning in bitmap_parse_user.
Also check zero for it.

Cc: [email protected]
Fixes: 9e01c1b ("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]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Lizhi Xu authored and gregkh committed Jan 2, 2025
1 parent a744146 commit 1cca920
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -5111,6 +5111,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;

Expand Down

0 comments on commit 1cca920

Please sign in to comment.