Skip to content

fix(syscall): add addrlen bounds check in ff_hook_bind#1068

Merged
jfb8856606 merged 1 commit into
devfrom
fix/bind-addrlen-bounds-check
Jun 8, 2026
Merged

fix(syscall): add addrlen bounds check in ff_hook_bind#1068
jfb8856606 merged 1 commit into
devfrom
fix/bind-addrlen-bounds-check

Conversation

@jfb8856606

Copy link
Copy Markdown
Contributor

Cherry-picks the bind() bounds check from #1067 and omits the accompanying test file.

Change

Reject ff_hook_bind calls with addrlen > sizeof(struct sockaddr_storage) to prevent out-of-bounds reads when copying the address into shared memory via rte_memcpy.

if (addrlen > sizeof(struct sockaddr_storage)) {
    errno = EINVAL;
    return -1;
}

Why this PR (instead of merging #1067 directly)

  • The bind bounds check itself is a reasonable defensive hardening, so it is kept.
  • The test file tests/test_invariant_ff_hook_syscall.c introduced in fix: add buffer-length check in ff_hook_syscall.c #1067 was intentionally not included, because:
    • It does not actually call ff_hook_bind; it only re-implements an if (addrlen > 128) check and asserts on its own logic, so it does not cover the modified code path.
    • The threshold 128 is hard-coded and inconsistent with the actual fix, which uses sizeof(struct sockaddr_storage).
    • It introduces a new dependency on the check framework that is not part of the existing build.
    • The file is missing a trailing newline.

Risk

Low. addrlen originates from the calling process's own bind(), not from remote input, so this is defensive hardening rather than a remotely-exploitable fix.

Test

  • make ff_hook_syscall.o and full make in adapter/syscall/ succeed under -Wall -Werror -O2 with no warnings or errors. The only link-time miss is -lfstack, which is produced by the upper lib/ target and unrelated to this change.

Closes part of #1067 (the bind hardening).

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.
@jfb8856606 jfb8856606 merged commit 8762e05 into dev Jun 8, 2026
7 checks passed
@jfb8856606 jfb8856606 deleted the fix/bind-addrlen-bounds-check branch June 8, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant