Skip to content

Commit 75ad96b

Browse files
sinkapgregkh
authored andcommitted
libbpf: Add explicit padding to btf_dump_emit_type_decl_opts
[ Upstream commit ea24b19 ] Similar to https://lore.kernel.org/bpf/20210313210920.1959628-2-andrii@kernel.org/ When DECLARE_LIBBPF_OPTS is used with inline field initialization, e.g: DECLARE_LIBBPF_OPTS(btf_dump_emit_type_decl_opts, opts, .field_name = var_ident, .indent_level = 2, .strip_mods = strip_mods, ); and compiled in debug mode, the compiler generates code which leaves the padding uninitialized and triggers errors within libbpf APIs which require strict zero initialization of OPTS structs. Adding anonymous padding field fixes the issue. Fixes: 9f81654 ("libbpf: Expose BTF-to-C type declaration emitting API") Suggested-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: KP Singh <kpsingh@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210319192117.2310658-1-kpsingh@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 590c628 commit 75ad96b

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎tools/lib/bpf/btf.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ struct btf_dump_emit_type_decl_opts {
173173
int indent_level;
174174
/* strip all the const/volatile/restrict mods */
175175
bool strip_mods;
176+
size_t :0;
176177
};
177178
#define btf_dump_emit_type_decl_opts__last_field strip_mods
178179

0 commit comments

Comments
 (0)