提交 f71b06b2 编写于 作者: K KP Singh 提交者: Zheng Zengkai

libbpf: Add explicit padding to btf_dump_emit_type_decl_opts

stable inclusion
from stable-5.10.37
commit 454fb207476b34daa26fca1692eacd763b0adea9
bugzilla: 51868
CVE: NA

--------------------------------

[ Upstream commit ea24b195 ]

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: 9f81654e ("libbpf: Expose BTF-to-C type declaration emitting API")
Suggested-by: NAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: NKP Singh <kpsingh@kernel.org>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210319192117.2310658-1-kpsingh@kernel.orgSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 19f9534c
...@@ -164,6 +164,7 @@ struct btf_dump_emit_type_decl_opts { ...@@ -164,6 +164,7 @@ struct btf_dump_emit_type_decl_opts {
int indent_level; int indent_level;
/* strip all the const/volatile/restrict mods */ /* strip all the const/volatile/restrict mods */
bool strip_mods; bool strip_mods;
size_t :0;
}; };
#define btf_dump_emit_type_decl_opts__last_field strip_mods #define btf_dump_emit_type_decl_opts__last_field strip_mods
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册