Repository navigation
async: move off the deprecated AsyncFd constructors - #344
Merged
Merged
Conversation
RUSTSEC-2026-0386 marks tokio's safe AsyncFd constructors unsound: they accept any AsRawFd, so a registration can outlive the descriptor it names. The fixed releases deprecate them in favour of the unsafe AsyncFd::register, which exists only from 1.51.6 and 1.53.3 on (1.52 is not patched), so the crates that register descriptors must require it. Signed-off-by: Cong Wang <cwang@multikernel.io>
tokio deprecates the safe AsyncFd constructors because nothing ties the registration to the descriptor's lifetime. Every site here hands the AsyncFd an owned fd, or an Arc that keeps it open, so the unsafe constructor's contract holds by construction and the SAFETY notes say which. Signed-off-by: Cong Wang <cwang@multikernel.io>
Reaper::exit and MainExit::wait registered a raw fd borrowed from a struct, so their soundness rested on callers never dropping the owner early, and a second concurrent waiter would hit EEXIST from epoll: exit() would then return before the reaper exited. Each waiter now registers its own dup, which shares readiness with the original and keeps the AsyncFd contract local. Signed-off-by: Cong Wang <cwang@multikernel.io>
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.
Fixes #343.
RUSTSEC-2026-0386 marks tokio's safe
AsyncFdconstructors unsound, and tokio 1.51.6 and 1.53.3+ deprecate them in favour of theunsafeAsyncFd::register. Our lockfile was on 1.51.0, so we never saw the warnings, but downstream users on newer tokio get the deprecation.sandlock-coreandsandlock-ocinow require tokio 1.53.3, becauseregisterdoesn't exist before then on this line (1.52 isn't patched). The lockfile moves to 1.54.1.OwnedFd, aControlFd, or anArc<OwnedFd>move toregister/register_with_interest, each with a one-line SAFETY note. This includessandlock-oci'sexit_watcher, which the issue didn't list.Reaper::exitandMainExit::waitregistered a raw fd borrowed from a struct. They now register their own dup, so the safety argument stays local. This also means a second concurrent waiter no longer getsEEXISTfrom epoll, which used to makeexit()return before the reaper had exited.Test plan
🤖 Generated with Claude Code