From: Sasha Levin Date: Thu, 13 Apr 2023 02:31:12 +0000 (-0400) Subject: Fixes for 6.1 X-Git-Tag: v5.15.107~1^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ffee26dc9c3320e324ee6b01ee11bd9fc54401bb;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 6.1 Signed-off-by: Sasha Levin --- diff --git a/queue-6.1/bpftool-print-newline-before-for-struct-with-padding.patch b/queue-6.1/bpftool-print-newline-before-for-struct-with-padding.patch new file mode 100644 index 00000000000..c57d3e57da9 --- /dev/null +++ b/queue-6.1/bpftool-print-newline-before-for-struct-with-padding.patch @@ -0,0 +1,55 @@ +From 292fe1693c8b3cb3bb94efd082b8023eef6dc6e9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 1 Oct 2022 13:44:24 +0300 +Subject: bpftool: Print newline before '}' for struct with padding only fields + +From: Eduard Zingerman + +[ Upstream commit 44a726c3f23cf762ef4ce3c1709aefbcbe97f62c ] + +btf_dump_emit_struct_def attempts to print empty structures at a +single line, e.g. `struct empty {}`. However, it has to account for a +case when there are no regular but some padding fields in the struct. +In such case `vlen` would be zero, but size would be non-zero. + +E.g. here is struct bpf_timer from vmlinux.h before this patch: + + struct bpf_timer { + long: 64; + long: 64;}; + +And after this patch: + + struct bpf_dynptr { + long: 64; + long: 64; + }; + +Signed-off-by: Eduard Zingerman +Signed-off-by: Andrii Nakryiko +Link: https://lore.kernel.org/bpf/20221001104425.415768-1-eddyz87@gmail.com +Signed-off-by: Sasha Levin +--- + tools/lib/bpf/btf_dump.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c +index 56102711f395a..80a15a6802094 100644 +--- a/tools/lib/bpf/btf_dump.c ++++ b/tools/lib/bpf/btf_dump.c +@@ -1011,7 +1011,11 @@ static void btf_dump_emit_struct_def(struct btf_dump *d, + if (is_struct) + btf_dump_emit_bit_padding(d, off, t->size * 8, align, false, lvl + 1); + +- if (vlen) ++ /* ++ * Keep `struct empty {}` on a single line, ++ * only print newline when there are regular or padding fields. ++ */ ++ if (vlen || t->size) + btf_dump_printf(d, "\n"); + btf_dump_printf(d, "%s}", pfx(lvl)); + if (packed) +-- +2.39.2 + diff --git a/queue-6.1/series b/queue-6.1/series index c784d3acd1a..556cfdff496 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -162,3 +162,4 @@ maple_tree-remove-extra-smp_wmb-from-mas_dead_leaves.patch maple_tree-add-smp_rmb-to-dead-node-detection.patch maple_tree-add-rcu-lock-checking-to-rcu-callback-functions.patch mm-enable-maple-tree-rcu-mode-by-default.patch +bpftool-print-newline-before-for-struct-with-padding.patch