All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sechang Lim" <rhkrqnwk98@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v3] bpf: fix NULL pointer dereference in bpf_task_from_vpid()
Date: Sat, 06 Jun 2026 09:31:00 +0000	[thread overview]
Message-ID: <20260606093100.B6CDF1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260606091941.1803115-1-rhkrqnwk98@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The use of the deprecated `in_interrupt()` macro causes `bpf_task_from_vpid()` to incorrectly fail and return `NULL` in valid task contexts when Bottom Halves (BH) are disabled.
--

commit 17040face7147d85a8cf3090be3539991c26df30
Author: Sechang Lim <rhkrqnwk98@gmail.com>

bpf: fix NULL pointer dereference in bpf_task_from_vpid()

This commit addresses a NULL pointer dereference in bpf_task_from_vpid()
by adding checks to return NULL when running in interrupt context or when
the current task has no active pid namespace.

> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index b5314c9fed3cf..226c31ccb5d61 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;

[Severity: Medium]
Does the use of in_interrupt() here incorrectly reject valid task contexts
where bottom halves (BH) are disabled?

Since in_interrupt() evaluates to irq_count(), it evaluates to true not only
in hardware and softirq contexts, but also in normal process contexts if
local_bh_disable() or spin_lock_bh() is active. This might cause valid BPF
programs running in BH-disabled task contexts to unexpectedly receive NULL
from bpf_task_from_vpid().

Would it be better to use !in_task() here to accurately filter out non-task
asynchronous contexts without penalizing BH-disabled task contexts?

> +
>  	rcu_read_lock();
> +	if (!task_active_pid_ns(current)) {
> +		rcu_read_unlock();
> +		return NULL;
> +	}
>  	p = find_task_by_vpid(vpid);

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260606091941.1803115-1-rhkrqnwk98@gmail.com?part=1

  reply	other threads:[~2026-06-06  9:31 UTC|newest]

Thread overview: 4+ 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 [this message]
2026-06-06  9:58 ` bot+bpf-ci
2026-06-06 12:57 ` Leon Hwang

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=20260606093100.B6CDF1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=rhkrqnwk98@gmail.com \
    --cc=sashiko-reviews@lists.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.