linux-stable/tools
Andrii Nakryiko 78a95870c3 libbpf: Fix btf_dump's packed struct determination
[ Upstream commit 4fb877aaa1 ]

Fix bug in btf_dump's logic of determining if a given struct type is
packed or not. The notion of "natural alignment" is not needed and is
even harmful in this case, so drop it altogether. The biggest difference
in btf_is_struct_packed() compared to its original implementation is
that we don't really use btf__align_of() to determine overall alignment
of a struct type (because it could be 1 for both packed and non-packed
struct, depending on specifci field definitions), and just use field's
actual alignment to calculate whether any field is requiring packing or
struct's size overall necessitates packing.

Add two simple test cases that demonstrate the difference this change
would make.

Fixes: ea2ce1ba99 ("libbpf: Fix BTF-to-C converter's padding logic")
Reported-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/20221215183605.4149488-1-andrii@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-04-06 12:12:48 +02:00
..
accounting
arch tools headers arm64: Sync arm64's cputype.h with the kernel sources 2023-01-18 10:07:42 -03:00
bootconfig bootconfig: Fix testcase to increase max node 2023-03-30 12:50:57 +02:00
bpf bpftool: Always disable stack protection for BPF objects 2023-03-10 09:29:08 +01:00
build
certs
cgroup
counter
debugging
edid
firewire
firmware
gpio tools: gpio: fix -c option of gpio-event-mon 2023-01-27 14:05:46 +01:00
hv
iio tools/iio/iio_utils:fix memory leak 2023-03-11 13:50:40 +01:00
include tools headers: Syncronize linux/build_bug.h with the kernel sources 2023-01-18 10:31:11 -03:00
io_uring
kvm/kvm_stat
laptop
leds
lib libbpf: Fix btf_dump's packed struct determination 2023-04-06 12:12:48 +02:00
memory-model
objtool objtool: Fix memory leak in create_static_call_sections() 2023-03-11 13:50:21 +01:00
pci
pcmcia
perf perf stat: Fix counting when initial delay configured 2023-03-17 08:57:53 +01:00
power tools/power turbostat: fix decoding of HWP_STATUS 2023-04-06 12:12:30 +02:00
rcu
scripts
spi
testing libbpf: Fix btf_dump's packed struct determination 2023-04-06 12:12:48 +02:00
thermal
time
tracing tools/tracing/rtla: osnoise_hist: use total duration for average calculation 2023-03-10 09:28:43 +01:00
usb
verification Tracing fix for 6.2: 2022-12-21 19:03:42 -08:00
virtio tools/virtio: fix the vringh test for virtio ring changes 2023-01-27 06:18:41 -05:00
vm
wmi
Makefile