Skip to content

RFC Fix deadlock with bpf_timer in fentry/fexit progs

Kumar Kartikeya Dwivedi bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Fix deadlock for bpf_timer's spinlockkernel/bpf/verifier.c tools/testing/selftests/bpf/prog_tests/timer.c tools/testing/selftests/bpf/prog_tests/timer_crash.c +2 more+34 -187 replies
2/2selftests/bpf: Add timer deadlock exampletools/testing/selftests/bpf/prog_tests/timer_deadlock.c tools/testing/selftests/bpf/progs/timer_deadlock.c+79 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC bpf-next v1 0/2] Fix deadlock with bpf_timer in fentry/fexit progs

Hi, this is a fix for a deadlock condition I noticed (and verified by constructing a test case, see patch #2) while looking at the code. There might be alternative ways to solve this, like having percpu map ops recursion counter, and detecting reentrancy based on that. I went for the simpler option for now.

Previous discussions on a patch doing something similar for a different issue here, but never added BPF_PROG_TYPE_TRACING to this list:

https://lore.kernel.org/bpf/CALOAHbBK1=ujbZp5n4t9zQf+DPZ3-a2ZDL0a3sfhVU6meJGqYw@mail.gmail.com
https://lore.kernel.org/bpf/CALOAHbAQ7AKNPrkawGKHarkB5CGkWXTC8P=+EJP3DAPNEf=Ayw@mail.gmail.com

Note that timer and timer_crash selftests are broken by this change, so it has potential for wider breakage.

Kumar Kartikeya Dwivedi (2):
bpf: Fix deadlock for bpf_timer's spinlock [EXAMPLE] selftests/bpf: Add timer deadlock example

 kernel/bpf/verifier.c                         | 10 ++--
 .../testing/selftests/bpf/prog_tests/timer.c  | 21 +++++---
 .../selftests/bpf/prog_tests/timer_crash.c    |  9 +++-
 .../selftests/bpf/prog_tests/timer_deadlock.c | 29 +++++++++++
 tools/testing/selftests/bpf/progs/timer.c     |  8 +--
 .../testing/selftests/bpf/progs/timer_crash.c |  4 +-
 .../selftests/bpf/progs/timer_deadlock.c      | 50 +++++++++++++++++++
 7 files changed, 113 insertions(+), 18 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/timer_deadlock.c
 create mode 100644 tools/testing/selftests/bpf/progs/timer_deadlock.c

base-commit: 25906092edb4bcf94cb669bd1ed03a0ef2f4120c --
2.38.1