]> git.baikalelectronics.ru Git - kernel.git/commit
bpf/test_run: fix unkillable BPF_PROG_TEST_RUN
authorStanislav Fomichev <sdf@google.com>
Tue, 12 Feb 2019 23:42:38 +0000 (15:42 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 18 Feb 2019 23:17:03 +0000 (00:17 +0100)
commita35d8218d61180e69ecbb5c8129aa87d79e60148
tree21336c0eca9c46abc9ad23bbd9813663dd120522
parent40c68ccfc9dc6945b757ec7379a577a9427897ae
bpf/test_run: fix unkillable BPF_PROG_TEST_RUN

Syzbot found out that running BPF_PROG_TEST_RUN with repeat=0xffffffff
makes process unkillable. The problem is that when CONFIG_PREEMPT is
enabled, we never see need_resched() return true. This is due to the
fact that preempt_enable() (which we do in bpf_test_run_one on each
iteration) now handles resched if it's needed.

Let's disable preemption for the whole run, not per test. In this case
we can properly see whether resched is needed.
Let's also properly return -EINTR to the userspace in case of a signal
interrupt.

See recent discussion:
http://lore.kernel.org/netdev/CAH3MdRWHr4N8jei8jxDppXjmw-Nw=puNDLbu1dQOFQHxfU2onA@mail.gmail.com

I'll follow up with the same fix bpf_prog_test_run_flow_dissector in
bpf-next.

Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/bpf/test_run.c