BPF List
 help / color / mirror / Atom feed
* [PATCH RFC bpf-next v1 0/2] Fix deadlock with bpf_timer in fentry/fexit progs
@ 2022-11-06  1:51 Kumar Kartikeya Dwivedi
  2022-11-06  1:51 ` [PATCH RFC bpf-next v1 1/2] bpf: Fix deadlock for bpf_timer's spinlock Kumar Kartikeya Dwivedi
  2022-11-06  1:51 ` [PATCH RFC bpf-next v1 2/2] [EXAMPLE] selftests/bpf: Add timer deadlock example Kumar Kartikeya Dwivedi
  0 siblings, 2 replies; 10+ messages in thread
From: Kumar Kartikeya Dwivedi @ 2022-11-06  1:51 UTC (permalink / raw)
  To: bpf; +Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Martin KaFai Lau

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-07 23:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-06  1:51 [PATCH RFC bpf-next v1 0/2] Fix deadlock with bpf_timer in fentry/fexit progs Kumar Kartikeya Dwivedi
2022-11-06  1:51 ` [PATCH RFC bpf-next v1 1/2] bpf: Fix deadlock for bpf_timer's spinlock Kumar Kartikeya Dwivedi
2022-11-06 21:20   ` Alexei Starovoitov
2022-11-06 21:44     ` Kumar Kartikeya Dwivedi
2022-11-07  0:31       ` Alexei Starovoitov
2022-11-07  1:48         ` Kumar Kartikeya Dwivedi
2022-11-07  2:34           ` Alexei Starovoitov
2022-11-07  3:45             ` Alexei Starovoitov
2022-11-07 23:13               ` Kumar Kartikeya Dwivedi
2022-11-06  1:51 ` [PATCH RFC bpf-next v1 2/2] [EXAMPLE] selftests/bpf: Add timer deadlock example Kumar Kartikeya Dwivedi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox