From: Steven Rostedt <rostedt@goodmis.org>
To: Wang Liang <wangliang74@huawei.com>
Cc: <mhiramat@kernel.org>, <mathieu.desnoyers@efficios.com>,
<tglozar@redhat.com>, <yuehaibing@huawei.com>,
<zhangchangzhong@huawei.com>,
<linux-trace-kernel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] tracing/osnoise: Fix null-ptr-deref in bitmap_parselist()
Date: Sat, 6 Sep 2025 12:10:07 -0400 [thread overview]
Message-ID: <20250906121007.5ceb3436@gandalf.local.home> (raw)
In-Reply-To: <20250906035610.3880282-1-wangliang74@huawei.com>
On Sat, 6 Sep 2025 11:56:10 +0800
Wang Liang <wangliang74@huawei.com> wrote:
> A crash was observed with the following output:
>
> BUG: kernel NULL pointer dereference, address: 0000000000000010
> Oops: Oops: 0000 [#1] SMP NOPTI
> CPU: 2 UID: 0 PID: 92 Comm: osnoise_cpus Not tainted 6.17.0-rc4-00201-gd69eb204c255 #138 PREEMPT(voluntary)
> RIP: 0010:bitmap_parselist+0x53/0x3e0
> Call Trace:
> <TASK>
> osnoise_cpus_write+0x7a/0x190
> vfs_write+0xf8/0x410
> ? do_sys_openat2+0x88/0xd0
> ksys_write+0x60/0xd0
> do_syscall_64+0xa4/0x260
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> </TASK>
>
> This issue can be reproduced by below code:
>
> fd=open("/sys/kernel/debug/tracing/osnoise/cpus", O_WRONLY);
> write(fd, "0-2", 0);
>
> When user pass 'count=0' to osnoise_cpus_write(), kmalloc() will return
> ZERO_SIZE_PTR (16) and cpulist_parse() treat it as a normal value, which
> trigger the null pointer dereference. Add check for the parameter 'count'.
>
> Link: https://lore.kernel.org/all/20250905032544.231962-1-wangliang74@huawei.com/
> Fixes: 17f89102fe23 ("tracing/osnoise: Allow arbitrarily long CPU string")
> Signed-off-by: Wang Liang <wangliang74@huawei.com>
> ---
> v2: return 0 when sending a count of 0.
FYI, I usually have this say:
Changes since v2: https://lore.kernel.org/all/20250905032544.231962-1-wangliang74@huawei.com/
and list the rest.
I know Linus doesn't like links to the patch, but I find them useful, and
even more useful when the patch has a link to previous versions. ;-)
I see that you did add it to the "link" above, which is probably fine too.
-- Steve
> ---
> kernel/trace/trace_osnoise.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/kernel/trace/trace_osnoise.c b/kernel/trace/trace_osnoise.c
> index fd259da0aa64..337bc0eb5d71 100644
> --- a/kernel/trace/trace_osnoise.c
> +++ b/kernel/trace/trace_osnoise.c
> @@ -2322,6 +2322,9 @@ osnoise_cpus_write(struct file *filp, const char
> __user *ubuf, size_t count, int running, err;
> char *buf __free(kfree) = NULL;
>
> + if (count < 1)
> + return 0;
> +
> buf = kmalloc(count, GFP_KERNEL);
> if (!buf)
> return -ENOMEM;
prev parent reply other threads:[~2025-09-06 16:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-06 3:56 Wang Liang
2025-09-06 16:10 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250906121007.5ceb3436@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=tglozar@redhat.com \
--cc=wangliang74@huawei.com \
--cc=yuehaibing@huawei.com \
--cc=zhangchangzhong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®