From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31C4DC282C8 for ; Mon, 28 Jan 2019 08:43:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EEEAC20880 for ; Mon, 28 Jan 2019 08:43:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="aEn8/22E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbfA1InU (ORCPT ); Mon, 28 Jan 2019 03:43:20 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:58208 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbfA1InU (ORCPT ); Mon, 28 Jan 2019 03:43:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=F3o6nTm841HdBCLvOATfQPDZijm3PF8Gp/uUhNbRubs=; b=aEn8/22EXTpIkUH0duoCmUxQH EH+w4ZoOm8By7w2MVIeJnqc+G5uesxqtwDTkOmSAb/oEME1cFQkumA2Yw4xBWwr6ufZbbYWx57pRI gpofVdPDRFzHsZhX/kP50ZgKAqV/ObjLHMlGET2u176t8xP1TXdrE6ZitCEUeOgrQtLzLp4qp3x7N rm7WG2TZVqJRIW1JbfzTF+wmY1gi/UxM5NupZeVuSSLVQYcCr+5oKGEQjp7z8EeJAFsq0V0vmAPb7 MeFLeohcQKd7ioKeWy8JjVCJWrBgNIVLmJU5zQh9NK6sZgVY814BtduQpoKfEbaSW31RgyqkhDKok 1hB2hkccQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1go2Vb-0006nE-PO; Mon, 28 Jan 2019 08:43:11 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4AC0720101B8E; Mon, 28 Jan 2019 09:43:10 +0100 (CET) Date: Mon, 28 Jan 2019 09:43:10 +0100 From: Peter Zijlstra To: Alexei Starovoitov Cc: Alexei Starovoitov , davem@davemloft.net, daniel@iogearbox.net, jakub.kicinski@netronome.com, netdev@vger.kernel.org, kernel-team@fb.com, mingo@redhat.com, will.deacon@arm.com, Paul McKenney , jannh@google.com Subject: Re: [PATCH v4 bpf-next 1/9] bpf: introduce bpf_spin_lock Message-ID: <20190128084310.GC28467@hirez.programming.kicks-ass.net> References: <20190124041403.2100609-1-ast@kernel.org> <20190124041403.2100609-2-ast@kernel.org> <20190124180109.GA27771@hirez.programming.kicks-ass.net> <20190124235857.xyb5xx2ufr6x5mbt@ast-mbp.dhcp.thefacebook.com> <20190125091057.GK17749@hirez.programming.kicks-ass.net> <20190125234241.soomtkrgp2i7m7ul@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190125234241.soomtkrgp2i7m7ul@ast-mbp.dhcp.thefacebook.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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() > > > > ... > > BPF_PROG_RUN() > > bpf_spin_lock() // forever more > > > > > > > > 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'.