fix: split io_uring_submit_and_wait to prevent SQ ring race (issue #1443)#4
Open
ShukantPal wants to merge 2 commits intomasterfrom
Open
fix: split io_uring_submit_and_wait to prevent SQ ring race (issue #1443)#4ShukantPal wants to merge 2 commits intomasterfrom
ShukantPal wants to merge 2 commits intomasterfrom
Conversation
…bfuse#1443) io_uring_submit_and_wait() was called without holding ring_lock in fuse_uring_thread(), while reply threads concurrently call io_uring_get_sqe()/io_uring_submit() under ring_lock in fuse_uring_commit_sqe(). Both paths modify the SQ ring, causing corruption in multithreaded operation. Split into io_uring_submit() under ring_lock (serialized with other SQ operations) and io_uring_wait_cqe() without the lock (CQ ring is only written by the kernel and safe to read concurrently). Add a post-CQE-processing submit to flush SQEs prepared during handling (resubmits and synchronous replies skip submission when cqe_processing is set).
|
|
Add source-level validation tests that verify the fix for the io_uring SQ ring race condition in fuse_uring_thread(). The tests check that: - io_uring_submit_and_wait() is not used (broken pattern) - io_uring_submit() is called under ring_lock (serialized with fuse_uring_commit_sqe from reply threads) - io_uring_wait_cqe() is called without holding ring_lock (safe since CQ ring is kernel-written) - io_uring_submit() is called after CQE processing to flush deferred SQEs from reply threads These tests reliably fail without the fix and pass with it, avoiding the non-determinism inherent in runtime race condition testing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
io_uring_submit_and_wait() was called without holding ring_lock in
fuse_uring_thread(), while reply threads concurrently call
io_uring_get_sqe()/io_uring_submit() under ring_lock in
fuse_uring_commit_sqe(). Both paths modify the SQ ring, causing
corruption in multithreaded operation.
Split into io_uring_submit() under ring_lock (serialized with other
SQ operations) and io_uring_wait_cqe() without the lock (CQ ring is
only written by the kernel and safe to read concurrently). Add a
post-CQE-processing submit to flush SQEs prepared during handling
(resubmits and synchronous replies skip submission when
cqe_processing is set).