bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack()
@ 2019-10-10  6:19 Song Liu
  2019-10-10  6:19 ` [PATCH bpf-next 1/2] sched: introduce this_rq_is_locked() Song Liu
  2019-10-10  6:19 ` [PATCH bpf-next 2/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack() Song Liu
  0 siblings, 2 replies; 9+ messages in thread
From: Song Liu @ 2019-10-10  6:19 UTC (permalink / raw)
  To: linux-kernel, bpf, netdev; +Cc: kernel-team, Song Liu

bpf stackmap with build-id lookup (BPF_F_STACK_BUILD_ID) can trigger A-A
deadlock on rq_lock():

rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[...]
Call Trace:
 try_to_wake_up+0x1ad/0x590
 wake_up_q+0x54/0x80
 rwsem_wake+0x8a/0xb0
 bpf_get_stack+0x13c/0x150
 bpf_prog_fbdaf42eded9fe46_on_event+0x5e3/0x1000
 bpf_overflow_handler+0x60/0x100
 __perf_event_overflow+0x4f/0xf0
 perf_swevent_overflow+0x99/0xc0
 ___perf_sw_event+0xe7/0x120
 __schedule+0x47d/0x620
 schedule+0x29/0x90
 futex_wait_queue_me+0xb9/0x110
 futex_wait+0x139/0x230
 do_futex+0x2ac/0xa50
 __x64_sys_futex+0x13c/0x180
 do_syscall_64+0x42/0x100
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

For more details on how to reproduce this is error, please refer to 2/2.

Fix this issue by checking a new helper this_rq_is_locked(). If the
rq_lock is already locked, postpone up_read() in irq_work, just like the
in_nmi() case.

Song Liu (2):
  sched: introduce this_rq_is_locked()
  bpf/stackmap: fix A-A deadlock in bpf_get_stack()

 include/linux/sched.h | 1 +
 kernel/bpf/stackmap.c | 2 +-
 kernel/sched/core.c   | 8 ++++++++
 3 files changed, 10 insertions(+), 1 deletion(-)

--
2.17.1

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

end of thread, other threads:[~2019-10-14 20:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10  6:19 [PATCH bpf-next 0/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack() Song Liu
2019-10-10  6:19 ` [PATCH bpf-next 1/2] sched: introduce this_rq_is_locked() Song Liu
2019-10-10  6:19 ` [PATCH bpf-next 2/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack() Song Liu
2019-10-10  7:36   ` Peter Zijlstra
2019-10-10 17:19     ` Alexei Starovoitov
2019-10-10 17:46       ` Peter Zijlstra
2019-10-10 18:06         ` Alexei Starovoitov
2019-10-14  9:09           ` Peter Zijlstra
2019-10-14 20:12             ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).