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=-3.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_NEOMUTT 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 59E10C43387 for ; Wed, 16 Jan 2019 23:23:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22AEF20652 for ; Wed, 16 Jan 2019 23:23:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YsnS+PiL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727213AbfAPXXJ (ORCPT ); Wed, 16 Jan 2019 18:23:09 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37293 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727039AbfAPXXJ (ORCPT ); Wed, 16 Jan 2019 18:23:09 -0500 Received: by mail-pf1-f194.google.com with SMTP id y126so3815411pfb.4 for ; Wed, 16 Jan 2019 15:23:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=aZO6+c5AGOcr5f1YXMvImyWepuIEXg46lo/qJa3LNtg=; b=YsnS+PiLlOLRCH286NkXOHKONPTyyGmgyWrgCOEMkgmwrvC2caU+Zb81tuCu0nmovG RslyGxxUcWwNYzy/vS+nYfK+XL3NscJ2KuUXCZjT02TmUKkpRgY+EBqKvvbtYHfwk4EK 4s5KUlvJnZIM6jmf0qqItvyETGgLzG6XPsx51B0Y5H0IGsbjFjbRbRYmjs0O6AQveW1y uocrgHKkip1orCaTxKQDIZAgfSH/Xy1E8z51rSIDknBR2uOx74Y8qJsw38/O5JS/HHt/ A9tVDhOCsODw4KMg17nVlz9zkXrKUAnBsCw5GCgqmmakjBAboN7cN+aCfoQWXQsf+fk0 Hwug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=aZO6+c5AGOcr5f1YXMvImyWepuIEXg46lo/qJa3LNtg=; b=ktZ1Z/MYkr5eLaWFDHPYLo6nEcMjadn9WXhP3LgURJ8O6hpk0dlvOKyTbRqgrHbp55 NjNgwEXRXXx7V4tCj3P3Ufd7NioaqsfCWUVOwmdUcEqdvVWNf/jPiGXqNpPysWrnYTAb C3NhY+2CicAagwBwnIDOaFZYURka2NBH4TPOGmnueUTvlfgWjWozgj9qehYVH6qPGzrs sbB9rPjO19tXYGCETGUy143iQzl9QV7FaQf8Qf3FNusgZa4IDHBuvg8SUqYrYfOvbInP V+0zEUl6HGgdqFL8RYnnNH9e5YmMr1u+8f3B2qgYMAdGC7LFjzKnEH0ZarOuTXbJm39u 6KVw== X-Gm-Message-State: AJcUukcl0Ykn0pJmfzc2wRsOyGyr+S5Mnyt+Oif1d5QwK/pBH2lY8vlI 4hg/J1jbwGR0w9eHWFSueHTsazBE X-Google-Smtp-Source: ALg8bN6HrfsrBKs+YyhNamI1ofRPQ2D1OJTFzN5ojX6QXJv9KFwcxiEZhcWnkebv5u51HYjryKZkPg== X-Received: by 2002:a62:3811:: with SMTP id f17mr12657882pfa.206.1547680988752; Wed, 16 Jan 2019 15:23:08 -0800 (PST) Received: from ast-mbp ([2620:10d:c090:200::6:30ae]) by smtp.gmail.com with ESMTPSA id i193sm18932611pgc.22.2019.01.16.15.23.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 15:23:07 -0800 (PST) Date: Wed, 16 Jan 2019 15:23:06 -0800 From: Alexei Starovoitov To: Daniel Borkmann Cc: Alexei Starovoitov , davem@davemloft.net, jakub.kicinski@netronome.com, netdev@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH bpf-next 1/9] bpf: introduce bpf_spin_lock Message-ID: <20190116232304.llq3gpmr2yyrufby@ast-mbp> References: <20190116050830.1881316-1-ast@kernel.org> <20190116050830.1881316-2-ast@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Jan 16, 2019 at 11:48:15PM +0100, Daniel Borkmann wrote: > > I think if I'm not mistaken there should still be a possibility for causing a > deadlock, namely if in the middle of the critical section I'm using an LD_ABS > or LD_IND instruction with oob index such that I cause an implicit return 0 > while lock is held. At least I don't see this being caught, probably also for > such case a test_verifier snippet would be good. good catch. My earlier implementation was reusing check_reference_leak() that is called for both bpf_exit and bpf_ld_abs, but then I realized we cannot call bpf_exit from callee when lock is held and moved that check before prepare_func_exit() forgetting about ldabs. argh. Will fix. > Wouldn't we also need to mark queued spinlock functions as notrace such that > e.g. from kprobe one cannot attach to these causing a deadlock? there is recursion check already, so I'm not sure that is necessary, but will add it since it doesn't hurt and safer indeed.