Skip to content

Fix unaligned enum values in btf_dump

Hungyu Lin bpf linux-kselftest lkml 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 0 repliesNew
  2. v22 patches 1 replySuperseded
  3. v11 patch 2 repliesSuperseded

Changes in v3 from the cover letter

- Do the alignment check before the size check (David).

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2libbpf: Fix sign extension of unaligned enums in btf_dump_get_enum_value()tools/lib/bpf/btf_dump.c+4 -90 replies
2/2selftests/bpf: Dump unaligned enums and a zeroed fs_contexttools/testing/selftests/bpf/prog_tests/btf_dump.c+9 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/2] Fix unaligned enum values in btf_dump

btf_dump_get_enum_value() reads unaligned enum values through btf_dump_get_bitfield_value() with a zero bit size, which shifts a __u64 by 64. Patch 1 copies unaligned enum data into an aligned buffer instead, as btf_dump_int_data() does. Patch 2 adds the tests Alexei posted in the v1 review.

Changes in v3:
- Do the alignment check before the size check (David).

Changes in v2:
- Describe the undefined shift in the commit log.
- Drop the data_end check, which broke the dump of struct fs_context without emit_zeroes.
- Add the selftests from the v1 review.

v2: https://lore.kernel.org/bpf/[email protected]/
v1: https://lore.kernel.org/bpf/[email protected]/

Hungyu Lin (2):
libbpf: Fix sign extension of unaligned enums in
btf_dump_get_enum_value()
selftests/bpf: Dump unaligned enums and a zeroed fs_context

 tools/lib/bpf/btf_dump.c                          | 13 ++++---------
 tools/testing/selftests/bpf/prog_tests/btf_dump.c | 10 +++++++++-
 2 files changed, 13 insertions(+), 10 deletions(-)

base-commit: 8835113107b2cf75df33a71e265cdeec5d5d13e0

Signature · 1 line
2.43.0