Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp196735lqb; Tue, 4 Jun 2024 08:47:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXObImxoaG0QIQMVOoQXhy5jbvu/GCfXRzyJ9tBrpAt+PiHodEbTLwaAlfGp/p9lP19dLY8EyPWWdgwt1OPEiwmvJCdGW6OQwKJRMjmHw== X-Google-Smtp-Source: AGHT+IHKw4TFskQTWlGnNwfSRUWSQc9TAKzCfn7642WRghiklvdBTNbdTckdN7qg7+Jz7QxTmIiI X-Received: by 2002:a05:6e02:1c22:b0:36b:3af2:2349 with SMTP id e9e14a558f8ab-3748b98f465mr138071045ab.15.1717516064400; Tue, 04 Jun 2024 08:47:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717516064; cv=pass; d=google.com; s=arc-20160816; b=tbCyvbSUfsx0QHPKdWYK8xcty3kXYYvRMAUPnWmrwPtcsq8b3Pj+MuW5aHNiY2QXt8 J+teNjx876IDZHNnuDPNIgQEijZ6VbyYdcoFIJ5P7zHvTRDMrD7TpKdjjUaLGSsVa3eK XWbxAe4BSHo4aTJbUAoZOkyCvkHRdXJ7tWurp2A6iG7b+5N2bG7Cb1ADQyLefjYhiqro x5kb8P6nDwWK5sXwMGglnWe/MCIEG7pu10WI9yC7Yrr70qsMkj9dNvQ9nVpqcIi87jTm q4kJj/+afNUfWJHq6DqXMmD2qb0L1yA1xnZgEWmn/7yum51kvx5w7ohJPI/deYDJkdFT Tryw== 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=jp8QVNcBwp91otoAEykvR7pBaCzyHhrLX6ezy3SsbVI=; b=C3O3W+pDw1d+f519Wuu7mI6S72FPzhTQZ0ChUdCUbunfmS5r0/E8065Rnl2SHOliJj QAOCVW5BUWGFA4bT0/6ZgPrOjE+Ii2lN7bEA/TgGUO/NRTIo9BlXmZsz9fmuDLUdwLBZ W716xchPszgNWJDolcGreU5SCrfY/ixcyFn1UutuoiGFnpG3wCOYzrC5N79pQrrxxfP3 kf0VLS0ELJVyP+wRSq29582AxgrQSi81qlWhy/ja7IS745GjfCRz2kPWDbWzMwy48io9 YP2vLNwJfmyVinkTro9EiC5lPOkwiXCBnaRbIkVQ58quOT4fXFa0DbahofINNOXNSCxP SrIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZpWmVHEr; 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-200991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200991-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. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35c17cfeesi8377038a12.638.2024.06.04.08.47.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 08:47:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZpWmVHEr; 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-200991-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200991-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 F37D2281737 for ; Tue, 4 Jun 2024 15:47:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DC8614A61E; Tue, 4 Jun 2024 15:44:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZpWmVHEr"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7LV7zmsm" 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 236471487DD; Tue, 4 Jun 2024 15:44:51 +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=1717515894; cv=none; b=XYSof/ZcWX4h4WEY1m1x3Kmgic5M26Y9BgSSG887j9NG/nrlnOkP+MYzVf85IdOO7ypnHZxPS535N+sfcrGKcemE+QN5Q8orpRl5wz6hBEi1gTiKB0DrlRLshpONdUCEdhxoxoENWQwZYijiJb04iGZDAwYnSiWcfTlnubPY7yI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717515894; c=relaxed/simple; bh=3tHIwdbnjoTNL6ML5KnhjhEyimnnTQ36tmq4mQnwqVw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nujNKUWrSZ5M3B0baDZZqw93uEEbYQUEsWgW+5q9R2aLf2b0bmwjV8tHqQSWiHPByWEZBZmafazMOMEaJuk3LA2oz/Iee2YaQLFs8x7Lnf3DIieHeI5oXqEDvagLrkV2pnr3Y82e1WWZ3Qd/Nx2EdnIWerSeq7q3YnmQQOtC718= 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=ZpWmVHEr; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7LV7zmsm; 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=1717515889; 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=ZpWmVHErbJYFgaXZ51awhGMxW8APDMPsVj677mOUaCG53w6WpXDDtD782NFgN/9poB5o/9 v8wyjjXhdoUVLXFpxZRCpGumG0gUmiJXArOSk0WR4dZPJ8FSPZpnPn+etwGCxEbBR0M2hZ jHdycZZdQIcwsDEpihBvWw+0YGieWALV0mpMi75xtJg04BclQhlq1lJeCr/MrForbC0ysz BUfaF2EvwiGSXmSFVmKuGtZ3W3TK5Tp3CdwdL4XPFYV+Ixa/v235KMB+bPjxBkBx8f9LBF KLso4ewxszNNc2GVpObSgXHryCla2dPlAiUtTYHnXje1C4tl/zTzKY4aAQpNyA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1717515889; 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=7LV7zmsmr6KTon9MNuUio70Erb1OBJPxeXiLPV4HpBhHg+kUbmieawZ6/D437xV4pBbr4t maPCCVw7KfTbEnBQ== To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: "David S. Miller" , Daniel Bristot de Oliveira , 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 v4 net-next 06/14] netfilter: br_netfilter: Use nested-BH locking for brnf_frag_data_storage. Date: Tue, 4 Jun 2024 17:24:13 +0200 Message-ID: <20240604154425.878636-7-bigeasy@linutronix.de> In-Reply-To: <20240604154425.878636-1-bigeasy@linutronix.de> References: <20240604154425.878636-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