]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Remove bpf_lsm_file_mprotect from sleepable list.
authorAlexei Starovoitov <ast@kernel.org>
Mon, 31 Aug 2020 20:16:51 +0000 (13:16 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 31 Aug 2020 21:03:57 +0000 (23:03 +0200)
commitd1c39a1ae794c1ada824d571249c846df81e2b6d
tree4bee8de2bdfd2f3caa3c4499c54b9196129c6525
parent226b8994ef9c9c5dc00289f28a86bcef3f5828d0
bpf: Remove bpf_lsm_file_mprotect from sleepable list.

Technically the bpf programs can sleep while attached to bpf_lsm_file_mprotect,
but such programs need to access user memory. So they're in might_fault()
category. Which means they cannot be called from file_mprotect lsm hook that
takes write lock on mm->mmap_lock.
Adjust the test accordingly.

Also add might_fault() to __bpf_prog_enter_sleepable() to catch such deadlocks early.

Fixes: 4f9aef2a7f98 ("bpf: Introduce sleepable BPF programs")
Fixes: 4021d934d935 ("selftests/bpf: Add sleepable tests")
Reported-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200831201651.82447-1-alexei.starovoitov@gmail.com
kernel/bpf/trampoline.c
kernel/bpf/verifier.c
tools/testing/selftests/bpf/progs/lsm.c