Linux io-uring development
 help / color / mirror / Atom feed
* [PATCH] io_uring/epoll: reject IOSQE_FIXED_FILE in io_epoll_ctl_prep()
@ 2026-11-19 19:22 Dominik Maier
  2026-11-19 23:22 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Maier @ 2026-11-19 19:22 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, dmnk+artist, Dominik Maier

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 <dmnk@google.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-19 23:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:22 [PATCH] io_uring/epoll: reject IOSQE_FIXED_FILE in io_epoll_ctl_prep() Dominik Maier
2026-11-19 23:22 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox