projects/linux·commit 7d87a5a2

fuse-uring: clear ent->fuse_req in commit_fetch error path

7d87a5a2 · Zhenghang Xiao <[email protected]> · 2026-06-15 12:25:56 +02:00

fuse_uring_commit_fetch() error path called fuse_request_end(req) without
clearing ent->fuse_req when fuse_ring_ent_set_commit() fails. The
still-pending fuse_uring_send_in_task() task-work later dereferences the
dangling pointer through fuse_uring_prepare_send(), causing a
use-after-free.

End the request with fuse_uring_req_end(), which handles all conditions
already.

Annotation/edition by Bernd: The UAF should be fixed by other means already
and actually has to be avoided that way.
Just checking for ent->fuse_req == NULL in fuse_uring_send_in_task()
would be prone to race conditions, because if malicious userspace
would commit requests that have passed the NULL check, but are
in doing args copy, it would still trigger a use-after-free.
Setting ent->fuse_req = NULL in fuse_uring_commit_fetch() still
makes sense, though.

Reported-by: Shuvam Pandey <[email protected]>
Reported-by: Berkant Koc <[email protected]>
Signed-off-by: Zhenghang Xiao <[email protected]>
Signed-off-by: Bernd Schubert <[email protected]>
Reviewed-by: Joanne Koong <[email protected]>
Signed-off-by: Miklos Szeredi <[email protected]>
Commit
7d87a5a284bb34edb3f4e7e312ef403b3385a7b7
Parents
8bbb2ad1

Changes

1 files changed · +1 −3

FileStatusAddDelContent
fs/fuse/dev_uring.cmodified+1−3View file

fs/fuse/dev_uring.c

View file
diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index ba5edf5..77c8cec 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -1003,9 +1003,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;
}