Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp235448ybi; Fri, 7 Jun 2019 07:15:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmK888mF3hYHq13cVWQoAPqhsIqYv8xlU0VH/d+2UDfAbHZ1AsSS+AUiRg2ZzBAcqPLOb0 X-Received: by 2002:a62:8c81:: with SMTP id m123mr410203pfd.240.1559916922423; Fri, 07 Jun 2019 07:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559916922; cv=none; d=google.com; s=arc-20160816; b=UttQS1f/hU5Zgy40bb5+Y4Nil+HwGEKL8OiHyw81rKYzyvyM61uNfTUPVI5XAuLf/L lJi5T7Ac6Atp0KQvevWJSfDEQxBNjMnitly3e+cz7eEQrTvbBa6GO/S7cm5yAw+pMAjG dnxKNBZ4VQmBTYGHvYPRIMZHvGzBgFaX4cig8bUaB+x5ehHxBh69535SVC2rnkZkvCzH 488trkBrjo3HhDTJxfRO53I9Gcc6tIs1G/8s/eowRr+QUqXuBBRpZjo36XqrNmVHMHtF geiolha75GFq6W7y6hI1++b8JMsylqjQipITrBYxAmskYZyJ8uj4vSRvdqMlwqqUHv3I DQhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=R8rr7vx5tvZzMq2dBl7sBVyIrE2yyObtQYr8QfKWTCc=; b=bvgSg8TtMk4dDPLgx4iLMMqZfxpYeljEUFVaO4WJZwhJM7nXkFbN7z4bWsUiG9p4H7 hDBkZpqZGd1OB+RwjV+bR1d7YADOFNCn9TD5jZ/zqh6vXP4lI4tqXCvyVjK8u65hPLvs EAgbqoE4z2sayVZe4TrzqxoMp6IpGMyQuhvBf4SIEIcBtvV74CzHFCwAE3b257oemdDO EVgnlgiNDRJCBn5BYy5JVVB1U78Vo6R0ehZDQrYTLJGd5wfLjMrmAWuT/hmDwrI9Lxlg vsP5Gz7hBhbH02hLDRG3kbZnhFdDqkJkH1FewKOcTzgOPw1opCZpRp9a++1/lIViqXGg IRMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si1822627pgh.273.2019.06.07.07.15.05; Fri, 07 Jun 2019 07:15:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729379AbfFGOKN (ORCPT + 99 others); Fri, 7 Jun 2019 10:10:13 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:35370 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbfFGOKN (ORCPT ); Fri, 7 Jun 2019 10:10:13 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1hZFZB-0006Q2-3B; Fri, 07 Jun 2019 22:10:01 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1hZFYz-000796-Cp; Fri, 07 Jun 2019 22:09:49 +0800 Date: Fri, 7 Jun 2019 22:09:49 +0800 From: Herbert Xu To: Linus Torvalds Cc: Alan Stern , "Paul E. McKenney" , Boqun Feng , Frederic Weisbecker , Fengguang Wu , LKP , LKML , Netdev , "David S. Miller" , Andrea Parri , Luc Maranget , Jade Alglave Subject: inet: frags: Turn fqdir->dead into an int for old Alphas Message-ID: <20190607140949.tzwyprrhmqdx33iu@gondor.apana.org.au> References: <20190603200301.GM28207@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 04, 2019 at 09:04:55AM -0700, Linus Torvalds wrote: > > In fact, the alpha port was always subtly buggy exactly because of the > "byte write turns into a read-and-masked-write", even if I don't think > anybody ever noticed (we did fix cases where people _did_ notice, > though, and we might still have some cases where we use 'int' for > booleans because of alpha issues.). This is in fact a real bug in the code in question that no amount of READ_ONCE/WRITE_ONCE would have caught. The field fqdir->dead is declared as boolean so writing to it is not atomic (on old Alphas). I don't think it currently matters because padding would ensure that it is in fact 64 bits long. However, should someone add another char/bool/bitfield in this struct in future it could become an issue. So let's fix it. ---8<-- The field fqdir->dead is meant to be written (and read) atomically. As old Alpha CPUs can't write a single byte atomically, we need at least an int for it to work. Signed-off-by: Herbert Xu diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index e91b79ad4e4a..8c458fba74ad 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -14,7 +14,9 @@ struct fqdir { int max_dist; struct inet_frags *f; struct net *net; - bool dead; + + /* We can't use boolean because this needs atomic writes. */ + int dead; struct rhashtable rhashtable ____cacheline_aligned_in_smp; diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 35e9784fab4e..05aa7c145817 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -193,7 +193,7 @@ void fqdir_exit(struct fqdir *fqdir) { fqdir->high_thresh = 0; /* prevent creation of new frags */ - fqdir->dead = true; + fqdir->dead = 1; /* call_rcu is supposed to provide memory barrier semantics, * separating the setting of fqdir->dead with the destruction -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt