diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-10-26 00:45:28 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-10-26 03:37:21 +0200 |
commit | de5d0dcef602de39070c31c7e56c58249c56ba37 (patch) | |
tree | a5d41c098437b7cfcea44149ce9627bb5b82d002 /tools/lib | |
parent | Merge branch 'bpftool: Switch to libbpf's hashmap for referencing BPF objects' (diff) | |
download | linux-de5d0dcef602de39070c31c7e56c58249c56ba37.tar.xz linux-de5d0dcef602de39070c31c7e56c58249c56ba37.zip |
libbpf: Fix off-by-one bug in bpf_core_apply_relo()
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
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/bpf/libbpf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 604abe00785f..e27a249d46fb 100644 --- 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]; |