libbpf: Fix endianness detection in BPF_CORE_READ_BITFIELD_PROBED()
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 26 Oct 2021 01:08:26 +0000 (03:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:41 +0000 (19:16 +0100)
commitd48715b25f2ef1f839eb9ee107d45dd029229f12
tree8fe6ec8abe55bb185a7aa55abbee5940cbb5579a
parentbf5e3d54de65100191ef1b08e2bac47a1a96b0a8
libbpf: Fix endianness detection in BPF_CORE_READ_BITFIELD_PROBED()

[ Upstream commit 45f2bebc8079788f62f22d9e8b2819afb1789d7b ]

__BYTE_ORDER is supposed to be defined by a libc, and __BYTE_ORDER__ -
by a compiler. bpf_core_read.h checks __BYTE_ORDER == __LITTLE_ENDIAN,
which is true if neither are defined, leading to incorrect behavior on
big-endian hosts if libc headers are not included, which is often the
case.

Fixes: ee26dade0e3b ("libbpf: Add support for relocatable bitfields")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211026010831.748682-2-iii@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/lib/bpf/bpf_core_read.h