From: Justin Suess <utilityemal77@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org, linux-security-module@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 05/11] bpf: add a path ancestor iterator
Date: Tue, 13 Oct 2026 14:00:07 -0400 [thread overview]
Message-ID: <as5w8lY-3Z6sVlxe@zenbox> (raw)
In-Reply-To: <sashiko-outbox-170194@kernel.org>
On Tue, Oct 13, 2026 at 05:11:54PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] bpf: deadlock in bpf_iter_path_ancestors_next due to GFP_KERNEL under VFS locks
> --
>
> commit 0d24b2f0561971ff2a9d89456692d9ec1ea13279
> Author: Justin Suess <utilityemal77@gmail.com>
>
> bpf: add a path ancestor iterator
>
> This commit introduces a sleepable BPF iterator for evaluating a path's
> ancestry using the stepwise vfs_walk_ancestors() engine. It adds kfuncs
> to manage the iterator and hands each position to the program as an
> acquired reference by allocating a copy of the path structure.
>
> > diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
> > index 08f0847c49708..02398f5a46d5a 100644
> > --- a/fs/bpf_fs_kfuncs.c
> > +++ b/fs/bpf_fs_kfuncs.c
> [ ... ]
> > +__bpf_kfunc struct path *
> > +bpf_iter_path_ancestors_next(struct bpf_iter_path_ancestors *it)
> > +{
> > + struct bpf_path_ancestors_kern *kit = (void *)it;
> > + struct path *pos = bpf_path_ancestors_step(kit);
> > + struct path *held;
> > +
> > + if (!pos)
> > + return NULL;
> > + /*
> > + * The position must outlive the walk's own view of it, so it gets a
> > + * reference and a struct path of its own to live in: struct path is
> > + * a value type, with nothing a BPF reference could be taken on
> > + * otherwise. Sleepable, so no atomic allocation.
> > + */
> > + held = kmalloc_obj(*held);
>
> [Severity: High]
> Can this allocation cause a deadlock if the iterator is used from a sleepable
> LSM hook?
>
> If a sleepable BPF LSM program is attached to a hook like
> security_inode_setattr or security_inode_unlink, it is called by the VFS
> with the inode's i_rwsem held.
>
> The kmalloc_obj() macro appears to default to GFP_KERNEL allocations, which
> includes the __GFP_FS flag. Under memory pressure, this could trigger direct
> memory reclaim.
>
> If reclaim attempts to write back dirty pages or shrink the dcache/icache,
> it might try to acquire the same i_rwsem, resulting in a deadlock.
>
Direct reclaim never takes i_rwsem. So this is incorrect.
(Also if that were the case, the mkdir selftest would splat with lockdep)
Justin
> > + if (!held) {
> > + kit->step = -ENOMEM;
> > + return NULL;
> > + }
> > + *held = *pos;
> > + path_get(held);
> > + return held;
> > +}
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261013164800.2906577-1-utilityemal77@gmail.com?part=5
next prev parent reply other threads:[~2026-10-13 18:00 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 16:47 [PATCH bpf-next v1 00/11] fs: unified VFS ancestor walk for Landlock and BPF Justin Suess
2026-10-13 16:47 ` [PATCH bpf-next v1 01/11] namei: introduce __path_walk_parent() Justin Suess
2026-10-13 16:54 ` sashiko-bot
2026-10-13 16:47 ` [PATCH bpf-next v1 02/11] namei: add vfs_walk_ancestors() Justin Suess
2026-10-13 17:00 ` sashiko-bot
2026-10-13 16:47 ` [PATCH bpf-next v1 03/11] landlock: convert ancestor walk to vfs_walk_ancestors() Justin Suess
2026-10-13 16:55 ` sashiko-bot
2026-10-13 16:47 ` [PATCH bpf-next v1 04/11] namei: expose the stepwise ancestor walk to fs/ Justin Suess
2026-10-13 16:54 ` sashiko-bot
2026-10-13 16:47 ` [PATCH bpf-next v1 05/11] bpf: add a path ancestor iterator Justin Suess
2026-10-13 17:11 ` sashiko-bot
2026-10-13 18:00 ` Justin Suess [this message]
2026-10-13 16:47 ` [PATCH bpf-next v1 06/11] selftests/bpf: exercise the " Justin Suess
2026-10-13 16:56 ` sashiko-bot
2026-10-13 19:50 ` Justin Suess
2026-10-13 16:47 ` [PATCH bpf-next v1 07/11] fs: add mnt_undo_legitimize() Justin Suess
2026-10-13 16:59 ` sashiko-bot
2026-10-13 16:47 ` [PATCH bpf-next v1 08/11] namei: add an rcu-walk mode to the ancestor walk Justin Suess
2026-10-13 17:01 ` sashiko-bot
2026-10-13 17:56 ` Justin Suess
2026-10-13 16:47 ` [PATCH bpf-next v1 09/11] bpf: support "__uninit" iterator arguments in generic kfuncs Justin Suess
2026-10-13 17:04 ` sashiko-bot
2026-10-13 16:47 ` [PATCH bpf-next v1 10/11] bpf: add a lockless path ancestor iterator Justin Suess
2026-10-13 17:03 ` sashiko-bot
2026-10-13 16:48 ` [PATCH bpf-next v1 11/11] selftests/bpf: exercise the " Justin Suess
2026-10-13 16:57 ` sashiko-bot
2026-10-13 17:50 ` bot+bpf-ci
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=as5w8lY-3Z6sVlxe@zenbox \
--to=utilityemal77@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--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