On Fri, Jan 25, 2019 at 03:42:43PM -0800, Alexei Starovoitov wrote: > On Fri, Jan 25, 2019 at 10:10:57AM +0100, Peter Zijlstra wrote:
> > What about the progs that run from SoftIRQ ? Since that bpf_prog_active > > thing isn't inside BPF_PROG_RUN() what is to stop say: > > > > reuseport_select_sock() > > ... > > BPF_PROG_RUN() > > bpf_spin_lock() > > <IRQ> > > ... > > BPF_PROG_RUN() > > bpf_spin_lock() // forever more > > > > </IRQ> > > > > Unless you stick that bpf_prog_active stuff inside BPF_PROG_RUN itself, > > I don't see how you can fundamentally avoid this happening (now or in > > the future). > But your issue above is valid. > We don't use bpf_prog_active for networking progs, since we allow > for one level of nesting due to the classic SKF_AD_PAY_OFFSET legacy. > Also we allow tracing progs to nest with networking progs. > People using this actively. > Typically it's not an issue, since in networking there is no > arbitrary nesting (unlike kprobe/nmi in tracing), > but for bpf_spin_lock it can be, since the same map can be shared > by networking and tracing progs and above deadlock would be possible: > (first BPF_PROG_RUN will be from networking prog, then kprobe+bpf's > BPF_PROG_RUN accessing the same map with bpf_spin_lock) > > So for now I'm going to allow bpf_spin_lock in networking progs only, > since there is no arbitrary nesting there. Isn't that still broken? AFAIU networking progs can happen in task context (TX) and SoftIRQ context (RX), which can nest. > And once we figure out the safety concerns for kprobe/tracepoint progs > we can enable bpf_spin_lock there too. > NMI bpf progs will never have bpf_spin_lock. kprobe is like NMI, since it pokes an INT3 instruction which can trigger in the middle of IRQ-disabled or even in NMIs. Similar arguments can be made for tracepoints, they can happen 'anywhere'.