From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+69a3d7738ad3aa175caf@syzkaller.appspotmail.com
Cc: brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
viro@zeniv.linux.org.uk
Subject: [PATCH next] eventpoll: delay file list memory deallocation until unlisting
Date: Sun, 24 May 2026 18:27:59 +0800 [thread overview]
Message-ID: <tencent_C65896BCE9C2EEE2CCF078666E102DC56D0A@qq.com> (raw)
In-Reply-To: <6a10a5e1.050a0220.66ea1.0008.GAE@google.com>
Commit e09c77d94003 implicitly sets the head->next value within list_file()
to NULL; this occurs because ctx->tfile_check_list which resides on the stack
is initialized to NULL. This introduces a potential risk to ep_remove_file(),
as the decision to reclaim epitems_head depends solely on whether the next
pointer is NULL. Prior to the introduction of e09c77d94003, the presence of
the sentinel value EP_UNACTIVE_PTR prevented the next pointer from becoming
NULL prematurely; the next value would only be updated to NULL during the
execution of unlist_file().
However, following the introduction of e09c77d94003, list_file() also updates
the next value to NULL, which ultimately led to the uaf reported in [1].
To mitigate the risk posed by the potentially NULL next pointer, the memory
reclamation for the file list originally performed within ep_remove_file()
has been deferred to unlist_file().
[1]
BUG: KASAN: slab-use-after-free in clear_tfile_check_list+0x114/0x380 fs/eventpoll.c:2443
Read of size 8 at addr ffff88803f021568 by task syz.0.74/5985
Call Trace:
clear_tfile_check_list+0x114/0x380 fs/eventpoll.c:2443
do_epoll_ctl_file+0x8fd/0xed0 fs/eventpoll.c:-1
Allocated by task 5985:
ep_attach_file fs/eventpoll.c:1751 [inline]
ep_register_epitem fs/eventpoll.c:1833 [inline]
ep_insert+0x512/0x1820 fs/eventpoll.c:1876
do_epoll_ctl_file+0x8bb/0xed0 fs/eventpoll.c:2651
Freed by task 5985:
kmem_cache_free+0x187/0x6c0 mm/slub.c:6411
ep_remove+0x155/0x2a0 fs/eventpoll.c:1135
ep_insert+0x1372/0x1820 fs/eventpoll.c:-1
do_epoll_ctl_file+0x8bb/0xed0 fs/eventpoll.c:2651
Fixes: e09c77d94003 ("eventpoll: hoist CTL_ADD scratch state into struct ep_ctl_ctx")
Reported-by: syzbot+69a3d7738ad3aa175caf@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=69a3d7738ad3aa175caf
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
fs/eventpoll.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index a569e98d4a99..66aa4f200909 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1080,6 +1080,8 @@ static void ep_remove_file(struct eventpoll *ep, struct epitem *epi,
v = container_of(head, struct epitems_head, epitems);
if (!smp_load_acquire(&v->next))
to_free = v;
+ if (!hlist_empty(&v->epitems))
+ to_free = NULL;
}
}
hlist_del_rcu(&epi->fllink);
--
2.43.0
next prev parent reply other threads:[~2026-05-24 10:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 18:52 [syzbot] [fs?] KASAN: slab-use-after-free Read in clear_tfile_check_list syzbot
2026-05-23 3:22 ` Edward Adam Davis
2026-05-23 3:50 ` syzbot
2026-05-24 10:27 ` Edward Adam Davis [this message]
2026-05-28 12:37 ` [PATCH next] eventpoll: delay file list memory deallocation until unlisting Christian Brauner
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=tencent_C65896BCE9C2EEE2CCF078666E102DC56D0A@qq.com \
--to=eadavis@qq.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+69a3d7738ad3aa175caf@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®