Re: [syzbot] [fs?] [io-uring?] general protection fault in __ep_remove

From: Hillf Danton
Date: Fri May 03 2024 - 23:24:20 EST


On Mon, 08 Apr 2024 01:26:16 -0700
> syzbot found the following issue on:
>
> HEAD commit: 480e035fc4c7 Merge tag 'drm-next-2024-03-13' of https://gi..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10801175180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 480e035fc4c7

--- x/fs/eventpoll.c
+++ y/fs/eventpoll.c
@@ -991,9 +991,13 @@ static __poll_t ep_item_poll(const struc
__poll_t res;

pt->_key = epi->event.events;
- if (!is_file_epoll(file))
- res = vfs_poll(file, pt);
- else
+ if (!is_file_epoll(file)) {
+ res = 0;
+ if (atomic_long_inc_not_zero(&file->f_count)) {
+ res = vfs_poll(file, pt);
+ fput(file);
+ }
+ } else
res = __ep_eventpoll_poll(file, pt, depth);
return res & epi->event.events;
}
--