Linux io-uring development
 help / color / mirror / Atom feed
From: Dominik Maier <dmnk@google.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, dmnk+artist@google.com,
	 Dominik Maier <dmnk@google.com>
Subject: [PATCH] io_uring/epoll: reject IOSQE_FIXED_FILE in io_epoll_ctl_prep()
Date: Thu, 19 Nov 2026 20:22:23 +0100	[thread overview]
Message-ID: <20261119192223.2659961-1-dmnk@google.com> (raw)

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


             reply	other threads:[~2026-11-19 19:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 19:22 Dominik Maier [this message]
2026-11-19 23:22 ` [PATCH] io_uring/epoll: reject IOSQE_FIXED_FILE in io_epoll_ctl_prep() Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119192223.2659961-1-dmnk@google.com \
    --to=dmnk@google.com \
    --cc=axboe@kernel.dk \
    --cc=dmnk+artist@google.com \
    --cc=io-uring@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox