IORING_OP_EPOLL_CTL already goes through do_epoll_ctl_file(), and IORING_OP_EPOLL_WAIT already resolves the epoll instance via .needs_file and req->file. Mark IORING_OP_EPOLL_CTL as .needs_file = 1 and pass req->file directly to do_epoll_ctl_file() so registered epoll instances work with IOSQE_FIXED_FILE instead of ignoring the flag and looking up sqe->fd in the normal descriptor table. Suggested-by: Jens Axboe Signed-off-by: Dominik Maier --- v2: - Wire up .needs_file = 1 and use req->file so IOSQE_FIXED_FILE works for registered epoll fds instead of rejecting REQ_F_FIXED_FILE (Jens). - v1: https://lore.kernel.org/io-uring/20261119192223.2659961-1-dmnk@google.com/ io_uring/epoll.c | 8 +------- io_uring/opdef.c | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/io_uring/epoll.c b/io_uring/epoll.c index 4fb04d4b9136..349bebdb0298 100644 --- a/io_uring/epoll.c +++ b/io_uring/epoll.c @@ -14,7 +14,6 @@ struct io_epoll { struct file *file; - int epfd; int op; int fd; struct epoll_event event; @@ -33,7 +32,6 @@ int io_epoll_ctl_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) if (sqe->buf_index || sqe->splice_fd_in) return -EINVAL; - epoll->epfd = READ_ONCE(sqe->fd); epoll->op = READ_ONCE(sqe->len); epoll->fd = READ_ONCE(sqe->off); @@ -55,17 +53,13 @@ int io_epoll_ctl(struct io_kiocb *req, unsigned int issue_flags) struct epoll_key key; int ret; - CLASS(fd, f)(ie->epfd); - if (fd_empty(f)) - return -EBADF; - CLASS(fd, tf)(ie->fd); if (fd_empty(tf)) return -EBADF; key.file = fd_file(tf); key.fd = ie->fd; - ret = do_epoll_ctl_file(fd_file(f), ie->op, &key, &ie->event, force_nonblock); + ret = do_epoll_ctl_file(req->file, ie->op, &key, &ie->event, force_nonblock); if (force_nonblock && ret == -EAGAIN) return -EAGAIN; diff --git a/io_uring/opdef.c b/io_uring/opdef.c index cf3aa2242cd7..f23f11ff356e 100644 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -313,6 +313,7 @@ const struct io_issue_def io_issue_defs[] = { .filter_populate = io_openat_bpf_populate, }, [IORING_OP_EPOLL_CTL] = { + .needs_file = 1, .unbound_nonreg_file = 1, .audit_skip = 1, #if defined(CONFIG_EPOLL) -- 2.56.1.831.g720f3f5937-goog