libbpf: Fix off-by-one bug in bpf_core_apply_relo()
[ Upstream commitde5d0dcef6
] Fix instruction index validity check which has off-by-one error. Fixes:3ee4f53355
("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
af25dbc846
Коммит
b5949ef075
|
@ -5138,7 +5138,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];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче