Repository navigation
test: fix uninitialised memory reads in unittest_ipaddr - #73608
Closed
abrahamperz wants to merge 1 commit into
Closed
abrahamperz wants to merge 1 commit into
abrahamperz wants to merge 1 commit into
Conversation
Running unittest_ipaddr under valgrind reported many "Conditional jump or move depends on uninitialised value(s)" errors (tracker ceph#64892). The tests build their own `struct ifaddrs` and `struct sockaddr_in`/ `sockaddr_in6` fixtures on the stack. The `ifaddrs` structs were never zero-initialised, so `ifa_flags` was read uninitialised in `grade_addr()` (a few tests even did `ifa_flags &= ~IFF_UP` on an uninitialised value). The `ipv4()`/`ipv6()` helpers only set the address family and address, so `sin_port`/`sin_zero` and `sin6_port`/`sin6_flowinfo`/`sin6_scope_id` stayed uninitialised and were later read when the addresses were formatted (getnameinfo). Value-initialise every `struct ifaddrs` fixture and memset the sockaddr in the `ipv4()`/`ipv6()` helpers. With both changes valgrind reports 0 errors and all 47 tests still pass. Signed-off-by: Abraham Pérez <[email protected]>
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
abrahamperz
marked this pull request as ready for review
November 7, 2026 17:31
Contributor
Author
This was referenced Nov 9, 2026
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.
Running
unittest_ipaddrunder valgrind (ctest -R unittest_ipaddr -T memcheck) reports many "Conditional jump or move depends on uninitialised value(s)" errors (tracker #64892).Root cause: the tests build their own fixtures on the stack and leave fields uninitialised.
struct ifaddrsfixtures are never zero-initialised, soifa_flagsis read uninitialised ingrade_addr()(a few tests even didifa_flags &= ~IFF_UPon an uninitialised value).ipv4()/ipv6()helpers only set the address family and address, leavingsin_port/sin_zeroandsin6_port/sin6_flowinfo/sin6_scope_iduninitialised; those are later read when the addresses are formatted (getnameinfo).Fix: value-initialise every
struct ifaddrsfixture andmemset()the sockaddr in theipv4()/ipv6()helpers.Before this change valgrind reported 64 errors from 7 contexts; after it,
ERROR SUMMARY: 0 errors from 0 contextsand all 47 tests still pass.Fixes: https://tracker.ceph.com/issues/64892
Checklist