ANDROID: Fix initializing a static union variable
saddr_wildcard is a static union variable initialized with {}.
Empty brace initialization of union types is unspecified prior to C23,
and even in C23, it doesn't guarantee zero initialization of all fields
(see sections 4.5 and 6.2 in
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2900.htm).
Clang currently only initializes the first field to zero, leaving other
fields undefined. This can lead to unexpected behavior and optimizations
that produce random values (with some optimization flags).
See https://godbolt.org/z/hxnT1PTWo.
The issue has been reported to Clang upstream (
https://github.com/llvm/llvm-project/issues/78034#issuecomment-2183233517).
This commit mitigates the problem by avoiding empty brace initialization
in saddr_wildcard.
Fixes: 08ec9af1 ("xfrm: Fix xfrm_state_find() wrt. wildcard source address.")
Link: https://patchwork.kernel.org/project/netdevbpf/patch/20240621211819.1690234-1-yabinc@google.com/#25906597
Bug: 392184315
Bug: 435302614
Bug: 435559445
Change-Id: I494f48077fa5305b6fe1657127418ba8f7a39d36
Signed-off-by:
Yabin Cui <yabinc@google.com>
Reviewed-by:
Nick Desaulniers <ndesaulniers@google.com>
Loading
Please sign in to comment