]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.15
authorSasha Levin <sashal@kernel.org>
Thu, 13 Apr 2023 02:31:13 +0000 (22:31 -0400)
committerSasha Levin <sashal@kernel.org>
Thu, 13 Apr 2023 02:31:13 +0000 (22:31 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.15/bpftool-print-newline-before-for-struct-with-padding.patch [new file with mode: 0644]
queue-5.15/series

diff --git a/queue-5.15/bpftool-print-newline-before-for-struct-with-padding.patch b/queue-5.15/bpftool-print-newline-before-for-struct-with-padding.patch
new file mode 100644 (file)
index 0000000..31de7a6
--- /dev/null
@@ -0,0 +1,55 @@
+From 7bd088b9bc902e3b24f8f77da9186ec26f123c1a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 1 Oct 2022 13:44:24 +0300
+Subject: bpftool: Print newline before '}' for struct with padding only fields
+
+From: Eduard Zingerman <eddyz87@gmail.com>
+
+[ 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 <eddyz87@gmail.com>
+Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
+Link: https://lore.kernel.org/bpf/20221001104425.415768-1-eddyz87@gmail.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ 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 8b1ba4b725e31..a9f974e5fb856 100644
+--- a/tools/lib/bpf/btf_dump.c
++++ b/tools/lib/bpf/btf_dump.c
+@@ -999,7 +999,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
+
index 4b65332e1ca5b1cf6e25b4c28a3bddaa0c9c60d3..01963010d8494246bc3962b1c0e03496c2790e22 100644 (file)
@@ -86,3 +86,4 @@ drm-bridge-lt9611-fix-pll-being-unable-to-lock.patch
 mm-take-a-page-reference-when-removing-device-exclusive-entries.patch
 kbuild-fix-single-directory-build.patch
 ocfs2-fix-freeing-uninitialized-resource-on-ocfs2_dlm_shutdown.patch
+bpftool-print-newline-before-for-struct-with-padding.patch