Conversation
Linux's unaligned_p() rejects futex operations whose uaddr is not 4-byte aligned, since an unaligned 4-byte word loses atomicity on arm64 and can straddle a page boundary. Mirror that across the WAIT/WAKE/REQUEUE/CMP_REQUEUE/WAKE_OP/LOCK_PI/TRYLOCK_PI/UNLOCK_PI dispatch sites by returning -EINVAL when the uaddr fails the 4-byte alignment check. robust_list_walk now applies the same check before touching each futex word: an unaligned or out-of-range futex_gva is skipped (the list itself still advances). Without the gate, a partial cross-page guest_write_small could leave the futex word in a torn state while the subsequent wake is suppressed, leaving waiters wedged on a half-modified word. Also handle the OWNER_DIED write failure case: log the address at debug level and suppress the wake. Waking after a failed write would just send waiters back to sleep on the unchanged word. This mirrors Linux handle_futex_death, which gives up on the entry without waking when the user-memory update faults. log_debug avoids stderr spam when a corrupted robust list trips the cap repeatedly.
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.
Linux's unaligned_p() rejects futex operations whose uaddr is not 4-byte aligned, since an unaligned 4-byte word loses atomicity on arm64 and can straddle a page boundary. Mirror that across the
WAIT/WAKE/REQUEUE/CMP_REQUEUE/WAKE_OP/LOCK_PI/TRYLOCK_PI/UNLOCK_PI dispatch sites by returning -EINVAL when the uaddr fails the 4-byte alignment check.
robust_list_walk now applies the same check before touching each futex word: an unaligned or out-of-range futex_gva is skipped (the list itself still advances). Without the gate, a partial cross-page guest_write_small could leave the futex word in a torn state while the subsequent wake is suppressed, leaving waiters wedged on a half-modified word.
Also handle the OWNER_DIED write failure case: log the address at debug level and suppress the wake. Waking after a failed write would just send waiters back to sleep on the unchanged word. This mirrors Linux handle_futex_death, which gives up on the entry without waking when the user-memory update faults. log_debug avoids stderr spam when a corrupted robust list trips the cap repeatedly.
Summary by cubic
Reject unaligned futex addresses across all futex paths and tighten robust-list cleanup to avoid torn writes and stuck waiters. Matches Linux by returning -EINVAL for any 4-byte misaligned
uaddrand by suppressing wakeups when OWNER_DIED updates fail.uaddrin WAIT, WAKE, REQUEUE/CMP_REQUEUE, WAKE_OP, and PI ops (LOCK_PI, TRYLOCK_PI, UNLOCK_PI).robust_list_walk, skip out-of-range or unaligned futex words; on OWNER_DIED write failure, log debug with address and do not wake.Written for commit 16ad7b4. Summary will update on new commits.