From: syzbot <syzbot+36e50496c8ac4bcde3f9@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] bpf: fix UAF by restoring RCU-delayed inode freeing in bpffs
Date: Mon, 01 Jun 2026 18:39:56 -0700 [thread overview]
Message-ID: <6a1e346c.fbc46276.3c3783.0006.GAE@google.com> (raw)
In-Reply-To: <6a1dbc91.fbc46276.3c3783.0004.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] bpf: fix UAF by restoring RCU-delayed inode freeing in bpffs
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
commit 4f375ade6aa9 moved all inode cleanup from ->free_inode() into
->destroy_inode() to avoid a sleeping-in-RCU-context warning when
calling bpf_any_put(). However this removed the RCU delay on freeing
the inode itself and the cached symlink body (i_link), both of which
can be accessed by RCU pathwalk (pick_link, may_lookup etc.).
This causes a use-after-free when a concurrent unlinkat() drops the
last inode reference and destroy_inode() frees the inode immediately,
while another task is still walking the path in RCU mode and reads
inode->i_opflags (offset +2) inside current_time() -> is_mgtime().
KASAN reports:
BUG: KASAN: slab-use-after-free in is_mgtime include/linux/fs.h:2313
Read of size 2 at addr ffff8880407e4282 (offset +2 = i_opflags)
The rules (per Al Viro):
->destroy_inode() called immediately, can sleep, use for blocking
cleanup e.g. bpf_any_put()
->free_inode() called after RCU grace period, use for freeing
inode and anything RCU-accessible e.g. i_link
Fix: keep bpf_any_put() in destroy_inode() since it is blocking, but
move kfree(i_link) and free_inode_nonrcu() into a new bpf_free_inode()
so they happen after RCU delay, preventing the UAF.
Reported-by: syzbot+36e50496c8ac4bcde3f9@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=36e50496c8ac4bcde3f9
Link: https://lore.kernel.org/all/20260423043906.GN3518998@ZenIV/
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
kernel/bpf/inode.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 25c06a011825..188c774a469c 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -766,10 +766,18 @@ static void bpf_destroy_inode(struct inode *inode)
{
enum bpf_type type;
- if (S_ISLNK(inode->i_mode))
- kfree(inode->i_link);
if (!bpf_inode_type(inode, &type))
bpf_any_put(inode->i_private, type);
+}
+
+/*
+ * Called after RCU grace period - safe to free inode and anything
+ * that might be accessed by RCU pathwalk (inode fields, i_link).
+ */
+static void bpf_free_inode(struct inode *inode)
+{
+ if (S_ISLNK(inode->i_mode))
+ kfree(inode->i_link);
free_inode_nonrcu(inode);
}
@@ -778,6 +786,7 @@ const struct super_operations bpf_super_ops = {
.drop_inode = inode_just_drop,
.show_options = bpf_show_options,
.destroy_inode = bpf_destroy_inode,
+ .free_inode = bpf_free_inode,
};
enum {
--
2.43.0
prev parent reply other threads:[~2026-06-02 1:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 17:08 [syzbot] [fs?] KASAN: slab-use-after-free Read in current_time syzbot
2026-06-01 23:48 ` Forwarded: [PATCH] fs/namei: fix UAF in pick_link() by unlazying before atime check syzbot
2026-06-02 1:39 ` syzbot [this message]
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=6a1e346c.fbc46276.3c3783.0006.GAE@google.com \
--to=syzbot+36e50496c8ac4bcde3f9@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.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
Powered by JetHome