Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1319242ybh; Thu, 16 Jul 2020 08:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1deRl2cLNB3NBgrVIgfuH+OgwRff1FSgPDWUy30lxxJXjTvvgbYp7mJm/6K0zw/HrgRZ/ X-Received: by 2002:a50:d6dd:: with SMTP id l29mr5106720edj.345.1594915027133; Thu, 16 Jul 2020 08:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594915027; cv=none; d=google.com; s=arc-20160816; b=y7OSuRby0Auy94S5r5DWJEHerPvs8ds2vql8cXLo4c2N+FOmUMNNyrvhznCgR8dV3B MIEU40bEot7l14CYPlCu7MA/a6Jy+Kc27ZHGKqCPNeajpJULjLAWjt2WPkQyUQ8UGBhJ n7izE80qfXsNG7PM0OaUGqUdtZ7/5plBvTH/nXZugeRdossP3cgwiXwCQ8dj3ssE6VNi Fv10CEfdsmBHPvpIxHAxeotvbRPGpyV3GS0sryEqviLaHGIgHA+R1J40d3C8b4Q9KtPp u5TR36Pef1YC8iW5pSPPQktQct96JYOkLLHEwsy4fnnJEmjfd8mT9rrHOXnHsH5BQSVi ReXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=8WXG2PIfyvvmPCMZWK/gVmBE6W6BlBqBnmsVmBGJnAE=; b=T4mFfawJvcaMCVpBV7J7GNromM+1No79eZuq3FNfPbJxJYRJ4OGaSAUVl6ATdPLvs+ zaPU7WjIIfPsEFrKaQkC1ZnB9lazM+f4lm4mTiexn3fzfuGbOYGWi/dAv9cmZKZX9ahw dChJCAf2rVDnnqvdwQs5W07Ddrg5KQQfXva8LUZ2S3AcWkkJRkBbVg431scmIoAS2he4 Ow8Xz8nFNelg93Eb9Bn7IZ2doRtxddCEyEYQqIbtyMiQr0N/LLY62KC+Jm+St8fuADHH naZ3XRni8N8IzKwT3UyM2bieDSRm/D5RL2q+d9oiGAJMxtkU8dBFSpqQOrwun6RvLZu9 Z/cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=TTVQzQQ8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr3si1211285ejb.525.2020.07.16.08.56.25; Thu, 16 Jul 2020 08:57:07 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=TTVQzQQ8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728967AbgGPPxn (ORCPT + 99 others); Thu, 16 Jul 2020 11:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728894AbgGPPxm (ORCPT ); Thu, 16 Jul 2020 11:53:42 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57D92C061755 for ; Thu, 16 Jul 2020 08:53:42 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id a21so7067782ejj.10 for ; Thu, 16 Jul 2020 08:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8WXG2PIfyvvmPCMZWK/gVmBE6W6BlBqBnmsVmBGJnAE=; b=TTVQzQQ8ViT26pmUNnI4AiNVW2VzNBVbcYWM3Gl8mx7rT/pIssKnqsignxE0w8FuXi 3eYXIYONhvl9O6WN+MFAA1B5qMhqm6imyFymvH5wjKTSVktzWmzxkQJTh3fH6AFIWsGU 5nUncZclPPs0cTOIBXHbRadP5rWrTInxmdohCU6TZNwEJ6/COZsIjEV3HNQXbC0R86XM bGDSspfH/2WT3M7Rj4sGmYXfU7wzz3uKyM7DsC5iNURYzvxWpIXNMQtWQZEc4zGy2CfH msueYSKFjXIQBwzUnweSezPrtfjSXzLbN8fiImPnjktGXVBRrPy4jup5lOuplPJOgG0F DMGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8WXG2PIfyvvmPCMZWK/gVmBE6W6BlBqBnmsVmBGJnAE=; b=iiBWJhA7G8H3zVZaJn6sTnRLZL8bflUETgkZq+ZjRg7RXN0SB2Uvuakic7PfjZYohl Elp7ND5gt7YRSjJ6qVsjX8f0m84xlpp79RyijQzR6we3R/aFuBuPL/1N5rIPER77J0pf c2LsEwYKHtKM1f7CQI7Ndvn8zJmxknCVsYrVyjhznlKF8oUprVWSu1Rlz1ftF0KzWn9r bvPtKJ2bGcTxGNEcY99v/bjKU7GO85P5OdZtbhFTj9OlACdVWobAQLqE1SPtB+pwVAXg e1V3QtZ2kTNEY7jAGo6LXOzlzJKSOq/aadCquTJNjY2ASX7cp486VIf+jwrFubHbltLJ WifQ== X-Gm-Message-State: AOAM530ISLQzNL9VzzJkKRvw20WT5l5HmI/fanmtWvJmPdQDG1Q3Z6Q9 oCtR2BFlbP2yXZdRDSC4RigjJ9yNBv5+hP4kGy1gnQ== X-Received: by 2002:a17:906:6d56:: with SMTP id a22mr4555135ejt.440.1594914821045; Thu, 16 Jul 2020 08:53:41 -0700 (PDT) MIME-Version: 1.0 References: <20200716060553.24618-1-ebiggers@kernel.org> In-Reply-To: <20200716060553.24618-1-ebiggers@kernel.org> From: Dan Williams Date: Thu, 16 Jul 2020 08:53:30 -0700 Message-ID: Subject: Re: [PATCH] /dev/mem: Add missing memory barriers for devmem_inode To: Eric Biggers Cc: Arnd Bergmann , Greg Kroah-Hartman , Linux Kernel Mailing List , Linux MM , Ingo Molnar , Kees Cook , Matthew Wilcox , Russell King , Andrew Morton Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 11:07 PM Eric Biggers wrote: > > From: Eric Biggers > > WRITE_ONCE() isn't the correct way to publish a pointer to a data > structure, since it doesn't include a write memory barrier. Therefore > other tasks may see that the pointer has been set but not see that the > pointed-to memory has finished being initialized yet. Instead a > primitive with "release" semantics is needed. > > Use smp_store_release() for this. > > The use of READ_ONCE() on the read side is still potentially correct if > there's no control dependency, i.e. if all memory being "published" is > transitively reachable via the pointer itself. But this pairing is > somewhat confusing and error-prone. So just upgrade the read side to > smp_load_acquire() so that it clearly pairs with smp_store_release(). > > Cc: Dan Williams > Cc: Arnd Bergmann > Cc: Ingo Molnar > Cc: Kees Cook > Cc: Matthew Wilcox > Cc: Russell King > Cc: Andrew Morton > Cc: Greg Kroah-Hartman > Fixes: 3234ac664a87 ("/dev/mem: Revoke mappings when a driver claims the region") > Signed-off-by: Eric Biggers Makes sense: Acked-by: Dan Williams