mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fuse: enforce file modes for io_uring commands
@ 2026-11-18 15:54 Sieun Yang
  0 siblings, 0 replies; only message in thread
From: Sieun Yang @ 2026-11-18 15:54 UTC (permalink / raw)
  To: bernd, joannelkoong; +Cc: miklos, fuse-devel, linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-18 15:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 15:54 [PATCH] fuse: enforce file modes for io_uring commands Sieun Yang

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®