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=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 E4C70C43464 for ; Fri, 18 Sep 2020 02:34:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A617C22208 for ; Fri, 18 Sep 2020 02:34:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600396486; bh=ZcY01G8CNGtt+E8vou5hC/ttOyMXMLrRERQUhf5GrdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BAxqAv33ZrlUHrj+dEiiznuWA6tLZskQ9tGNelzjaenCLdmLyAhJqSAtJPoS2QppT vtoA+qBWBeiu0YTMBLOcwVNp2diF9PdBwz3Ac6rM+u88vg67et2PKU9IsSEBxhErVf Mmt1l6DL2RxXY5MBew3UrH3fD2v+G4YuJUn6A3q4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728937AbgIRCN2 (ORCPT ); Thu, 17 Sep 2020 22:13:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:40700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728508AbgIRCN1 (ORCPT ); Thu, 17 Sep 2020 22:13:27 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 409C0238EE; Fri, 18 Sep 2020 02:13:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395203; bh=ZcY01G8CNGtt+E8vou5hC/ttOyMXMLrRERQUhf5GrdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iaqJ/a1bsHH/KhiSJrGkRtuNLU3CtVW7slTjAIJXb3lTPEV6kBeX22D1bWq3T3i+5 JKNAculN0RwZIMgA/siri+JxMuT1TgZi+bKz3rqdeU2O3to9neEfDQwWI/pbK95ltw 1aXXNBFutnbIGuYLsuIqh0Kst3+2FNdzMIuUoDGM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Gleixner , Alexei Starovoitov , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 053/127] bpf: Remove recursion prevention from rcu free callback Date: Thu, 17 Sep 2020 22:11:06 -0400 Message-Id: <20200918021220.2066485-53-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021220.2066485-1-sashal@kernel.org> References: <20200918021220.2066485-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Thomas Gleixner [ Upstream commit 8a37963c7ac9ecb7f86f8ebda020e3f8d6d7b8a0 ] If an element is freed via RCU then recursion into BPF instrumentation functions is not a concern. The element is already detached from the map and the RCU callback does not hold any locks on which a kprobe, perf event or tracepoint attached BPF program could deadlock. Signed-off-by: Thomas Gleixner Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20200224145643.259118710@linutronix.de Signed-off-by: Sasha Levin --- kernel/bpf/hashtab.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c index 6cc090d015f66..ecc58137525bc 100644 --- a/kernel/bpf/hashtab.c +++ b/kernel/bpf/hashtab.c @@ -645,15 +645,7 @@ static void htab_elem_free_rcu(struct rcu_head *head) struct htab_elem *l = container_of(head, struct htab_elem, rcu); struct bpf_htab *htab = l->htab; - /* must increment bpf_prog_active to avoid kprobe+bpf triggering while - * we're calling kfree, otherwise deadlock is possible if kprobes - * are placed somewhere inside of slub - */ - preempt_disable(); - __this_cpu_inc(bpf_prog_active); htab_elem_free(htab, l); - __this_cpu_dec(bpf_prog_active); - preempt_enable(); } static void htab_put_fd_value(struct bpf_htab *htab, struct htab_elem *l) -- 2.25.1