Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp755128lqb; Wed, 29 May 2024 09:32:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVLQLKvb8SG+7KuxI4xYCqhYzPPKinrS6uU3y66OuTla9WfJ8jJax8vulZbADwe5M5L5aIR5mcXFm6M7jVvSQV7SPdIi6U8NuiUhmeSEg== X-Google-Smtp-Source: AGHT+IHRArbl3BGZZoLDale4gAunD0q3zOkU87m5NOjds2Dnc1yvTPz5Y0bCkt5A4HkZaEnD+AyV X-Received: by 2002:a05:6a00:1d92:b0:6f8:e442:a282 with SMTP id d2e1a72fcca58-6f8f3f9e9acmr16676319b3a.21.1717000361625; Wed, 29 May 2024 09:32:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717000361; cv=pass; d=google.com; s=arc-20160816; b=RUEzPlW/YaNVjluUksBQaNtCUrRFCre+qI+kLKuVnC3KdOqnPZ2LLvPgFePmu1+14g 4qfy28yWizuEY1Gr7gAACyIK4nj3RmCRlBeyxnpheJEWOjfhkX+jobGv+QO4ubqh25Xm OL/uls4a/2O0LwtAPF9x7jH4FGeFfpKS4d+te1lKMutZEkXtD0sE1EmC3xOtx6DJQFrt G23Ua0gCkvznnaLdRguB7DHIVd9QM50P48V7E1ZhenUxJ8dDZFds1+CUWC1lMK++vmzF uO53HQnsAj1LwGKwAtHh5M6svYklFY1KISKlKKnAY4ek+dlg32ZBhMBg2XFNRNZnPBEo 9bMw== 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=1zGFUh5BIokNXo1khBHVCTilWjLuFPEXOImnZTfvdCg=; fh=Ej/6QqEEGY/7y/PC2iPJlxhwmDV3n0Ei5q2YdL2wS1M=; b=CRCZ6kglVdNvut8iT4SHX4AeFQJi14NgyUbos4eOJqFJjqcIYQ0kXEQHOs5VSHlLEr T6fv5NILnbM6TRl9NkHfdp7GhQGVGmgu3HuMMXkHNoYX73Ne11hT+scQjT+mi+dpm+wK e3dS6sQ2kvyrog6oW13ENvJ78NQm3/cHz5WtsIS23dwlNvsNnLp+xPuZI3Oa4K7czPMM V1qH8ndcqfSebi7MOlbomtkc9sRdAcjTCDmgoFOQ6PFh1Rui8rkXO3egfMgC1Pxzn5xB 4gc1i3jHZkm8oFOXTEMaahTB0Oa+lxfy5qJwW5s3QmIn5lSk8mLAyVWsNjrPdm7j84Ek USAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VUA0iBwG; 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-194455-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194455-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-682278903adsi10322068a12.400.2024.05.29.09.32.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 09:32:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194455-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VUA0iBwG; 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-194455-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194455-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E25AF286AB5 for ; Wed, 29 May 2024 16:32:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C4FE1A2C0F; Wed, 29 May 2024 16:29:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VUA0iBwG"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="mlKwRR9Z" 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 D48DE190674; Wed, 29 May 2024 16:29:37 +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=1717000181; cv=none; b=lwg77lK4CPTlbvgnn6u4VL1YNP7w9+is87ebMvgg5GpRtkMrSP95/8StoqF1Ukg3LmWGXqyO7swKyv39m7Qfho26tmADk8hSmn7FF1LsoFaG+I6l3GaOwwKyUjwbmaCyL09iKcCICTxEvBxdJkkJxuHf4niPd87kCXUoGrNGARY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717000181; c=relaxed/simple; bh=3tHIwdbnjoTNL6ML5KnhjhEyimnnTQ36tmq4mQnwqVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lef1MeNs9q/JtrNsqBpP7jVFXSdthZrniCYhijpvUjpzD0sDbhOQT9fY0BjnRLHXc/mf+7NFBPymTVkTBA5oLG9EEri4MJhjsmIES+akz0dDpqLa16T/1YwnphzUTrBYe4i57OzESGHxSspjdG2xhrK3YOEMuuRjXN3CWkMilN8= 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=VUA0iBwG; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=mlKwRR9Z; 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=1717000175; 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=1zGFUh5BIokNXo1khBHVCTilWjLuFPEXOImnZTfvdCg=; b=VUA0iBwGEc81mD73qjwJmXlz8MTU8Y/yPMtDI1dD51yp1PuNqbRK4AeLOvx0M/xs2VAspJ TOrqy0YKTyBrSZdrkFNxC6Dr+G52Zdl9cfH0Dw6XWybKf1S4gnXQLAv7EDjHXrZRvdf4xF CRzouHRVmve2c7Va8sAQEm2pFri7GGpNvlh5qMjhdbEGxsNsbGUb/EQrmuyesUPc/yDns8 bcFITrtRfs+evv9IlR1K1dzhsR29rJF/+0gf9zb1Tfm67cO7jnBXHKK1VRzqnT+m7TQS0p eYjQ5p+Jq9wgmMBatCxfqGcDjbtp5PVO3S2EQgZFcP0eIj6iOwEI/5CtyTssuw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1717000175; 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=1zGFUh5BIokNXo1khBHVCTilWjLuFPEXOImnZTfvdCg=; b=mlKwRR9ZI3EbRRNirrageDDySZ/98P75LZSWJpU43woC6gIsPKql8ddWXQyQFmlgImThft ByzJU1aTXr3dNJBA== 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 v3 net-next 07/15] netfilter: br_netfilter: Use nested-BH locking for brnf_frag_data_storage. Date: Wed, 29 May 2024 18:02:30 +0200 Message-ID: <20240529162927.403425-8-bigeasy@linutronix.de> In-Reply-To: <20240529162927.403425-1-bigeasy@linutronix.de> References: <20240529162927.403425-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 bf30c50b56895..9596ad19224ad 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.45.1