All of lore.kernel.org
 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
Subject: [PATCH v2] io_uring/epoll: support fixed files for IORING_OP_EPOLL_CTL
Date: Tue, 24 Nov 2026 18:06:10 +0000	[thread overview]
Message-ID: <20261124180610.75208-1-dmnk@google.com> (raw)

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 <axboe@kernel.dk>
Signed-off-by: Dominik Maier <dmnk@google.com>
---
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


                 reply	other threads:[~2026-11-24 18:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261124180610.75208-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.