Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1575976pxb; Mon, 8 Mar 2021 00:34:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9ojgpLZxcgGP59AcA8piAtiAomcR8wDFhUXQxbK+FK0T+GyFVghNETGZ4BLZHXaQpO1pC X-Received: by 2002:a50:a086:: with SMTP id 6mr20603323edo.70.1615192488178; Mon, 08 Mar 2021 00:34:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615192488; cv=none; d=google.com; s=arc-20160816; b=B1DU9WPkwFc2EG03it+GLneWsQ4I8UyBAThTeHsEkBjqgfzDteb78k63CQKmhSJYlC YWJ50JAf+u7SNLHPDaN8+mV9Cg7lYJi4STb+fMep7XZQ+oqzGVF4/4G9Q1rV9wGcYEn5 EGL6ihjc+KtjAtHhsxsF5NbV5z640Fm4BkXCIWg5MbFNjUZ7bHSC9NkRTQqkuWl4R4WI xKFcawqqOe6v5hCVsKvkQq6O19drGJKk/+g/y8byTyIZKp977OfUzucVWtAf6ORa7LqM rhNuaonmObYH7UXJtTrkyRA3aO00rmzQhZwpiWNHkgVeEGyl4/HL89rY1yASEVn7W447 t4XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vZT52xbfVfFNHbppq3XxQvqLpy688PuIoObPORnqI5g=; b=w/DIzpUGRYycY8FCa1MiQzoUqIQsdYmzTfy2r4dg5V5iAjEpMGo5aEzml0fgkC5qta 4UntbDax3usv5pOUUMDyEv4d/EUWwUJr/q1Z26zvkE4nlhlbXTlgQse/Y8tEQE5nqtAC 0nA4wXkFQQEfmXSl/q7gW9mm2uXO7tK6P8QT3pM4egpanyztwHEuJk2AJF5CrWb55YJP 8i5GKtKWPp50x2AulAKKK25Ea+ckALGzbUfqZCekLPqGJDxR4PKrmCMoccoWwscJRBeq oEKPLHnDxaggLZ1Zk/dNYGOTF47HYuc3F4IKvZe4+IdRk/NHDkuAH7CvR1DKUKjRiu23 5XyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=Xd+qdLDA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s10si6850396ejv.67.2021.03.08.00.34.25; Mon, 08 Mar 2021 00:34:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=Xd+qdLDA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233528AbhCHBZO (ORCPT + 99 others); Sun, 7 Mar 2021 20:25:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233475AbhCHBYj (ORCPT ); Sun, 7 Mar 2021 20:24:39 -0500 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [IPv6:2001:df5:b000:5::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 358FDC061761 for ; Sun, 7 Mar 2021 17:24:39 -0800 (PST) Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id E0864891B0; Mon, 8 Mar 2021 14:24:34 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1615166674; bh=vZT52xbfVfFNHbppq3XxQvqLpy688PuIoObPORnqI5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Xd+qdLDARhZ+PIdweC93dg4dUlAJW8MfbBwqfLEBe1aOJZaMy7hn99L1HbG23ZGiQ 2qgdajDIlrp6P4sOuUOocvJaCuQt/O0g4MuKqNE+lKJTWujrigkJUP2Mb3beg/X8T5 uDby+SI4EXnakWMTPnC4P4b3WmGMijFzUs71lop9W8t8uyIavM76EbsmZm9m5uRzO4 Hh+6s29HGzK7eIBH06tms1M8aV7QIQaqFyP8b57JcjnMuXfvz1DbFRnHiBxOYX3pIU YsVwdBbtKoKlUtGMRBVzPRqER5sGlXCGMs++vcH70703t+s/QFjvoIJ1w+NuzpODlX gyKnkHOdCqYJA== Received: from smtp (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 08 Mar 2021 14:24:34 +1300 Received: from markto-dl.ws.atlnz.lc (markto-dl.ws.atlnz.lc [10.33.23.25]) by smtp (Postfix) with ESMTP id 957F413EFA5; Mon, 8 Mar 2021 14:24:46 +1300 (NZDT) Received: by markto-dl.ws.atlnz.lc (Postfix, from userid 1155) id 9FA84340F85; Mon, 8 Mar 2021 14:24:34 +1300 (NZDT) From: Mark Tomlinson To: pablo@netfilter.org, kadlec@netfilter.org, fw@strlen.de Cc: subashab@codeaurora.org, netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Tomlinson Subject: [PATCH v2 3/3] netfilter: x_tables: Use correct memory barriers. Date: Mon, 8 Mar 2021 14:24:13 +1300 Message-Id: <20210308012413.14383-4-mark.tomlinson@alliedtelesis.co.nz> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308012413.14383-1-mark.tomlinson@alliedtelesis.co.nz> References: <20210308012413.14383-1-mark.tomlinson@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SEG-SpamProfiler-Analysis: v=2.3 cv=C7uXNjH+ c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=dESyimp9J3IA:10 a=Ma0BngSExibuLm0IY5UA:9 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a new table value was assigned, it was followed by a write memory barrier. This ensured that all writes before this point would complete before any writes after this point. However, to determine whether the rules are unused, the sequence counter is read. To ensure that all writes have been done before these reads, a full memory barrier is needed, not just a write memory barrier. The same argument applies when incrementing the counter, before the rules are read. Changing to using smp_mb() instead of smp_wmb() fixes the kernel panic reported in cc00bcaa5899 (which is still present), while still maintaining the same speed of replacing tables. The smb_mb() barriers potentially slow the packet path, however testing has shown no measurable change in performance on a 4-core MIPS64 platform. Fixes: 7f5c6d4f665b ("netfilter: get rid of atomic ops in fast path") Signed-off-by: Mark Tomlinson --- include/linux/netfilter/x_tables.h | 2 +- net/netfilter/x_tables.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter= /x_tables.h index 5deb099d156d..8ec48466410a 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -376,7 +376,7 @@ static inline unsigned int xt_write_recseq_begin(void= ) * since addend is most likely 1 */ __this_cpu_add(xt_recseq.sequence, addend); - smp_wmb(); + smp_mb(); =20 return addend; } diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index af22dbe85e2c..a2b50596b87e 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1387,7 +1387,7 @@ xt_replace_table(struct xt_table *table, table->private =3D newinfo; =20 /* make sure all cpus see new ->private value */ - smp_wmb(); + smp_mb(); =20 /* * Even though table entries have now been swapped, other CPU's --=20 2.30.1