mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/3] Fix unaligned enum values in btf_dump
@ 2026-11-26  1:12 Hungyu Lin
  2026-11-26  1:12 ` [PATCH bpf-next v4 1/3] libbpf: Fix sign extension of unaligned enums in btf_dump_get_enum_value() Hungyu Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hungyu Lin @ 2026-11-26  1:12 UTC (permalink / raw)
  To: andrii, bpf
  Cc: ast, daniel, eddyz87, memxor, martin.lau, song, yonghong.song,
	jolsa, emil, ihor.solodrai, alan.maguire, shuah, alexis.lothore,
	luisflavieira, ameryhung, david.laight.linux, linux-kselftest,
	linux-kernel, dennylin0707

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 makes the zero check of
enum bitfields read only the bytes of the bitfield, as Alexei suggested
in the v3 review. Patch 3 adds the tests Alexei posted in the v1 review.

Changes in v4:
- Add patch 2 to fix the zero check of enum bitfields (Alexei).

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.

v3: https://lore.kernel.org/bpf/20261116080151.44860-1-dennylin0707@gmail.com/
v2: https://lore.kernel.org/bpf/20261115084923.53182-1-dennylin0707@gmail.com/
v1: https://lore.kernel.org/bpf/20261113223449.97604-1-dennylin0707@gmail.com/

Hungyu Lin (3):
  libbpf: Fix sign extension of unaligned enums in
    btf_dump_get_enum_value()
  libbpf: Fix zero detection of enum bitfields in BTF dumper
  selftests/bpf: Dump unaligned enums and a zeroed fs_context

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


base-commit: 3cbbebf6819b42008e7ef85b6f0a7254c3074c19
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-26  1:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26  1:12 [PATCH bpf-next v4 0/3] Fix unaligned enum values in btf_dump Hungyu Lin
2026-11-26  1:12 ` [PATCH bpf-next v4 1/3] libbpf: Fix sign extension of unaligned enums in btf_dump_get_enum_value() Hungyu Lin
2026-11-26  1:12 ` [PATCH bpf-next v4 2/3] libbpf: Fix zero detection of enum bitfields in BTF dumper Hungyu Lin
2026-11-26  1:12 ` [PATCH bpf-next v4 3/3] selftests/bpf: Dump unaligned enums and a zeroed fs_context Hungyu Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®