]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
epoll: be better about file lifetimes
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 3 May 2024 20:36:09 +0000 (13:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 5 May 2024 21:00:48 +0000 (14:00 -0700)
commit4efaa5acf0a1d2b5947f98abb3acf8bfd966422b
tree0a7f074026609c4fed7d2c4add29c12e5c051ce0
parentf462ae0edd3703edd6f22fe41d336369c38b884b
epoll: be better about file lifetimes

epoll can call out to vfs_poll() with a file pointer that may race with
the last 'fput()'. That would make f_count go down to zero, and while
the ep->mtx locking means that the resulting file pointer tear-down will
be blocked until the poll returns, it means that f_count is already
dead, and any use of it won't actually get a reference to the file any
more: it's dead regardless.

Make sure we have a valid ref on the file pointer before we call down to
vfs_poll() from the epoll routines.

Link: https://lore.kernel.org/lkml/0000000000002d631f0615918f1e@google.com/
Reported-by: syzbot+045b454ab35fd82a35fb@syzkaller.appspotmail.com
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/eventpoll.c