]> www.infradead.org Git - users/jedix/linux-maple.git/commit
fuse: {io-uring} Fix a possible req cancellation race
authorBernd Schubert <bschubert@ddn.com>
Tue, 25 Mar 2025 17:29:31 +0000 (18:29 +0100)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 31 Mar 2025 12:53:02 +0000 (14:53 +0200)
commit09098e62e4be8f0755e58d6078aaf27cbd9a3a8d
treed1c03f07301687a382b7efb94de2160e1f9cf41f
parent4701f33a10702d5fc577c32434eb62adde0a1ae1
fuse: {io-uring} Fix a possible req cancellation race

task-A (application) might be in request_wait_answer and
try to remove the request when it has FR_PENDING set.

task-B (a fuse-server io-uring task) might handle this
request with FUSE_IO_URING_CMD_COMMIT_AND_FETCH, when
fetching the next request and accessed the req from
the pending list in fuse_uring_ent_assign_req().
That code path was not protected by fiq->lock and so
might race with task-A.

For scaling reasons we better don't use fiq->lock, but
add a handler to remove canceled requests from the queue.

This also removes usage of fiq->lock from
fuse_uring_add_req_to_ring_ent() altogether, as it was
there just to protect against this race and incomplete.

Also added is a comment why FR_PENDING is not cleared.

Fixes: c090c8abae4b ("fuse: Add io-uring sqe commit and fetch support")
Cc: <stable@vger.kernel.org> # v6.14
Reported-by: Joanne Koong <joannelkoong@gmail.com>
Closes: https://lore.kernel.org/all/CAJnrk1ZgHNb78dz-yfNTpxmW7wtT88A=m-zF0ZoLXKLUHRjNTw@mail.gmail.com/
Signed-off-by: Bernd Schubert <bschubert@ddn.com>
Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dev.c
fs/fuse/dev_uring.c
fs/fuse/dev_uring_i.h
fs/fuse/fuse_dev_i.h
fs/fuse/fuse_i.h