]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: btf: Fix bitfield extraction for big endian
authorOkash Khawaja <osk@fb.com>
Tue, 10 Jul 2018 21:33:07 +0000 (14:33 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 11 Jul 2018 20:36:08 +0000 (22:36 +0200)
commitc06b421e73d0895d43a28e31ea838457022c7134
tree6f2c9bc4ce56c7d0f63b7754d5cb34bb3960b4a4
parentf28d8843a1e6e778c093fca2a235034751e22c54
bpf: btf: Fix bitfield extraction for big endian

When extracting bitfield from a number, btf_int_bits_seq_show() builds
a mask and accesses least significant byte of the number in a way
specific to little-endian. This patch fixes that by checking endianness
of the machine and then shifting left and right the unneeded bits.

Thanks to Martin Lau for the help in navigating potential pitfalls when
dealing with endianess and for the final solution.

Fixes: 61662444ba2c ("bpf: btf: Add pretty print capability for data with BTF type info")
Signed-off-by: Okash Khawaja <osk@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/btf.c