projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ec80906
)
bpf: Simplify check in btf_parse_hdr()
author
Yuntao Wang
<ytcoode@gmail.com>
Sun, 20 Mar 2022 07:52:40 +0000
(15:52 +0800)
committer
Daniel Borkmann
<daniel@iogearbox.net>
Mon, 21 Mar 2022 13:49:28 +0000
(14:49 +0100)
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: Yuntao Wang <ytcoode@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link:
https://lore.kernel.org/bpf/20220320075240.1001728-1-ytcoode@gmail.com
kernel/bpf/btf.c
patch
|
blob
|
history
diff --git
a/kernel/bpf/btf.c
b/kernel/bpf/btf.c
index ce212bf39b2b09171a2e6087d63e965474db21dd..24788ce564a08611dcc04f9f37acb520891537f0 100644
(file)
--- a/
kernel/bpf/btf.c
+++ b/
kernel/bpf/btf.c
@@
-4482,8
+4482,7
@@
static int btf_parse_hdr(struct btf_verifier_env *env)
btf = env->btf;
btf_data_size = btf->data_size;
- if (btf_data_size <
- offsetof(struct btf_header, hdr_len) + sizeof(hdr->hdr_len)) {
+ if (btf_data_size < offsetofend(struct btf_header, hdr_len)) {
btf_verifier_log(env, "hdr_len not found");
return -EINVAL;
}