Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1137270imm; Thu, 6 Sep 2018 16:22:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZYsLxpObI27Yn54K1bmwDOhpNDt+SpdEpyhaomo/72/DsgQ2kY8Gmu3Lbb6rnyp7YCtPmg X-Received: by 2002:a63:3281:: with SMTP id y123-v6mr5314016pgy.310.1536276143749; Thu, 06 Sep 2018 16:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536276143; cv=none; d=google.com; s=arc-20160816; b=uUdXVKXfTEWb/zwK+gSGf7gb9LDAs5r8/Db59sqpetp+dCPLsCPbX0k44Io2UrJm2/ zaNJ0T+IaPk4LRVoRjHFSkf5PLtLadb50KuW9LI3UeFepcaZ6OckQ3prnVbt4RTM5xOo 96sZ6YXfv7G+OvTTryVHUT/3OSl4Lrhelbofhc5LMENflBnzlnKXlJSzqJLhimQtrIT1 BbZZcwr09d80L5m0tbBFcJNuEmOAHgW1A16ZHNdC8yDfXOuloJpiy9mXRdr6/nZPKd/i HJjLdSgXTCpbi3h9r3RynCcIFkJTJT9njXm3IUGLD5worcUxuZz2iUGfCboLHe1N/tsa 1UKg== 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=ON+lHFM51K8CZHGRpJ/4i7t4ynNk3SJauBytIGPtdkM=; b=KE22FPbM8eAL1Btb/7B9epJ1AEyUlhX/YOHSf9PU6AaZ9lv0xA2dnRsIfw6Vp0/9/2 bZUMxCw/zw75ei7/u9YS3wlW80rDI7CYuEhkqH5y47Xc9/XkuocPIAUU0xq330xNegRZ xacfmb7bQUwumHZdpeu/yRYgglJBFJa0vFOe55xHw5tGIceCf46uNq3Hw29SQHb0iO0A sl+HlNSG8Tjim1tV5eTDHvZLBpYvJ2brNpzhXsktrYvVDtn4OLCPq6J1jF16sxYMkY6D cxAD05meWl2d1ATU0g4RRFFjBNtrdDKQuAjbIV1pfa9YWMp0DDEIknlM9ebl7l+XUcz+ hFHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=L4XF3DPr; 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 y15-v6si6271746pfg.124.2018.09.06.16.22.07; Thu, 06 Sep 2018 16:22:23 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=L4XF3DPr; 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 S1728813AbeIGAeq (ORCPT + 99 others); Thu, 6 Sep 2018 20:34:46 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50488 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728461AbeIGAep (ORCPT ); Thu, 6 Sep 2018 20:34:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ON+lHFM51K8CZHGRpJ/4i7t4ynNk3SJauBytIGPtdkM=; b=L4XF3DPrXbBbJSApxUIQpTA39 ofKHwm/aTwKfe0UpwlgzeMoWP1Zjmz/taeyhpAZJ4imMfat/7bFJFO1Rp61Z9ROAJc+Lnja+6z0wA bw+6qMDyUEZI2c2eEkzCNwlD/p9JSrvxWRLvK1ocjQLjB/69LRr5JYBTF/T+WObMKHjOJUH4hIYfA D8MEHiCTgxTy7bh7gCbQwW/arSvvUlRMlUrEk4sb6rI5Ii9ZU8ExyK/wtMH0vLUpqOf4xaXHp3fqf LfXmhjDVoY0fKKqqsyrITzpMI6I1JstS7UjS2g9BQ+f71n5fA8eUkFapWB2YXO401L4V7xmt8+sWz v5lr1S2ew==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fy0PK-00071f-IR; Thu, 06 Sep 2018 19:57:39 +0000 Received: by worktop (Postfix, from userid 1000) id A50286E0AA9; Thu, 6 Sep 2018 21:57:31 +0200 (CEST) Date: Thu, 6 Sep 2018 21:57:31 +0200 From: Peter Zijlstra To: Nadav Amit Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, Ingo Molnar , x86@kernel.org, Dave Hansen , Nadav Amit , Andi Kleen , Josh Poimboeuf , Michal Hocko , Vlastimil Babka , Dave Hansen , Sean Christopherson , Andy Lutomirski Subject: Re: [PATCH] x86: use WRITE_ONCE() when setting PTEs Message-ID: <20180906195731.GE4816@worktop.programming.kicks-ass.net> References: <20180902181451.80520-1-namit@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180902181451.80520-1-namit@vmware.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 02, 2018 at 11:14:50AM -0700, Nadav Amit wrote: > When page-table entries are set, the compiler might optimize their > assignment by using multiple instructions to set the PTE. This might > turn into a security hazard if the user somehow manages to use the > interim PTE. L1TF does not make our lives easier, making even an interim > non-present PTE a security hazard. > > Using WRITE_ONCE() to set PTEs and friends should prevent this potential > security hazard. > > I skimmed the differences in the binary with and without this patch. The > differences are (obviously) greater when CONFIG_PARAVIRT=n as more > code optimizations are possible. For better and worse, the impact on the > binary with this patch is pretty small. Skimming the code did not cause > anything to jump out as a security hazard, but it seems that at least > move_soft_dirty_pte() caused set_pte_at() to use multiple writes. Acked-by: Peter Zijlstra (Intel) Also, its corollary would also make sense/be required, use READ_ONCE() when reading these.