IORING_OP_EPOLL_CTL does not set .needs_file in io_issue_defs[] and resolves both epfd and fd directly from the process file descriptor table via CLASS(fd, ...) in io_epoll_ctl(). Unlike the other .needs_file = 0 operations (such as openat, statx, xattr, and fs helpers), io_epoll_ctl_prep() does not reject REQ_F_FIXED_FILE. On a ring configured with IORING_REGISTER_RESTRICTIONS requiring IOSQE_FIXED_FILE, submitting IORING_OP_EPOLL_CTL with IOSQE_FIXED_FILE set passes io_check_restriction() while operating on unregistered regular file descriptors. Reject REQ_F_FIXED_FILE with -EBADF in io_epoll_ctl_prep(). This issue was discovered with an AI-assisted code review tool (ARTIST) and reproduced in QEMU/KVM on an unmodified v7.4-rc3 kernel without kernel modifications or error injection; a standalone reproducer is available upon maintainers' request. The fix was compile-tested with -Werror and checked with checkpatch.pl --strict; an equivalent fix was verified against the reproducer in QEMU/KVM. Fixes: 3e4827b05d2a ("io_uring: add support for epoll_ctl(2)") Cc: stable@vger.kernel.org Signed-off-by: Dominik Maier --- io_uring/epoll.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io_uring/epoll.c b/io_uring/epoll.c index b9db8bd..7de4a9d 100644 --- a/io_uring/epoll.c +++ b/io_uring/epoll.c @@ -32,6 +32,8 @@ 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; + if (unlikely(req->flags & REQ_F_FIXED_FILE)) + return -EBADF; epoll->epfd = READ_ONCE(sqe->fd); epoll->op = READ_ONCE(sqe->len); -- 2.56.1.750.gf70dc682cf-goog