From: sashiko-bot@kernel.org
To: "Justin Suess" <utilityemal77@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v1 2/4] selftests/bpf: Test MEM_RCU carry-over for trusted fields
Date: Wed, 14 Oct 2026 17:43:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-171590@kernel.org> (raw)
In-Reply-To: <20261014173039.3666415-3-utilityemal77@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] bpf: unhandled NULL deref of f_inode due to SLAB_TYPESAFE_BY_RCU
--
commit 3b6fbe50569bfdf0fb6b88ab1c38f2e6056c0f68
Author: Justin Suess <utilityemal77@gmail.com>
selftests/bpf: Test MEM_RCU carry-over for trusted fields
This commit adds selftests to verify the behavior of the BPF verifier when
accessing fields from RCU-protected pointers. It includes an accept test
for dereferencing an inode within an RCU critical section, and a reject test
for using it after the critical section ends.
> diff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
> index 55398c04290a8..f519ba5f4ea20 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
[ ... ]
> +SEC("lsm.s/bprm_committed_creds")
> +__success
> +int BPF_PROG(trusted_field_used_in_rcu_cs, struct linux_binprm *bprm)
> +{
> + struct mm_struct *mm = bprm->mm;
> + struct inode *inode;
> + struct file *file;
> + ino_t ino = 0;
> +
> + if (!mm)
> + return 0;
> +
> + bpf_rcu_read_lock();
> + file = mm->exe_file;
> + if (file) {
> + inode = file->f_inode;
> + ino = inode->i_ino;
[Severity: High]
Can this result in an unhandled NULL pointer dereference leading to a
kernel Oops?
Because struct file is allocated with SLAB_TYPESAFE_BY_RCU in files_init()
in fs/file_table.c, the file object can be concurrently freed and reallocated
while an RCU reader holds a pointer to it. During this reallocation process,
alloc_empty_file() calls init_file(), which zeroes out f_inode.
In check_ptr_to_btf_access() in the verifier, the PTR_MAYBE_NULL flag is omitted
for trusted fields read from MEM_RCU pointers. This prevents the verifier from
enforcing a NULL check on the resulting inode pointer. Additionally, the
dereference bypasses the exception table rewrite that would normally handle
memory faults for untrusted pointers.
If a file is closed and reallocated concurrently while the BPF program runs,
could inode be NULL when inode->i_ino is accessed? Is it safe to codify this
pattern as an accept test without requiring a NULL check for f_inode?
> + }
> + bpf_rcu_read_unlock();
> + __sink(ino);
> + return 0;
> +}
> +
> char _license[] SEC("license") = "GPL";
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014173039.3666415-1-utilityemal77@gmail.com?part=2
next prev parent reply other threads:[~2026-10-14 17:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 17:30 [PATCH bpf-next v1 0/4] bpf: bound trusted fields to their parent's lifetime Justin Suess
2026-10-14 17:30 ` [PATCH bpf-next v1 1/4] bpf: Carry MEM_RCU for trusted fields with MEM_RCU parents Justin Suess
2026-10-14 17:30 ` [PATCH bpf-next v1 2/4] selftests/bpf: Test MEM_RCU carry-over for trusted fields Justin Suess
2026-10-14 17:43 ` sashiko-bot [this message]
2026-10-14 18:05 ` Justin Suess
2026-10-14 17:30 ` [PATCH bpf-next v1 3/4] bpf: Bind trusted fields to their parent's reference Justin Suess
2026-10-14 17:30 ` [PATCH bpf-next v1 4/4] selftests/bpf: Test trusted-field invalidation on parent release Justin Suess
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=sashiko-outbox-171590@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=utilityemal77@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 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.