]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tracing: Prevent bad count for tracing_cpumask_write
authorLizhi Xu <lizhi.xu@windriver.com>
Mon, 16 Dec 2024 07:32:38 +0000 (15:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2025 12:25:04 +0000 (13:25 +0100)
[ Upstream commit 98feccbf32cfdde8c722bc4587aaa60ee5ac33f0 ]

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: 9e01c1b74c953 ("cpumask: convert kernel trace functions")
Link: https://lore.kernel.org/20241216073238.2573704-1-lizhi.xu@windriver.com
Reported-by: syzbot+0aecfd34fb878546f3fd@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0aecfd34fb878546f3fd
Tested-by: syzbot+0aecfd34fb878546f3fd@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/trace.c

index 3ecd7c700579c803c95c93350dcbadd56792a6dc..ca39a647f2ef075248a24c93c889755ce46ad319 100644 (file)
@@ -4910,6 +4910,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;