Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1419093pxb; Thu, 4 Feb 2021 12:26:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8/1laj/j+RyXAEOj7NmcBorWKpyUOsbCoppHJcYqX7ZSwik1GNBblvYOgw3lN4XJUWc4l X-Received: by 2002:a17:907:7815:: with SMTP id la21mr824872ejc.12.1612470414412; Thu, 04 Feb 2021 12:26:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612470414; cv=none; d=google.com; s=arc-20160816; b=y9/nemWt1EcS4vrByaQhJSM6BZfOQuhE/Kr2BrQ1OtMGrpIDi3QRmkHTcZzWYmUBqG 0BkF0xVeLNZjls+cgOdZPxRVdA4IDxhDh6MShmOrjCSud3jtW6q9CVIavML7cDraiR5w tO0sOpSMzMtnAUXqqtmj8pZbl3bPHoHtZF6SPGeCQ0vUtwOULLnj76ZfEeg2O+5ToGkl 4g8bNB9/UM5QJDjnYL41O/oG3mTP8nQmMG+T7vHY+5mtWD+n9Gv4qylONro7aEN4Htvz Qgcg9swqJokdZAhAPc2/8aDHXUcX3Xpf9jb23wviw4RjQgdUbhNWJ/LiESdZH1VA59mn Ft2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=wnU2ljW3GZfVnC0yk4dz3F0Y7a+z0DVuakcSpmImkaw=; b=s8RfyLa2L0wATe7qt+p99v1LnVLj0/KHu7IKLCGRfi9L+dCZayVgO089CCqekUaEk0 7Ii+UizhQFAO/nFW2Ui2nukON/0MMXZaajh1LUCUwEdMfPmdcsr+19ROY4ehimlaZ36h ub7WY4gT6jwWX6PVN4VRoRH6e9otSTmADgFJXK/Rd7Zxi4nRvl0DjIdmFBrl/Eipaj2J kKPQ27rxSlltxLWBRKyql24mHab5SUGTh8UXf11Pn4GtM3yrlSDT7Mxw0erpGLtkUcSr Xp1xpVhEZ4xmwhjBuBk89xbB3jcn6Lx9jSRgv5zd8sJkq8DgfcgVoPMKG9kJ+WSjaK7D MdkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gk1+3E6z; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si2586875edq.1.2021.02.04.12.26.29; Thu, 04 Feb 2021 12:26:54 -0800 (PST) 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=@chromium.org header.s=google header.b=gk1+3E6z; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240077AbhBDUW7 (ORCPT + 99 others); Thu, 4 Feb 2021 15:22:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240064AbhBDUWr (ORCPT ); Thu, 4 Feb 2021 15:22:47 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4FB6C061797 for ; Thu, 4 Feb 2021 12:22:15 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id i7so2908085pgc.8 for ; Thu, 04 Feb 2021 12:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wnU2ljW3GZfVnC0yk4dz3F0Y7a+z0DVuakcSpmImkaw=; b=gk1+3E6zusffn9W5IuwsN3M705pg/AsgpNvWYuk60I9SgeXKbvb/YqudopHfguTWg9 XHcDS3MQ5Ux9oTwks1PbxMjwOQxFmmNtlcxRxjcKXwBpL+AypZgWkafkkCYlZNNC8R7x wPriOS6bS/ExEs3s+CHTQ9aBYRWxITrDlxn9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wnU2ljW3GZfVnC0yk4dz3F0Y7a+z0DVuakcSpmImkaw=; b=ACibfZ3nVi81xnXVtrhPqp4YJUJlSDfGQBPdkKd1VTHJsBDBK1P8qh4DZRPHoq97T0 92YZJoYHt5ThDlXgku1UU1Kts4MMSbSmIaedu4z5wsKsb7vLojUOqleE1Ud/S+MMWz4T /mMoJFP53EwtnycYNtBm8iZXeGPGTnMdwgl0ERgzZe+pr498RIanIt0EVYjOm6zabOna 7l1WW0BEhNtMuEVLypiwLdpdQh6MjwllF9o16GnKY+J1BFrdAFsIMbW2CSYm6hTGuqGj FtN/8g5+GwNcy6O6xLb0urhBEjVfwhtbswooJgMZbyoIirf2TO6tyCbvl6P9Z0i2r3GO s46Q== X-Gm-Message-State: AOAM531owQ7WDcHpeBnRzzeaIWgDzH4n/DpK8sLKxlOLSNjfT0LtcE3O zUdK5ScLLc2PnpvaOfwn74GZXQ== X-Received: by 2002:a63:5952:: with SMTP id j18mr708407pgm.29.1612470135501; Thu, 04 Feb 2021 12:22:15 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 11sm7480618pgz.22.2021.02.04.12.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 12:22:14 -0800 (PST) Date: Thu, 4 Feb 2021 12:22:13 -0800 From: Kees Cook To: Yu-cheng Yu Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu Subject: Re: [PATCH v19 14/25] x86/mm: Update maybe_mkwrite() for shadow stack Message-ID: <202102041222.B111A20A9@keescook> References: <20210203225547.32221-1-yu-cheng.yu@intel.com> <20210203225547.32221-15-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203225547.32221-15-yu-cheng.yu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 03, 2021 at 02:55:36PM -0800, Yu-cheng Yu wrote: > When serving a page fault, maybe_mkwrite() makes a PTE writable if its vma > has VM_WRITE. > > A shadow stack vma has VM_SHSTK. Its PTEs have _PAGE_DIRTY, but not > _PAGE_WRITE. In fork(), _PAGE_DIRTY is cleared to effect copy-on-write, > and in page fault, _PAGE_DIRTY is restored and the shadow stack page is > writable again. > > Update maybe_mkwrite() by introducing arch_maybe_mkwrite(), which sets > _PAGE_DIRTY for a shadow stack PTE. > > Apply the same changes to maybe_pmd_mkwrite(). > > Signed-off-by: Yu-cheng Yu Reviewed-by: Kees Cook -- Kees Cook