BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: quanyeyang <quanyemostima@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH] bpf: disable lockdep while running BPF on lock_release
Date: Mon, 03 Aug 2026 10:50:51 +0000	[thread overview]
Message-ID: <20260803105051.92C7B1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260803-fix-lock-tracepoint-bpf-lockdep-v1-1-91fb7afb526a@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] Disabling lockdep during `trace_call_bpf` for `lock_release` hides valid lock inversions and allows silent physical deadlocks.
- [High] Temporarily disabling lockdep globally via `lockdep_off()` in `trace_call_bpf()` unintentionally blinds lockdep to any hardware interrupts and softirqs that preempt the BPF program.

Pre-existing issues:
- [High] The patch fails to disable lockdep for BPF programs attached to `lock_release` via raw tracepoints.
--

--- Patch [1]: [PATCH] bpf: disable lockdep while running BPF on lock_release ---
commit 4871557897dd6c7f2fd05dc2170475d6e2824a6e
Author: quanyeyang <quanyemostima@gmail.com>

bpf: disable lockdep while running BPF on lock_release

trace_lock_release() runs before __lock_release(), so the lock is
still on the held stack when attached BPF programs execute. This patch marks
lock_release with TRACE_EVENT_FL_BPF_NO_LOCKDEP and temporarily disables
lockdep around bpf_prog_run_array() for that event to avoid false recursive
locking warnings.

Closes: https://syzkaller.appspot.com/bug?extid=ef8d17bae14efb960935

> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 75495a5c35079..f2460f3c860e0 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c

[ ... ]

> @@ -144,8 +146,12 @@ unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx)
>  	 * rcu_dereference() which is accepted risk.
>  	 */
>  	rcu_read_lock();
> +	if (no_lockdep)
> +		lockdep_off();

[Severity: High]
Could this introduce a regression by suppressing valid warnings about real
physical lock deadlocks caused by BPF programs?

If a BPF program attached to lock_release acquires a kernel lock, the CPU
physically holds the original lock while executing the BPF program. If the
BPF lock ordering violates the kernel's lock graph, wouldn't this cause a
silent deadlock without any lockdep warning?

[Severity: High]
Could this also introduce a regression by unintentionally blinding lockdep to
hardware interrupts and softirqs?

trace_call_bpf() for lock_release can execute with hardware interrupts
enabled. The lockdep_off() macro increments current->lockdep_recursion.
If a hardware interrupt fires while the BPF program is executing, it runs
in a context where current->lockdep_recursion > 0.

Does this mean all lock acquisitions in the interrupt handler and
subsequent softirqs will completely bypass lockdep tracking?

[Severity: High]
This is a pre-existing issue, but does this approach fail to disable lockdep
for BPF programs attached to lock_release via raw tracepoints?

If a user attaches a BPF program using the raw tracepoint interface
(raw_tracepoint/lock_release), the kernel dispatches this through
__bpf_trace_run() which bypasses trace_call_bpf() completely.

Will the false positive lockdep warning still trigger for raw tracepoints
since they lack this lockdep suppression logic?

>  	ret = bpf_prog_run_array(rcu_dereference(call->prog_array),
>  				 ctx, bpf_prog_run);
> +	if (no_lockdep)
> +		lockdep_on();
>  	rcu_read_unlock();

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260803-fix-lock-tracepoint-bpf-lockdep-v1-1-91fb7afb526a@gmail.com?part=1

  reply	other threads:[~2026-08-03 10:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 10:37 [PATCH] bpf: disable lockdep while running BPF on lock_release quanyeyang via B4 Relay
2026-08-03 10:50 ` sashiko-bot [this message]
2026-08-04  0:46 ` Justin Suess
2026-08-04  8:34   ` NeilBrown
2026-08-04 14:45     ` Quanye Yang
2026-08-04 22:48       ` NeilBrown
2026-08-05  7:07         ` 回复: " quanyeyang
2026-08-05  9:03           ` NeilBrown
2026-08-05 22:43             ` NeilBrown
2026-08-06  4:26               ` quanyeyang

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=20260803105051.92C7B1F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=quanyemostima@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox