Linux kernel -stable discussions
 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 7.3.y 10/15] io_uring/openclose: allow an empty path with O_EMPTYPATH
Date: Sat,  5 Dec 2026 23:13:00 +0000	[thread overview]
Message-ID: <20261205231305.4158103-11-axboe@kernel.dk> (raw)
In-Reply-To: <20261205231305.4158103-1-axboe@kernel.dk>

From: Hengyu Liang <hengyul@cs.unc.edu>

Commit 080434cbb0e9bf03e83f35ebc1cb339546ff6e1a upstream.

Commit 31cf44efa6df ("vfs: add O_EMPTYPATH to openat(2)/openat2(2)")
made build_open_flags() accept O_EMPTYPATH and turn it into
LOOKUP_EMPTY, so that openat(fd, "", O_EMPTYPATH) reopens the file
behind fd.

However, io_uring also uses build_open_flags(), but __io_openat_prep()
still copies the name with delayed_getname(), which rejects an empty
name with -ENOENT. As of now, IORING_OP_OPENAT and IORING_OP_OPENAT2
accept O_EMPTYPATH, but fail on the empty path this flag is meant for.

Before 31cf44efa6df, both calls fail: it prints "openat: -1" and
"IORING_OP_OPENAT: -2". After that commit (v7.2), the result is:

    openat: 4
    IORING_OP_OPENAT: -2

Copy the name with delayed_getname_uflags() and AT_EMPTY_PATH when
O_EMPTYPATH is set, as io_uring's statx already does for AT_EMPTY_PATH.

Fixes: 31cf44efa6df ("vfs: add O_EMPTYPATH to openat(2)/openat2(2)")
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Link: https://patch.msgid.link/20261125180817.3682397-1-hengyul@cs.unc.edu
Reviewed-by: Jori Koolstra (CIQ) <jkoolstra@xs4all.nl>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 io_uring/openclose.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/io_uring/openclose.c b/io_uring/openclose.c
index 24cf3ce2e2bc..29fe31f16a2b 100644
--- a/io_uring/openclose.c
+++ b/io_uring/openclose.c
@@ -54,6 +54,7 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
 {
 	struct io_open *open = io_kiocb_to_cmd(req, struct io_open);
 	const char __user *fname;
+	int uflags = 0;
 	int ret;
 
 	if (unlikely(sqe->buf_index))
@@ -67,7 +68,9 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
 
 	open->dfd = READ_ONCE(sqe->fd);
 	fname = u64_to_user_ptr(READ_ONCE(sqe->addr));
-	ret = delayed_getname(&open->filename, fname);
+	if (open->how.flags & O_EMPTYPATH)
+		uflags = AT_EMPTY_PATH;
+	ret = delayed_getname_uflags(&open->filename, fname, uflags);
 	if (unlikely(ret))
 		return ret;
 	req->flags |= REQ_F_NEED_CLEANUP;
-- 
2.55.0


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

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 23:12 [PATCH 7.3.y 00/15] io_uring fixes for 7.3-stable Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 01/15] io_uring/net: don't charge the folio offset to truesize for managed frags Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 02/15] io_uring/net: don't copy msg_name on a recvmsg retry Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 03/15] io_uring/kbuf: clear REQ_F_BL_NO_RECYCLE on buffer put Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 04/15] io_uring: free the ring after a grace period Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 05/15] io_uring/filetable: don't install O_PATH files Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 06/15] io_uring/timeout: hold timeout_lock for the link splice Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 07/15] io_uring/cancel: always walk links under timeout_lock Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 08/15] io_uring/net: don't count the buffers of a send bundle Jens Axboe
2026-12-05 23:12 ` [PATCH 7.3.y 09/15] io_uring/net: restore the cmsg buffer on recvmsg retry Jens Axboe
2026-12-05 23:13 ` Jens Axboe [this message]
2026-12-05 23:13 ` [PATCH 7.3.y 11/15] io_uring/bpf-ops: validate loop_step before registration Jens Axboe
2026-12-05 23:13 ` [PATCH 7.3.y 12/15] io_uring: close poll activation race when enabling rings Jens Axboe
2026-12-05 23:13 ` [PATCH 7.3.y 13/15] io_uring/cancel: arm local work wakeups only for submitter Jens Axboe
2026-12-05 23:13 ` [PATCH 7.3.y 14/15] io_uring/zcrx: don't sync dma-bufs Jens Axboe
2026-12-05 23:13 ` [PATCH 7.3.y 15/15] io_uring: enforce task restrictions on blind MSG_RING 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=20261205231305.4158103-11-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox