]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix bpffs bitfield pretty print
authorYonghong Song <yhs@fb.com>
Thu, 10 Jan 2019 19:14:00 +0000 (11:14 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 11 Jan 2019 09:40:54 +0000 (10:40 +0100)
commit8bcd4cfcdd2cd612647e027cc3207d2c2740e127
treeb6fe6e825c88f12b2e2a20f711701af97af15b86
parentb7675a688d7c2f18df3ac22b5bd7bf7074b2f8ea
bpf: fix bpffs bitfield pretty print

Commit d9226d80e6ce ("bpf: btf: fix struct/union/fwd types
with kind_flag") introduced kind_flag and used bitfield_size
in the btf_member to directly pretty print member values.

The commit contained a bug where the incorrect parameters could be
passed to function btf_bitfield_seq_show(). The bits_offset
parameter in the function expects a value less than 8.
Instead, the member offset in the structure is passed.

The below is btf_bitfield_seq_show() func signature:
  void btf_bitfield_seq_show(void *data, u8 bits_offset,
                             u8 nr_bits, struct seq_file *m)
both bits_offset and nr_bits are u8 type. If the bitfield
member offset is greater than 256, incorrect value will
be printed.

This patch fixed the issue by calculating correct proper
data offset and bits_offset similar to non kind_flag case.

Fixes: d9226d80e6ce ("bpf: btf: fix struct/union/fwd types with kind_flag")
Acked-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/btf.c