fix(syscall): add addrlen bounds check in ff_hook_bind#1068
Merged
Conversation
Reject bind() calls with addrlen larger than sizeof(struct sockaddr_storage) to prevent out-of-bounds reads when copying the address into shared memory via rte_memcpy. Defensive hardening (low-risk; addrlen comes from the local process, not a remote attacker). Cherry-picked from #1067; the accompanying test file in that PR was intentionally omitted because it does not actually exercise ff_hook_bind.
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.
Cherry-picks the bind() bounds check from #1067 and omits the accompanying test file.
Change
Reject
ff_hook_bindcalls withaddrlen > sizeof(struct sockaddr_storage)to prevent out-of-bounds reads when copying the address into shared memory viarte_memcpy.Why this PR (instead of merging #1067 directly)
tests/test_invariant_ff_hook_syscall.cintroduced in fix: add buffer-length check in ff_hook_syscall.c #1067 was intentionally not included, because:ff_hook_bind; it only re-implements anif (addrlen > 128)check and asserts on its own logic, so it does not cover the modified code path.128is hard-coded and inconsistent with the actual fix, which usessizeof(struct sockaddr_storage).checkframework that is not part of the existing build.Risk
Low.
addrlenoriginates from the calling process's ownbind(), not from remote input, so this is defensive hardening rather than a remotely-exploitable fix.Test
make ff_hook_syscall.oand fullmakeinadapter/syscall/succeed under-Wall -Werror -O2with no warnings or errors. The only link-time miss is-lfstack, which is produced by the upperlib/target and unrelated to this change.Closes part of #1067 (the bind hardening).