The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Berkant Koc <me@berkoc.com>
To: Greg KH <gregkh@linuxfoundation.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Bernd Schubert <bschubert@ddn.com>
Cc: security@kernel.org, Joanne Koong <joannelkoong@gmail.com>,
	linux-fuse@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] fuse: io-uring: clear ent->fuse_req in commit_fetch error path
Date: Sun, 17 May 2026 14:59:37 +0200	[thread overview]
Message-ID: <20260517-fuse-uaf-patch1@berkoc.com> (raw)
In-Reply-To: <20260517-fuse-uaf-cover@berkoc.com>

From: Berkant Koc <me@berkoc.com>

fuse_uring_commit_fetch() locates a request, removes it from the
processing queue, clears req->ring_entry, then calls
fuse_ring_ent_set_commit() under queue->lock. On the error branch
(set_commit returning non-zero because the entry is not in
FRRS_USERSPACE) the function unlocks the queue and ends the request
directly with fuse_request_end(), but it never clears ent->fuse_req.

ent->fuse_req then keeps pointing at the freed fuse_req while the entry
remains on a queue list. Subsequent teardown via
fuse_uring_entry_teardown() reads ent->fuse_req under queue->lock and
hands the dangling pointer to fuse_uring_stop_fuse_req_end(), which
dereferences it and calls fuse_request_end() a second time on freed
memory.

Route the error branch through fuse_uring_req_end() instead. That
helper acquires queue->lock, clears ent->fuse_req under the lock,
removes the request from any list it is still on, drops the lock, sets
req->out.h.error, clears FR_SENT and ends the request. The
ent->fuse_req = NULL store under the lock is what closes the window
for the later teardown reader.

Fixes: c090c8abae4b ("fuse: Add io-uring sqe commit and fetch support")
Cc: stable@vger.kernel.org # 6.14+
Signed-off-by: Berkant Koc <me@berkoc.com>
---
 fs/fuse/dev_uring.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 7b9822e8837b..7523569ffdce 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -924,9 +924,7 @@ static int fuse_uring_commit_fetch(struct io_uring_cmd *cmd, int issue_flags,
 		pr_info_ratelimited("qid=%d commit_id %llu state %d",
 				    queue->qid, commit_id, ent->state);
 		spin_unlock(&queue->lock);
-		req->out.h.error = err;
-		clear_bit(FR_SENT, &req->flags);
-		fuse_request_end(req);
+		fuse_uring_req_end(ent, req, err);
 		return err;
 	}

--
2.47.3

  reply	other threads:[~2026-05-17 12:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260517095846.fuse-iouring-uaf.dc5f5dbb71dc@berkoc.com>
     [not found] ` <2026051703-equinox-multitude-91e2@gregkh>
2026-05-17 12:59   ` [PATCH 0/2] fuse: io-uring: fix two UAFs in dev_uring.c teardown Berkant Koc
2026-05-17 12:59     ` Berkant Koc [this message]
2026-05-17 14:11       ` [PATCH 1/2] fuse: io-uring: clear ent->fuse_req in commit_fetch error path Bernd Schubert
2026-05-17 14:24         ` Berkant Koc
2026-05-17 12:59     ` [PATCH 2/2] fuse: wait for aborted connection before releasing last fuse_dev Berkant Koc
2026-05-17 15:00       ` Bernd Schubert
2026-05-18  1:13         ` Berkant Koc
2026-05-18  9:55           ` Bernd Schubert
2026-05-18 11:47             ` Bernd Schubert
2026-05-18 14:32               ` Berkant Koc
2026-05-18 14:46                 ` Bernd Schubert
2026-05-18 15:35                   ` Joanne Koong
2026-05-18 17:49                     ` Berkant Koc
2026-05-18 15:47                   ` Berkant Koc
2026-05-18  9:06         ` Pavel Begunkov
2026-05-18  9:50           ` Bernd Schubert
2026-05-18 10:32             ` Pavel Begunkov
2026-05-17 13:14     ` [PATCH 0/2] fuse: io-uring: fix two UAFs in dev_uring.c teardown Berkant Koc
2026-05-17 13:43       ` Bernd Schubert
2026-05-17 14:02         ` Berkant Koc

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=20260517-fuse-uaf-patch1@berkoc.com \
    --to=me@berkoc.com \
    --cc=bschubert@ddn.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fuse@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=security@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