Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1063538ybl; Thu, 12 Dec 2019 09:06:00 -0800 (PST) X-Google-Smtp-Source: APXvYqxO1wQQlVpXXHzMZRHZkDskF+DKkI6DYGofpyF8OLAGwog43b+NuWd1OK8ETdOSF/012SoU X-Received: by 2002:aca:554d:: with SMTP id j74mr5893983oib.92.1576170360480; Thu, 12 Dec 2019 09:06:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576170360; cv=none; d=google.com; s=arc-20160816; b=Cumw8pc0+Mmjv/Yys/Iry1/iCRBPIi+8jymAnIX1TU5+WLkCWSFugKKSOvaJn2E+KS ji/V8Y01Di+QdDiGFRDZeVzh99JlQG8ByBdN4pkl/Cr9ro3xLPz9sXgKh68W/YlDJYyw IhcvqeYxrOm/FOg0LD0nkeZjjO6Kyr/WXOgGQoMJCDEKFZQ1OSCIYcI1A7AlzenJJGA/ r588nj7QI32GxbzZuzInkSSIwPnyfEzTIx0qyT2tQv2bn41XSEpI1juDbDuv+atWAsAC H1jeZfcOMEjnGdQxdH+GuZuckCg+FUuaSd6b67pNynB0SPQHuPFLosyPc5LpF5rIT13f 80uQ== 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:dkim-signature; bh=g990hDleBSuXCO+5ll9aeBw6YEv47j+fX+qDHbbR5z0=; b=Z379CQa46H0sY5LQHP8RFdnfkIX60NulOl+4KDr/UGV2oNW6jacsO/ur49tJdPT1FB BaJAtZtJN/yRMlFR5Tuqs3Qd+5Y2WtY5wcemdN/h5E0uUEqVnw8L6FZ9+9LlUQKo5FMg tQTxj8Vjgx9MeKoo5NeeWjCljvcHMiVhAnIIUBSVKR5Cf3yVwFfeV2ljkC+sxeAW6Qs1 /rbvT6cHMg20Nqs2JvOaPhc6vR8NXuCVfgoUPo9gYeIlM1QDk3z+ydOlxt3waszn5YWE EygZa79ZGkqT6Sa9htEyVJTzUrZhiPe7Qh2cvbV/Od97PVb8LkVycXRc3L0yJFON2fnv QLMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKrPjstB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si3270618oic.245.2019.12.12.09.05.42; Thu, 12 Dec 2019 09:06:00 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=xKrPjstB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730054AbfLLREf (ORCPT + 99 others); Thu, 12 Dec 2019 12:04:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:50248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729927AbfLLREf (ORCPT ); Thu, 12 Dec 2019 12:04:35 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1A4EB214AF; Thu, 12 Dec 2019 17:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576170274; bh=cStQM6dJAgiI/M8e5otdqNPehlU5HK8fnoGish0RYPA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xKrPjstBHwTbT220UQOtLkKeCMvT6WPqTLCez8mR+Lq7UVly0+SrA5HonfG1lMuyO Uy6bO0rwELdpe2xXOhR9JbKXRiq4xqT6Xsi+e/OTI+9prkABIh2bIOaZcKkaGFGW5p YqTrrN1JrVJnnP8s94OpHruGOkFIRCOQrvvW7fz8= Date: Thu, 12 Dec 2019 17:04:28 +0000 From: Will Deacon To: Peter Zijlstra Cc: Michael Ellerman , Linus Torvalds , dja@axtens.net, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, christophe.leroy@c-s.fr, linux-arch@vger.kernel.org, Mark Rutland , Segher Boessenkool , Arnd Bergmann , Christian Borntraeger Subject: Re: READ_ONCE() + STACKPROTECTOR_STRONG == :/ (was Re: [GIT PULL] Please pull powerpc/linux.git powerpc-5.5-2 tag (topic/kasan-bitops)) Message-ID: <20191212170427.GA16364@willie-the-truck> References: <87blslei5o.fsf@mpe.ellerman.id.au> <20191206131650.GM2827@hirez.programming.kicks-ass.net> <875zimp0ay.fsf@mpe.ellerman.id.au> <20191212080105.GV2844@hirez.programming.kicks-ass.net> <20191212100756.GA11317@willie-the-truck> <20191212104610.GW2827@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191212104610.GW2827@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 12, 2019 at 11:46:10AM +0100, Peter Zijlstra wrote: > On Thu, Dec 12, 2019 at 10:07:56AM +0000, Will Deacon wrote: > > > > So your proposed change _should_ be fine. Will, I'm assuming you never > > > saw this on your ARGH64 builds when you did this code ? > > > > I did see it, but (a) looking at the code out-of-line makes it look a lot > > worse than it actually is (so the ext4 example is really helpful -- thanks > > Michael!) and (b) I chalked it up to a crappy compiler. > > > > However, see this comment from Arnd on my READ_ONCE series from the other > > day: > > > > https://lore.kernel.org/lkml/CAK8P3a0f=WvSQSBQ4t0FmEkcFE_mC3oARxaeTviTSkSa-D2qhg@mail.gmail.com > > > > In which case, I'm thinking that we should be doing better in READ_ONCE() > > for non-buggy compilers which would also keep the KCSAN folks happy for this > > code (and would help with [1] too). > > So something like this then? Although I suppose that should be moved > into compiler-gcc.h and then guarded by #ifndef READ_ONCE or so. Ah wait, I think we've been looking at this wrong. The volatile pointer argument is actually the problem here, not READ_ONCE()! The use of typeof() means that the temporary variable to which __READ_ONCE_SIZE writes ends up being a volatile store, so it can't be optimised away. This is why we get a stack access and why stack protector then wrecks the codegen for us. I'll cook a patch getting rid of those volatiles. Will