bpf: fix off-by-one error in adjust_subprog_starts
authorEdward Cree <ecree@solarflare.com>
Fri, 16 Nov 2018 12:00:07 +0000 (12:00 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Dec 2018 08:24:42 +0000 (09:24 +0100)
commitbddeb44981c1f5dd699ff45cce6ce31e59c0300c
treec681bbdef17036d15f2fd454ac43710d139232c9
parent1fd99ac175e63102876c6ae135c06c72575c5d24
bpf: fix off-by-one error in adjust_subprog_starts

commit afd594240806acc138cf696c09f2f4829d55d02f upstream.

When patching in a new sequence for the first insn of a subprog, the start
 of that subprog does not change (it's the first insn of the sequence), so
 adjust_subprog_starts should check start <= off (rather than < off).
Also added a test to test_verifier.c (it's essentially the syz reproducer).

Fixes: cc8b0b92a169 ("bpf: introduce function calls (function boundaries)")
Reported-by: syzbot+4fc427c7af994b0948be@syzkaller.appspotmail.com
Signed-off-by: Edward Cree <ecree@solarflare.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/verifier.c
tools/testing/selftests/bpf/test_verifier.c