mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Sieun Yang" <didtldms2525@naver.com>
To: <bernd@bsbernd.com>, <joannelkoong@gmail.com>
Cc: <miklos@szeredi.hu>, <fuse-devel@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] fuse: enforce file modes for io_uring commands
Date: Thu, 19 Nov 2026 00:54:33 +0900	[thread overview]
Message-ID: <2a2eb8c6a3fc9d6e2dbdc4e5bb8c956e@cweb004.nm> (raw)

Ordinary read() and write() enforce FMODE_READ and FMODE_WRITE before
reaching FUSE. IORING_OP_URING_CMD does not, and FUSE's command handler
does not check either mode. REGISTER can therefore deliver requests
through an O_WRONLY connection. COMMIT_AND_FETCH also enters its
reply-and-fetch path through an O_RDONLY connection.

This can expose data to a process given only a write-only FUSE
connection. On 7.4.0-rc3-g20eef29b7c84 with fuse.enable_uring=1,
uid 1000 received a FUSE_WRITE request containing 36 bytes written by
uid 2000 after being passed only an O_WRONLY connection fd. Ordinary
read() on that fd returned EBADF, and new O_RDONLY and O_RDWR opens of
/dev/fuse were denied. The mount used default_permissions and a file
owned by uid 2000 with mode 0200.

Require FMODE_READ for REGISTER. COMMIT_AND_FETCH both submits a reply
and fetches the next request, so require FMODE_READ and FMODE_WRITE.
The same test returned EBADF for REGISTER with the change applied.

Fixes: 24fe962c86f5 ("fuse: {io-uring} Handle SQEs - register commands")
Fixes: c090c8abae4b ("fuse: Add io-uring sqe commit and fetch support")
Cc: stable@vger.kernel.org
Signed-off-by: Sieun Yang <didtldms2525@jnu.ac.kr>
---
 fs/fuse/dev_uring.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 460776cd6..481368ac9 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -1698,6 +1698,8 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
 
 	switch (cmd_op) {
 	case FUSE_IO_URING_CMD_REGISTER:
+		if (!(cmd->file->f_mode & FMODE_READ))
+			return -EBADF;
 		err = fuse_uring_register(cmd, issue_flags, fch);
 		if (err) {
 			pr_info_once("FUSE_IO_URING_CMD_REGISTER failed err=%d\n",
@@ -1708,6 +1710,9 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
 		}
 		break;
 	case FUSE_IO_URING_CMD_COMMIT_AND_FETCH:
+		if ((cmd->file->f_mode & (FMODE_READ | FMODE_WRITE)) !=
+		    (FMODE_READ | FMODE_WRITE))
+			return -EBADF;
 		err = fuse_uring_commit_fetch(cmd, issue_flags, fch);
 		if (err) {
 			pr_info_once("FUSE_IO_URING_COMMIT_AND_FETCH failed err=%d\n",

base-commit: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca
-- 
2.39.5

                 reply	other threads:[~2026-11-18 15:54 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=2a2eb8c6a3fc9d6e2dbdc4e5bb8c956e@cweb004.nm \
    --to=didtldms2525@naver.com \
    --cc=bernd@bsbernd.com \
    --cc=fuse-devel@lists.linux.dev \
    --cc=joannelkoong@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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

all inboxes | Powered by JetHome®