io_uring/epoll: reject IOSQE_FIXED_FILE in io_epoll_ctl_prep()
PATCH 1/1 io_uring/epoll: reject IOSQE_FIXED_FILE in io_epoll_ctl_prep()
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.
--- io_uring/epoll.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/epoll.c +2 -0
@@ -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);
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
Jens Axboe
maintainerQuoted 4 lines · Dominik Maier
IORING_OP_EPOLL_CTLdoes not set .needs_file in io_issue_defs[] and resolves both epfd and fd directly from the process file descriptor table viaCLASS(fd, ...)inio_epoll_ctl().
Quoted 8 lines
Unlike the other .needs_file = 0 operations (such as openat, statx, xattr, and fs helpers),
io_epoll_ctl_prep()does not rejectREQ_F_FIXED_FILE. On a ring configured withIORING_REGISTER_RESTRICTIONSrequiringIOSQE_FIXED_FILE, submittingIORING_OP_EPOLL_CTLwithIOSQE_FIXED_FILEset passesio_check_restriction()while operating on unregistered regular file descriptors.Reject
REQ_F_FIXED_FILEwith-EBADFinio_epoll_ctl_prep().
Seems like a case of too much LLM and too little actual thinking. The better solution here would be to allow a fixed file, there are numerous instances of exactly like that in io_uring. That would certainly be worth doing, for the sake of consistency.
Quoted 6 lines
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.
Can we stop these silly disclaimers? If you insist on putting advertisement in your emails, at least put them below the '---' so we don't get them in the git log at least.
Signature · 1 line
Jens Axboe