]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
libbpf: Fix undefined behavior in {get,put}_unaligned_be32()
authorEric Biggers <ebiggers@kernel.org>
Mon, 6 Oct 2025 01:20:37 +0000 (18:20 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 6 Oct 2025 16:16:29 +0000 (09:16 -0700)
commit4d920ed684392ae064af62957d6f5a90312dfaf6
tree6b2c26b86f4a0c76a3c50451db7e6c2ca8a468d3
parentde7342228b7343774d6a9981c2ddbfb5e201044b
libbpf: Fix undefined behavior in {get,put}_unaligned_be32()

These violate aliasing rules and may be miscompiled unless
-fno-strict-aliasing is used.  Replace them with the standard memcpy()
solution.  Note that compilers know how to optimize this properly.

Fixes: 4a1c9e544b8d ("libbpf: remove linux/unaligned.h dependency for libbpf_sha256()")
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20251006012037.159295-1-ebiggers@kernel.org
tools/lib/bpf/libbpf_utils.c