Merge tag 'for-7.2/io_uring-epoll-20260616' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux

Pull io_uring epoll update from Jens Axboe:
 "As discussed a few months ago, this pull request gets rid of allowing
  nested epoll notification contexts via io_uring.

  Nested contexts have been a source of issues on the epoll side, and
  there should not be a need to support them from io_uring. The epoll
  io_uring side exists mainly to facilitate a gradual migration from a
  notification based epoll setup to an io_uring ditto"

* tag 'for-7.2/io_uring-epoll-20260616' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux:
  io_uring/epoll: disallow adding an epoll file to an epoll context
  io_uring/epoll: switch to using do_epoll_ctl_file() interface
This commit is contained in:
Linus Torvalds
2026-06-18 08:09:57 -07:00

View File

@@ -51,10 +51,24 @@ int io_epoll_ctl_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
int io_epoll_ctl(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_epoll *ie = io_kiocb_to_cmd(req, struct io_epoll);
int ret;
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
struct epoll_key key;
int ret;
ret = do_epoll_ctl(ie->epfd, ie->op, ie->fd, &ie->event, force_nonblock);
CLASS(fd, f)(ie->epfd);
if (fd_empty(f))
return -EBADF;
CLASS(fd, tf)(ie->fd);
if (fd_empty(tf))
return -EBADF;
/* disallow adding an epoll context to another epoll context */
if (ie->op == EPOLL_CTL_ADD && is_file_epoll(fd_file(tf)))
return -EINVAL;
key.file = fd_file(tf);
key.fd = ie->fd;
ret = do_epoll_ctl_file(fd_file(f), ie->op, &key, &ie->event, force_nonblock);
if (force_nonblock && ret == -EAGAIN)
return -EAGAIN;