All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: stable@vger.kernel.org
Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org
Subject: [PATCH 6.6.y 06/13] io_uring/filetable: don't install O_PATH files
Date: Sat,  5 Dec 2026 23:12:26 +0000	[thread overview]
Message-ID: <20261205231233.4140988-7-axboe@kernel.dk> (raw)
In-Reply-To: <20261205231233.4140988-1-axboe@kernel.dk>

From: Chris Mason <mason@kernel.org>

Commit e49d115878796b7b7f77f821d67b7b2f7ccaf400 upstream.

IORING_OP_FADVISE with POSIX_FADV_WILLNEED on a fixed file that was
opened with O_PATH can dereference a NULL pointer in the readahead code
of the filesystem.

The opcode handlers are written like the system calls that they mirror,
which get their file from fdget() and so never see an O_PATH file.
io_uring has to keep that true for req->file. io_file_get_normal() does,
with fget(). io_file_get_fixed() checks nothing, so a fixed file table
must never hold an O_PATH file. The register and update paths take their
files from fget(). But a direct open, IORING_OP_OPENAT or
IORING_OP_OPENAT2 with sqe->file_index set, installs the file that
do_file_open() returns, and io_install_fixed_file() refuses nothing but
io_uring files.

With O_PATH, do_dentry_open() returns before it calls ->open(), so
file->private_data stays NULL. generic_fadvise() has no check of its own
and starts readahead with that file, and fuse_send_readpages(), for one,
dereferences file->private_data.

The fix used here is to refuse O_PATH files in io_install_fixed_file()
as well, so that a direct open gives what an open followed by a register
gives.

A direct open with O_PATH now fails with -EBADF. Until now the slot
could be turned into a descriptor with IORING_OP_FIXED_FD_INSTALL,
passed to another ring with IORING_MSG_SEND_FD, and used with
IORING_OP_FGETXATTR and IORING_OP_FSETXATTR. No program that does so is
known, and a fixed file can't serve as the directory of a lookup.

Fixes: b9445598d8c6 ("io_uring: openat directly into fixed fd table")
Signed-off-by: Chris Mason <mason@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 io_uring/filetable.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/io_uring/filetable.c b/io_uring/filetable.c
index aa9f0abcd8ee..802a45c6ee74 100644
--- a/io_uring/filetable.c
+++ b/io_uring/filetable.c
@@ -73,6 +73,9 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file,
 
 	if (io_is_uring_fops(file))
 		return -EBADF;
+	/* Registered files come from fget(), which refuses these too */
+	if (file->f_mode & FMODE_PATH)
+		return -EBADF;
 	if (!ctx->file_data)
 		return -ENXIO;
 	if (slot_index >= ctx->nr_user_files)
-- 
2.55.0


  parent reply	other threads:[~2026-12-05 23:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 23:12 [PATCH 6.6.y 00/13] io_uring fixes for 6.6-stable Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 01/13] io_uring/net: don't charge the folio offset to truesize for managed frags Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 02/13] io_uring/net: don't copy msg_name on a recvmsg retry Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 03/13] io_uring/tctx: add separate lock for list of tctx's in ctx Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 04/13] io_uring: free the task context after a grace period Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 05/13] io_uring: free the ring " Jens Axboe
2026-12-05 23:12 ` Jens Axboe [this message]
2026-12-05 23:12 ` [PATCH 6.6.y 07/13] io_uring: make ctx->timeout_lock a raw spinlock Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 08/13] io_uring/timeout: flush timeouts outside of the timeout lock Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 09/13] io_uring/cancel: always walk links under timeout_lock Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 10/13] io_uring/net: restore the cmsg buffer on recvmsg retry Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 11/13] io_uring_poll: kill the no longer necessary barrier after poll_wait() Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 12/13] io_uring: close poll activation race when enabling rings Jens Axboe
2026-12-05 23:12 ` [PATCH 6.6.y 13/13] io_uring/cancel: arm local work wakeups only for submitter 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=20261205231233.4140988-7-axboe@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=gregkh@linuxfoundation.org \
    --cc=io-uring@vger.kernel.org \
    --cc=stable@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.