projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9327acd
)
libbpf: Fix off-by-one bug in bpf_core_apply_relo()
author
Andrii Nakryiko
<andrii@kernel.org>
Mon, 25 Oct 2021 22:45:28 +0000
(15:45 -0700)
committer
Alexei Starovoitov
<ast@kernel.org>
Tue, 26 Oct 2021 01:37:21 +0000
(18:37 -0700)
Fix instruction index validity check which has off-by-one error.
Fixes: 3ee4f5335511 ("libbpf: Split bpf_core_apply_relo() into bpf_program independent helper.")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link:
https://lore.kernel.org/bpf/20211025224531.1088894-2-andrii@kernel.org
tools/lib/bpf/libbpf.c
patch
|
blob
|
history
diff --git
a/tools/lib/bpf/libbpf.c
b/tools/lib/bpf/libbpf.c
index 604abe00785f816e725e8fd6a19fabe0d185e881..e27a249d46fb933efe1b9ba014c342823b7ee162 100644
(file)
--- a/
tools/lib/bpf/libbpf.c
+++ b/
tools/lib/bpf/libbpf.c
@@
-5405,7
+5405,7
@@
static int bpf_core_apply_relo(struct bpf_program *prog,
* relocated, so it's enough to just subtract in-section offset
*/
insn_idx = insn_idx - prog->sec_insn_off;
- if (insn_idx > prog->insns_cnt)
+ if (insn_idx >
=
prog->insns_cnt)
return -EINVAL;
insn = &prog->insns[insn_idx];