Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3491921pxf; Mon, 29 Mar 2021 03:53:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2IgV0a+hRK8tNT11oF5xeknzDZh5HDMZpJnPqptCfe3ShMibUG0uQGKEFpn1Nt6mWlG7J X-Received: by 2002:a05:6402:699:: with SMTP id f25mr28098715edy.47.1617015236185; Mon, 29 Mar 2021 03:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617015236; cv=none; d=google.com; s=arc-20160816; b=W1jbl7zaaYQSf277JFBXbLTZ9hefym06ZVwzHLcfjeqGGdrzYkZAmOy+ZWz80HYRds /qBi0LBlrY254io7dqv582o76mwL0tRFqtEkUOM93nh0dzPUWAIivSYBlj1WdDhQTevX Wts4Q/Hditj80OnRvvxnS6Zucd6Ju2MFwF63BZ/rCyJuHbu5l6sJZC3E2SsQHjMoO+fx a5gcJYTKWshNI55Av1KScJzd32vnunENtcenqPlscW1N3rV17mmppv3JmMIYjbnuGbn4 NFuomj0zGquM+bc1vVl9/wtZyVXBpFM9bDGHYFUZOGj+n1SQ/4gmEmln71Gnnce1Yq4d p7NA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IkuVjO16Qh0ifQr8Yahmv88+pLjowqBAHue1dSj5XG0=; b=i23jdsyBD+n/KkkOsI9BBnm50eYoFx3k4bMEdRUduJuE1yExF+9bS2EDyB4piuzxfQ TLiRDqRINrHSTCsipQnQz7AW4q37vVF37y8ENKZe2EROnuMZOpTN12IZ9PSgfI0Eg9mu nI24NEApPnqGOUatuGfdHj6hGXFn32wpsg6woRLsvth0jrNomIN4sea7VPDfZldDbmO9 HsK+RMpspyPwYQWJyvaHs/DmIob4R7TkI1E+86n+Pj30JRytelt5Y1gTkwHRKbB81aG3 5vbQrZHk7uIly2gXmk8zkKPBLZWpE7xdIDTANqLjhkmaNIOLTSoBMrsyHBUYUboJGvlP SRYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mIZf3nUI; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds18si12913358ejc.311.2021.03.29.03.53.33; Mon, 29 Mar 2021 03:53:56 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=mIZf3nUI; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235512AbhC2InG (ORCPT + 99 others); Mon, 29 Mar 2021 04:43:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:41252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233433AbhC2IZK (ORCPT ); Mon, 29 Mar 2021 04:25:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD8B661959; Mon, 29 Mar 2021 08:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006296; bh=sDBqcHPhIHDIZShWpfUiPbvZed99NKuOLc6eLpnFItw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mIZf3nUIGBTYxQWpaslSmMvaGdbq8moRA3+KEOhbkaJK9JdAF+4DHNzjQZ8flB1c7 WwLi5AEVZgMvsJXYpXk8h02rQsrvqrofNid+KWMSbUjBDKOuaO8IqBOy2hj95ASJfO bddIUarkshAlwUgiaAaIbkufqYPh4N5ZCG3aeRF0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Tomlinson , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.10 190/221] netfilter: x_tables: Use correct memory barriers. Date: Mon, 29 Mar 2021 09:58:41 +0200 Message-Id: <20210329075635.466633947@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Tomlinson [ Upstream commit 175e476b8cdf2a4de7432583b49c871345e4f8a1 ] 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 Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- 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(); return addend; } diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index 7df3aef39c5c..6bd31a7a27fc 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1389,7 +1389,7 @@ xt_replace_table(struct xt_table *table, table->private = newinfo; /* make sure all cpus see new ->private value */ - smp_wmb(); + smp_mb(); /* * Even though table entries have now been swapped, other CPU's -- 2.30.1