Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp6965lqh; Fri, 3 May 2024 11:33:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX71kF5BYZl2m+RxoPGCT1nWfXgkVO96J8U0C8SY9DvmfGmv5HN1nikvAg7r11A9l7hDg8scMng33wzGOxS6n/RHsstsDLq7w6TKUlZKg== X-Google-Smtp-Source: AGHT+IHB0vnU9702DiCNI3SPtkaf0YEylkVQXuidBSp0mI/cEcy+N3zSipv3uEJ2wBe+TPIl1ivd X-Received: by 2002:ad4:5f8c:0:b0:6a0:7a42:128a with SMTP id jp12-20020ad45f8c000000b006a07a42128amr3946249qvb.0.1714761183321; Fri, 03 May 2024 11:33:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714761183; cv=pass; d=google.com; s=arc-20160816; b=piNYgsmXsg3pLW8rxzWmMOGcj8BY74nr2FHvTCjKege6BLjJ403l4NLng0M4Zb+TT7 sUBrpAUaXxUai4xRrQBnWxXsp9lZ9EPV+MadQQ8JpYjTv0kq5dNaTOSvcdzX7vJcppaG V5tC5zUMpiZtVdmrO4s6tJHY35WiLGi/eGSPCXoMYZwaGWFZDBiqwtn5TnHFKyDWJbxc xnbPIbhdARjqJUAXxG/Ka5YLlfWipZw0grz9JQPEyLzjEyiJ5aH824QXFyTeEjFdYXm9 fBw5CkNylTOKB27CQ2m4GBCBWcjjFvVC4DLBFVW9lkcHfkEPqEMlFbYdABFs9QYdZ8vC G3Ug== ARC-Message-Signature: i=2; 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=H7YehgQsfcS62wHoW0lT0hKawzgXS3v0pYsqGden+Fw=; fh=Ej/6QqEEGY/7y/PC2iPJlxhwmDV3n0Ei5q2YdL2wS1M=; b=ixpzn9Gx7kpQIMObuJjpMGdPjbsy8eiMeSs1+tfyLnoDDTd+EM7LT71CbHN/6fuKTY gttmeVkcd7y/aGUymRn0ly4cbNehf9O/iIAaZ0nOvA3DEZMwlLOrTU1rGhOhX3rHd08i eHBdrxRppTK+nkv4tMbGF90RkFokLi7yBzzaIFhZY9YF5m47wkbX6TepW3+2M+uD1aE5 VxPiCdsvmsRrQSsuwmXk/eN4Ye0t+lZSEtjGKcxLPlqj6RHsbL9vLOJyYavtZnnflFGO 2Dy46+X0BlGX+fVVyq8081ftarx8rNPO1yABCgdOzD8FsvCAERK/+8q2UQv7uNnOxxCC 7TXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="3N9uVA/r"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-168064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168064-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. [147.75.199.223]) by mx.google.com with ESMTPS id gf12-20020a056214250c00b006a0cbe9c5bcsi4051279qvb.519.2024.05.03.11.33.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 11:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="3N9uVA/r"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-168064-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168064-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 EE44B1C21487 for ; Fri, 3 May 2024 18:33:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74B1612F5B2; Fri, 3 May 2024 18:30:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3N9uVA/r"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="d+bl86la" 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 78782158D78; Fri, 3 May 2024 18:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714761013; cv=none; b=iaP/Xa1BWk/XHNjKJa1zqhn6GbekcrucVvjnEYhJnHNhrf5e83fdg7L5dIYBAqBvaxtmdoo6sa06qoMzeblsRBF219vPm2pNaPoXN8osxW/aVlRb2c10cUW2O+cQdrJ2tf2AhywoFtrKR/pPctn/Fyn1PlMthck/a1W8h3/qo2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714761013; c=relaxed/simple; bh=sk4AU8OgknjRSmTeIM8d2vACmrBkH/YqK9W4PPXihlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yu1BjmxvLeZJcnWa1CZwXOReanZYiwsQQHa7VrHx/FgYkmKISfU8eKWn+m39lNS/Ud5Hra1PI1PVQH8/Y9caX7IEYaRjJddFs1AmB0cTC3OllYOhuyfh/Y8AXGRdWbeHQzma03W625aXesGovXBZR8H5JHKmZ9GH/nBeKDs0uEw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3N9uVA/r; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=d+bl86la; arc=none smtp.client-ip=193.142.43.55 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=1714761008; 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=H7YehgQsfcS62wHoW0lT0hKawzgXS3v0pYsqGden+Fw=; b=3N9uVA/rSGGKnseYOg5jHK7lOkOnRpchV6uLIiU1Fg2aTTU9QiTO1Ov7OWI7xDZOMg9W63 hOInMkJK8RY8bUFyQACrzgRLeBXvvDUVvBYEoGl7go6XcTyKxBNSnLwEEjwaxd/MAcRszz o6xoG1SmE21FxRLKK2K983zSNGuP6Nj/YKrGVesu5hP8rPl2T8upS5JZYKVyGLQ0Oy++o/ iaJmFrHYQAqXz7LIjrpkutVOSlqyrCH7mg/cdFHZmuB4gOq6JiIirHkCwSCXUcNyJAxqdw VYhSP5JSZBYXzSJfI8IB5zb9JeocJnIUHQ/yWuNPC4vN4plH6jAdmQrTgWNW4Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714761008; 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=H7YehgQsfcS62wHoW0lT0hKawzgXS3v0pYsqGden+Fw=; b=d+bl86laZw1AIF8zVC0bWXExGb/Id1llWZZysFEGJZ4g6pXGAn9IwUByl+TPwKOWD3+Mrr 4vibp7BD7BGdxbCg== 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/15] netfilter: br_netfilter: Use nested-BH locking for brnf_frag_data_storage. Date: Fri, 3 May 2024 20:25:11 +0200 Message-ID: <20240503182957.1042122-8-bigeasy@linutronix.de> In-Reply-To: <20240503182957.1042122-1-bigeasy@linutronix.de> References: <20240503182957.1042122-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 7948a9e7542c4..baacd80716046 100644 --- a/net/bridge/br_netfilter_hooks.c +++ b/net/bridge/br_netfilter_hooks.c @@ -137,6 +137,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; @@ -144,7 +145,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) { @@ -882,6 +885,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)) { @@ -909,6 +913,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