TCPIP: make the return value of network_socket_accept_tcp more expressive - #107
Open
nding0405 wants to merge 1 commit into
Open
TCPIP: make the return value of network_socket_accept_tcp more expressive#107nding0405 wants to merge 1 commit into
nding0405 wants to merge 1 commit into
Conversation
…sive The network_socket_accept_tcp function can only return either a valid sealed capability or an untagged nullptr, so the caller cannot distinguish a timeout from an out-of-memory failure. Change it so that it can return an invalid capability that encodes the error code.
nding0405
force-pushed
the
fix-accept-return-value
branch
from
July 23, 2026 19:25
860576b to
bd3fa50
Compare
nding0405
added a commit
to nding0405/network-stack
that referenced
this pull request
Jul 23, 2026
This patch completes the fix for issue CHERIoT-Platform#104. PR CHERIoT-Platform#107 added an ephemeral claim in with_sealed_socket(), protecting the SealedSocket wrapper until the first cross-compartment call. In network_socket_close(), that protection ends at heap_can_free(). In the post-reset close path, the socket lock cannot be acquired, so any later dereference of the wrapper may race with another thread freeing the wrapper and cause a Use-After-Free. The normal close path is not affected because the wrapper remains protected by socketLock. To remove this race, the fields needed after heap_can_free() are copied from the wrapper before the cross call, and the wrapper is not dereferenced afterward in the post-reset path. The raw FreeRTOS socket is also vulnerable in rawSocket->ucProtocol; because this value is needed only for the normal close path, but the current codebase make it accesible for both nomal close and post-reset close, ane the later path can produce an UAF on that line of code. Thus, to fix this, the dereference is moved inside the lock-protected branch. These changes eliminate both wrapper and raw-socket UAF from the unprotected post-reset path.
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.
The network_socket_accept_tcp function can only return either a valid sealed capability or an untagged nullptr, so the caller cannot distinguish a timeout from an out-of-memory failure. Change it so that it can return an invalid capability that encodes the error code.