提交 583669ab 编写于 作者: Y Yuntao Wang 提交者: Daniel Borkmann

bpf: Simplify check in btf_parse_hdr()

Replace offsetof(hdr_len) + sizeof(hdr_len) with offsetofend(hdr_len) to
simplify the check for correctness of btf_data_size in btf_parse_hdr()
Signed-off-by: NYuntao Wang <ytcoode@gmail.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220320075240.1001728-1-ytcoode@gmail.com
上级 ec80906b
...@@ -4482,8 +4482,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env) ...@@ -4482,8 +4482,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env)
btf = env->btf; btf = env->btf;
btf_data_size = btf->data_size; btf_data_size = btf->data_size;
if (btf_data_size < if (btf_data_size < offsetofend(struct btf_header, hdr_len)) {
offsetof(struct btf_header, hdr_len) + sizeof(hdr->hdr_len)) {
btf_verifier_log(env, "hdr_len not found"); btf_verifier_log(env, "hdr_len not found");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册