Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6824686rdb; Fri, 15 Dec 2023 09:12:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8oOVKVp1g2vKw6k/0oUAgeNt0KhPp8bbCZ26bDcKFDfoym4d9q72idFh4t+3l5NV6w7DT X-Received: by 2002:a81:6d02:0:b0:5e4:affb:c8a9 with SMTP id i2-20020a816d02000000b005e4affbc8a9mr724986ywc.47.1702660370485; Fri, 15 Dec 2023 09:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702660370; cv=none; d=google.com; s=arc-20160816; b=N1cRe56k4YHk/9jae3XCUSQDhSgwUF88vTMj2YBdK4XqwD7/qkK04TOauOY23eqc94 OAS7fKbJkf0Wad+i55wlHJmVNT06u8uJcbeTq3ctYHVvVL4A9my8x/be8FZ4nPQyYqpa 4VRhvdm/PaDYQVuDsdt/QamSP9/KHRv8Gb5Uj9KQXkAOy9COdDYq8MLhh+x6IEOApxP2 vYk/pVrFUlNHDgIwVzthDQBoljVXK3VOmmJ8ruVUua1lbhWuFCioF3CUuoIBPh7dY2rC T+LP4nW5JygjtzPWM+mr6N33Ea7u4ff9XQdercpZ6OQhpHOdho7QzTSMldVGOtLwUWJ4 K7Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=vARt+YL97Jryti27DqzXdO+MIl5JkGOA6gpxESYjlfg=; fh=Ej/6QqEEGY/7y/PC2iPJlxhwmDV3n0Ei5q2YdL2wS1M=; b=ux2u6ZPUoRuqmzrrsA7937cui6CR7zR1zMEUdh1ChImVuBYUuPnytOG7iVAhso7SsA VUFciBhLydv+HeGrj3IjweQ8ArFKTSQqddf88dEbZ6/+hmvyMdzmDepBJHcYXJKTTTG/ wwDplEAL6IaUN9NiTm+xHOUQrzcTLJFOyBnNl4tB7ykpCE8WtqEEZQ5Qt9x9dhTrvedT J+zYKws1+V/6WwtXPirwR0ZYefKnKucTCz3LaPDJDEDzDqawn24ZqBSAjwoX+0Q4hNg2 MDjYcJRpdqe5KcNr9o4mk9wzMZs9PSkXUeco52RAV5ZVeWH0WVZFBxeff8EfB4vXEB+o t4YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IVmUifsG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-1368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b17-20020a81bd11000000b005d7a22d1df3si10422663ywi.273.2023.12.15.09.12.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IVmUifsG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-1368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3B3A51C23F04 for ; Fri, 15 Dec 2023 17:12:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B65B547F69; Fri, 15 Dec 2023 17:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="IVmUifsG"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3VHfYBBQ" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69218446AF; Fri, 15 Dec 2023 17:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702660234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vARt+YL97Jryti27DqzXdO+MIl5JkGOA6gpxESYjlfg=; b=IVmUifsGvdEZ8CGV0s9FwkZiqqSybt/c9A41u+Pwr3cbn4oYTXFnP8larPDHyX8kbJc6Vl Gg23hGBj7HwUt1YqRKp3seWlUOrtSBRhDBpb6ydnZqKfgHKPeSgaA5e7W2mHQgFoji379V gkcy1WQDrXWPmIkf6UuG9NtcQUgzkXvs0IRSrQgOR/NXJZ1yTaSGA4ZzDHIR8TShWlspMt R/MdV/QNCSs2T968kCpx9S8uu4Hk07Hga8g7qgf+rAnm3LWDOK7B4aLC+rTELfJ2SoMe9Z 775i1xjsJgIcWEJqQu0Kg1c00ZvUOPTeT+o1usjaPUo/I4EH1M+kUmLD9n3RnQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702660234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vARt+YL97Jryti27DqzXdO+MIl5JkGOA6gpxESYjlfg=; b=3VHfYBBQXPCHKXGBFrTfmgQ3OItM0LGx7LIE5jlsybnHdpT5t8UzWo4GBDlg4/BghTs8l+ owNIlXpgsVXnTGBA== To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Boqun Feng , Daniel Borkmann , Eric Dumazet , Frederic Weisbecker , Ingo Molnar , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Thomas Gleixner , Waiman Long , Will Deacon , Sebastian Andrzej Siewior , Florian Westphal , Jozsef Kadlecsik , Nikolay Aleksandrov , Pablo Neira Ayuso , Roopa Prabhu , bridge@lists.linux.dev, coreteam@netfilter.org, netfilter-devel@vger.kernel.org Subject: [PATCH net-next 07/24] netfilter: br_netfilter: Use nested-BH locking for brnf_frag_data_storage. Date: Fri, 15 Dec 2023 18:07:26 +0100 Message-ID: <20231215171020.687342-8-bigeasy@linutronix.de> In-Reply-To: <20231215171020.687342-1-bigeasy@linutronix.de> References: <20231215171020.687342-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable brnf_frag_data_storage is a per-CPU variable and relies on disabled BH for its locking. Without per-CPU locking in local_bh_disable() on PREEMPT_RT this data structure requires explicit locking. Add a local_lock_t to the data structure and use local_lock_nested_bh() for locking. This change adds only lockdep coverage and does not alter the functional behaviour for !PREEMPT_RT. Cc: Florian Westphal Cc: Jozsef Kadlecsik Cc: Nikolay Aleksandrov Cc: Pablo Neira Ayuso Cc: Roopa Prabhu Cc: bridge@lists.linux.dev Cc: coreteam@netfilter.org Cc: netfilter-devel@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior --- net/bridge/br_netfilter_hooks.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/bridge/br_netfilter_hooks.c b/net/bridge/br_netfilter_hook= s.c index 6adcb45bca75d..c06f498c5f1b3 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -133,6 +133,7 @@ static inline bool is_pppoe_ipv6(const struct sk_buff *= skb, #define NF_BRIDGE_MAX_MAC_HEADER_LENGTH (PPPOE_SES_HLEN + ETH_HLEN) =20 struct brnf_frag_data { + local_lock_t bh_lock; char mac[NF_BRIDGE_MAX_MAC_HEADER_LENGTH]; u8 encap_size; u8 size; @@ -140,7 +141,9 @@ struct brnf_frag_data { __be16 vlan_proto; }; =20 -static DEFINE_PER_CPU(struct brnf_frag_data, brnf_frag_data_storage); +static DEFINE_PER_CPU(struct brnf_frag_data, brnf_frag_data_storage) =3D { + .bh_lock =3D INIT_LOCAL_LOCK(bh_lock), +}; =20 static void nf_bridge_info_free(struct sk_buff *skb) { @@ -768,6 +771,7 @@ static int br_nf_dev_queue_xmit(struct net *net, struct= sock *sk, struct sk_buff =20 IPCB(skb)->frag_max_size =3D nf_bridge->frag_max_size; =20 + guard(local_lock_nested_bh)(&brnf_frag_data_storage.bh_lock); data =3D this_cpu_ptr(&brnf_frag_data_storage); =20 if (skb_vlan_tag_present(skb)) { @@ -795,6 +799,7 @@ static int br_nf_dev_queue_xmit(struct net *net, struct= sock *sk, struct sk_buff =20 IP6CB(skb)->frag_max_size =3D nf_bridge->frag_max_size; =20 + guard(local_lock_nested_bh)(&brnf_frag_data_storage.bh_lock); data =3D this_cpu_ptr(&brnf_frag_data_storage); data->encap_size =3D nf_bridge_encap_header_len(skb); data->size =3D ETH_HLEN + data->encap_size; --=20 2.43.0