summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2026-04-23 05:10:45 -0600
committerJens Axboe <axboe@kernel.dk>2026-05-15 09:57:41 -0600
commitcfa1539b24aff18ecb71c6334e7270f810d145bb (patch)
tree923f9f2e844e1544e9ef2650403a367dcc976fbd
parent071858de47a29ae8b0bf2239a195df876806e28e (diff)
io_uring/epoll: disallow adding an epoll file to an epoll context
One of the nastier things about epoll is how it allows adding epoll files to epoll contexts. This leads to all sorts of loop detection code, and has been a source of issues in the past. Arguably adding IORING_EPOLL_CTL is a historical mistake on the io_uring side, but we're kind of stuck with it now as it does seem to be in use according to code searches. But we can at least minimize the damage a bit and just disallow this part of epoll, where nesting issues can arise. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/epoll.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/io_uring/epoll.c b/io_uring/epoll.c
index b9db8bde27ec..eecd748cad01 100644
--- a/io_uring/epoll.c
+++ b/io_uring/epoll.c
@@ -62,6 +62,9 @@ int io_epoll_ctl(struct io_kiocb *req, unsigned int issue_flags)
CLASS(fd, tf)(ie->fd);
if (fd_empty(tf))
return -EBADF;
+ /* disallow adding an epoll context to another epoll context */
+ if (ie->op == EPOLL_CTL_ADD && is_file_epoll(fd_file(tf)))
+ return -EINVAL;
key.file = fd_file(tf);
key.fd = ie->fd;