Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2278090pxb; Tue, 23 Feb 2021 03:10:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcSNWtyHjyPeVTDCjNNqwwl4A9Gj8+7PsP1tvuwsazI8m7B3nbbtqcTM39e+UEWo0F8jVU X-Received: by 2002:aa7:c95a:: with SMTP id h26mr27477474edt.166.1614078616190; Tue, 23 Feb 2021 03:10:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614078616; cv=none; d=google.com; s=arc-20160816; b=XiweuRBMXzK06NVdoql3froecPgUIF8xYmS7SkCYWfrRNIKdkqhFVD1C3f1mGgUNJt cGUYBmRdnX9K531DcdpY1f5tdwprV+XA3go4RwC+yW9dH4fNKBKDOthE0wFUgigNKyp+ Q+kiKG+g64kG1YrwKzO8SWaZ/FjzWao9m57dnYJJ3X23kRu0RU3ZBkmYNv0K8LlyvevD iukAGPn54rcGWmzivVwEtIvrJ0RjZ2caIaL/n9PHmuL54f7XgXf9X9YBEJmqnrPnhb6G YjbAlEYv3WKL9sN9LZfCOnGT1hFZDwakH6FnsyBgJiJZrXY0JaqcpPgbPBIfVxajySHE lDrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K2ylQVZRhghwU1ruzT40Z4+JszR4ATXnAjr+EMA5yu4=; b=Y9fWuXvEHpAjENigQ08ZRA5ZbmKq3qlxjGXlDjnPMhfvDl/bCeE4JSTyP2VhcmkZZ5 PeWIXndW5fkf5c5j7ICXDxZJ6rd91KiRlR4MASMxqrVlQTzD9n71OGcIfWnvgF75cu79 JRrOl+lyEl3IIwsFPI+ARUfnUz7NOjqGIs2+MyOtmdNlafzoqc0H0vmZupO4MHElisix bCw2rTcu70NO1o2CLFclvPobT2xXci8/S+x5gn+VA4eoj98IxgpeaD2C8xNb8rnG6NLC iBRtnf3es46VOk5w5oiSom4e8YLVELXlc7TLcjsYbS/CvVLgxnpXdxP7gLNEAES/3NFM DLQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NBP9tV4J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si1914119edc.296.2021.02.23.03.09.48; Tue, 23 Feb 2021 03:10:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NBP9tV4J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbhBWLHf (ORCPT + 99 others); Tue, 23 Feb 2021 06:07:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232217AbhBWLH0 (ORCPT ); Tue, 23 Feb 2021 06:07:26 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1819C061786; Tue, 23 Feb 2021 03:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=K2ylQVZRhghwU1ruzT40Z4+JszR4ATXnAjr+EMA5yu4=; b=NBP9tV4JPO5/VnfruO4LFjeYaJ 3GZA7ssSASYSXNeuC1blqtsH9J0+PR5QVfvEtsfuMt3bcKFwa6TM/ZdJeff7fa1TqlCeJ240L3Vv6 PPadV4Ub0Nl4PbeEZ9nt2Pkqx35oZm+7UGB3xzHj2naf991/OeM9JjNDGjvPaK0f4sMVmP9dAYqui pURY68O3Lr7IQZSASDNT2rK5GgHSiOEB+dpSSqEI0jP8xQyPRmwAKD2EdIOQHU1zUtu0KkkqVw1Br 3ZljwcflvZ+eRCnSiVP5ZiXt13PU6gLS5qUDGQ6FmssCSKh9F45Os3+FrXg5i0iC4HVZXZq0ZqI1R PVdJKD9A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lEVWJ-007rop-4d; Tue, 23 Feb 2021 11:06:30 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A7112300DB4; Tue, 23 Feb 2021 12:06:22 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8759F2013B7C2; Tue, 23 Feb 2021 12:06:22 +0100 (CET) Date: Tue, 23 Feb 2021 12:06:22 +0100 From: Peter Zijlstra To: Song Liu Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, kernel-team@fb.com Subject: Re: [PATCH v4 bpf-next 2/6] bpf: prevent deadlock from recursive bpf_task_storage_[get|delete] Message-ID: References: <20210223012014.2087583-1-songliubraving@fb.com> <20210223012014.2087583-3-songliubraving@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210223012014.2087583-3-songliubraving@fb.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 22, 2021 at 05:20:10PM -0800, Song Liu wrote: > BPF helpers bpf_task_storage_[get|delete] could hold two locks: > bpf_local_storage_map_bucket->lock and bpf_local_storage->lock. Calling > these helpers from fentry/fexit programs on functions in bpf_*_storage.c > may cause deadlock on either locks. > > Prevent such deadlock with a per cpu counter, bpf_task_storage_busy, which > is similar to bpf_prog_active. We need this counter to be global, because So bpf_prog_active is one of the biggest turds around, and now you're making it worse ?!