Commit 98feccbf authored by Lizhi Xu's avatar Lizhi Xu Committed by Steven Rostedt (Google)
Browse files

tracing: Prevent bad count for tracing_cpumask_write

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

Cc: stable@vger.kernel.org
Fixes: 9e01c1b7 ("cpumask: convert kernel trace functions")
Link: https://lore.kernel.org/20241216073238.2573704-1-lizhi.xu@windriver.com


Reported-by: default avatar <syzbot+0aecfd34fb878546f3fd@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd


Tested-by: default avatar <syzbot+0aecfd34fb878546f3fd@syzkaller.appspotmail.com>
Signed-off-by: default avatarLizhi Xu <lizhi.xu@windriver.com>
Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
parent 452f4b31
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;