From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "Sechang Lim" <rhkrqnwk98@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Juntong Deng" <juntong.deng@outlook.com>, <bpf@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf v3] bpf: fix NULL pointer dereference in bpf_task_from_vpid()
Date: Sun, 07 Jun 2026 13:06:34 +0200 [thread overview]
Message-ID: <DJ2ROT6HWPCR.3EJLG83YWTZN6@gmail.com> (raw)
In-Reply-To: <64l5t5yu77d5xg4jqjjwyqr2k75f2pi2vl7yus4oczgosjrpyx@2ink2pha4wt5>
On Sun Jun 7, 2026 at 12:05 PM CEST, Sechang Lim wrote:
> On Sun, Jun 07, 2026 at 10:44:41AM +0200, Kumar Kartikeya Dwivedi wrote:
>>> kernel/bpf/helpers.c | 7 +++++++
>>> 1 file changed, 7 insertions(+)
>>>
>>> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
>>> index b5314c9fed3c..226c31ccb5d6 100644
>>> --- a/kernel/bpf/helpers.c
>>> +++ b/kernel/bpf/helpers.c
>>> @@ -2912,7 +2912,14 @@ __bpf_kfunc struct task_struct *bpf_task_from_vpid(s32 vpid)
>>> {
>>> struct task_struct *p;
>>>
>>> + if (in_interrupt())
>>> + return NULL;
>>> +
>>
>>This seems too broad, I would just drop this hunk. It seems unrelated to the fix.
>>IIUC we only need the bit below to prevent the original NULL deref.
>>
>>pw-bot: cr
>>
>>> rcu_read_lock();
>>> + if (!task_active_pid_ns(current)) {
>>> + rcu_read_unlock();
>>> + return NULL;
>>> + }
>>> p = find_task_by_vpid(vpid);
>>> if (p)
>>> p = bpf_task_acquire(p);
>>
>
> Right, the NULL check alone fixes the crash. The async-context guard was
> added on Yonghong's v1 request: in softirq current is unrelated to the
> packet, so the looked-up task is meaning less even without the crash.
>
> Drop it entirely, or keep that intent with a narrower predicate?
> in_interrupt() is also true under spin_lock_bh(), so !in_task() would be
> more precise.
Drop it. I think there are contexts where tracing programs use it, may run with
interrupts disabled, but current still remains meaningful.
prev parent reply other threads:[~2026-06-07 11:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 9:19 [PATCH bpf v3] bpf: fix NULL pointer dereference in bpf_task_from_vpid() Sechang Lim
2026-06-06 9:31 ` sashiko-bot
2026-06-06 9:58 ` bot+bpf-ci
2026-06-06 12:57 ` Leon Hwang
2026-06-07 8:44 ` Kumar Kartikeya Dwivedi
2026-06-07 10:05 ` Sechang Lim
2026-06-07 11:06 ` Kumar Kartikeya Dwivedi [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=DJ2ROT6HWPCR.3EJLG83YWTZN6@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=jolsa@kernel.org \
--cc=juntong.deng@outlook.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=rhkrqnwk98@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.