]> git.proxmox.com Git - mirror_ubuntu-kernels.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)
commitb65f370d0671c4980ffe866c41e327b88893245c
tree6f2c9bc4ce56c7d0f63b7754d5cb34bb3960b4a4
parent61d769807f273fda962866f3d4c677cda9974d3c
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: b00b8daec828 ("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