diff options
author | Martin KaFai Lau <kafai@fb.com> | 2018-12-19 13:01:01 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-12-19 15:42:55 -0800 |
commit | fdbaa0beb78b7c8847e261fe2c32816e9d1c54cc (patch) | |
tree | b99ead4b2f848949b21d9b5a0cb552b4ac6a9972 /kernel | |
parent | 9e88b9312acb9b80554c48b58668fb144720333a (diff) | |
download | linux-fdbaa0beb78b7c8847e261fe2c32816e9d1c54cc.tar.bz2 |
bpf: Ensure line_info.insn_off cannot point to insn with zero code
This patch rejects a line_info if the bpf insn code referred by
line_info.insn_off is 0. F.e. a broken userspace tool might generate
a line_info.insn_off that points to the second 8 bytes of a BPF_LD_IMM64.
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/verifier.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index e0e77ffeefb8..5c64281d566e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -4980,6 +4980,14 @@ static int check_btf_line(struct bpf_verifier_env *env, goto err_free; } + if (!prog->insnsi[linfo[i].insn_off].code) { + verbose(env, + "Invalid insn code at line_info[%u].insn_off\n", + i); + err = -EINVAL; + goto err_free; + } + if (!btf_name_by_offset(btf, linfo[i].line_off) || !btf_name_by_offset(btf, linfo[i].file_name_off)) { verbose(env, "Invalid line_info[%u].line_off or .file_name_off\n", i); |