BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ziyang Men" <ziyang.meme@gmail.com>
Cc: hannes@cmpxchg.org, mkoutny@suse.com, tj@kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v3 3/4] block: add BPF kfuncs to read blkcg io.stat
Date: Thu, 20 Aug 2026 21:40:41 +0000	[thread overview]
Message-ID: <20260820214041.C19601F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260820211758.3393984-4-ziyang.meme@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling bpf_css_release() from NMI context can trigger a deadlock.
--

--- Patch [3]: [PATCH v3 3/4] block: add BPF kfuncs to read blkcg io.stat ---
commit d71e52907eeb75ca126ab0da4391bc18134b90e2
Author: Ziyang Men <ziyang.meme@gmail.com>

block: add BPF kfuncs to read blkcg io.stat

This commit adds BPF kfuncs to acquire and release a controller's css from a
cgroup. It also adds a kfunc to cast an io controller css to its block
cgroup, along with an open-coded iterator for the per-device blkgs.

> diff --git a/kernel/cgroup/bpf_cgroup.c b/kernel/cgroup/bpf_cgroup.c
> index cd28c838dc7b6..e253633e82782 100644
> --- a/kernel/cgroup/bpf_cgroup.c
> +++ b/kernel/cgroup/bpf_cgroup.c
[ ... ]
> +/**
> + * bpf_css_release - Release a css reference
> + * @css: css to release
> + */
> +__bpf_kfunc void bpf_css_release(struct cgroup_subsys_state *css)
> +{
> +	css_put(css);
> +}

[Severity: High]
Can this trigger a deadlock if called from NMI context?

Since these kfuncs are registered under BPF_PROG_TYPE_UNSPEC, they can be
called by NMI-context BPF programs such as perf events. 

If a BPF program drops the last reference to the css here, css_put() will
invoke the percpu_ref release callback, css_release(), directly in the NMI
context. 

css_release() unconditionally calls queue_work(), which internally acquires
the workqueue pool's raw spinlock. If the NMI interrupted a context that
already held this lock, would this instantly deadlock the system?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260820211758.3393984-1-ziyang.meme@gmail.com?part=3

  reply	other threads:[~2026-08-20 21:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 21:17 [PATCH v3 0/4] cgroup: expose cpu.stat and io.stat to BPF Ziyang Men
2026-08-20 21:17 ` [PATCH v3 1/4] cgroup: add BPF kfuncs to read a cpu cgroup's stats Ziyang Men
2026-08-20 21:28   ` sashiko-bot
2026-08-20 21:17 ` [PATCH v3 2/4] selftests/bpf: add cgroup_iter_cpu test for cpu cgroup kfuncs Ziyang Men
2026-08-20 22:19   ` bot+bpf-ci
2026-08-20 21:17 ` [PATCH v3 3/4] block: add BPF kfuncs to read blkcg io.stat Ziyang Men
2026-08-20 21:40   ` sashiko-bot [this message]
2026-08-20 22:19   ` bot+bpf-ci
2026-08-20 21:17 ` [PATCH v3 4/4] selftests/bpf: add test for blkcg io.stat BPF kfuncs Ziyang Men
2026-08-31 22:16 ` [PATCH v3 0/4] cgroup: expose cpu.stat and io.stat to BPF Ziyang Men
2026-09-02 23:10   ` Shakeel Butt

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=20260820214041.C19601F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=mkoutny@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=ziyang.meme@gmail.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