Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp209996ybv; Tue, 18 Feb 2020 21:25:09 -0800 (PST) X-Google-Smtp-Source: APXvYqz52xXAHvhkVuk1vLsccSb9JIxI6Ap4YbI3BIjqOnWbtTYSbtUFUz5FX0RdN0Flt9qYxYx6 X-Received: by 2002:a9d:62ca:: with SMTP id z10mr2052818otk.263.1582089909712; Tue, 18 Feb 2020 21:25:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582089909; cv=none; d=google.com; s=arc-20160816; b=MGc061p45Sl2rX3gj8dsqHoUpaSliCdlPg5tzhx1vezkOfeZ/otVAzgWV2ROEDXVob JP490ws8gPOPcJ0wxHn+kNFJZkQZfyiMjMu9m/dKIESWHh+tdGgtcQJtee97f1Omg2JB Pd7rPVBEqeFbIDg2QiFgbk7GDcn3U2yby+VO6+zmcmm3RYWlEqaUr5bWMIH4i/1qD9Tq jqet0E9mhw+dytWZC9uwrUwPdBKrkiyr6rRLujIouJ/M7XPXsFLmFOAroWEuaJol5I4U 8KWlG2oTQbfzZzov6tS/wW64E2OEQs2UQqQOrPb9a5tivYRTxukN0ETEMzBDp5fzDLwm zbxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=dGJoogZBINB/2NJe5GN3akvIRUbd0si9wNwAncu9b0Q=; b=lXl4ev6x6266OSHJiPtDrr2o0Faku5BJH0zmJ55jOUTNCSbZ0/ji7Q1B2KBSDiiDwl 3wUQY4FSFm9r+Hk+OhFIXH5Qq+pwQbvEVB71oR9XHFjG4uGWFFyhzpYqxEiHkFJ1Yk8i 1sfk3IHJ6ZlXoLd3J/rKI05sCmXN8HMZkgA7pFtC7/dbnuYTvalTBPcJQnuaEzITRVqs SmNDgyRaaE9humQ2fUk5WOtqiLZcxO8b3DMDqP5eNCdeY04V+eRDslPK4pH9y9P65THw HQb745cSZJ16KrAxKGSeupDCD+PGT4m4Q807aopWKHxv1lVKo1imwGFszp1ZgUNsLlDB oDhA== 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 h22si1322399oie.189.2020.02.18.21.24.57; Tue, 18 Feb 2020 21:25:09 -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; 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 S1726484AbgBSFXf (ORCPT + 99 others); Wed, 19 Feb 2020 00:23:35 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:36886 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbgBSFXf (ORCPT ); Wed, 19 Feb 2020 00:23:35 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j4HpZ-00F4vo-LP; Wed, 19 Feb 2020 05:23:29 +0000 Date: Wed, 19 Feb 2020 05:23:29 +0000 From: Al Viro To: Qian Cai Cc: hch@infradead.org, darrick.wong@oracle.com, elver@google.com, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs: fix a data race in i_size_write/i_size_read Message-ID: <20200219052329.GP23230@ZenIV.linux.org.uk> References: <20200219045228.GO23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 19, 2020 at 12:08:40AM -0500, Qian Cai wrote: > > > > On Feb 18, 2020, at 11:52 PM, Al Viro wrote: > > > > If aligned 64bit stores on 64bit host (note the BITS_PER_LONG ifdefs) end up > > being split, the kernel is FUBAR anyway. Details, please - how could that > > end up happening? > > My understanding is the compiler might decide to split the load into saying two 4-byte loads. Then, we might have, > > Load1 > Store > Load2 > > where the load value could be a garbage. Also, Marco (the KCSAN maintainer) who knew more of compiler than me mentioned that there is no guarantee that the store will not be split either. Thus, the WRITE_ONCE(). > I would suggest * if some compiler does that, ask the persons responsible for that "optimization" which flags should be used to disable it. * if they fail to provide such, educate them regarding the usefulness of their idea * if that does not help, don't use the bloody piece of garbage. Again, is that pure theory (because I can't come up with any reason why splitting a 32bit load would be any less legitimate than doing the same to a 64bit one on a 64bit architecture), or is there anything that really would pull that off?