Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1416962pxb; Thu, 4 Feb 2021 12:23:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFIOVgFax7hv8vfDEZXxksITP+npHOTInKv+oKBmXumm/wk80xX3nNmsQbDesJFaWrDabO X-Received: by 2002:a05:6402:4242:: with SMTP id g2mr327806edb.103.1612470186461; Thu, 04 Feb 2021 12:23:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612470186; cv=none; d=google.com; s=arc-20160816; b=kd5hVxRQFUX4rpZWiKNJ0rE1S3ighDP7TQExaIoldqAWOHy3SBzZVf1Rak0jylMkg3 BC061xZb7NwED09SfuVss1twXMqIy6oThr4xaWOxRHSC/0Euy5F2wpRhe5762AojFMfV 1YpfgjgLMZAVomqAg0Pt4k7AI1znW0Y0IliJD6nLfcf3vpFPipKboG+I1b0F/4hQ82RJ IucVkd/vpW0alJYrmokAdmL8FH+cStS8gfla9XhZfV4QO4IHiLVd6ctCLBIkQlJxDQme 0BfE2VINntOTQ+6SnxwYTe4vyv/SlluYrITtWdKYfjxMwvuL5dCDWPVB1+lg/qTCcSQ6 58Yw== 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=F9VJiSBsSJrC2jYFpinGxml1C+FEA2FI359p7GFWxRk=; b=ztCk8RL7YlTPOgOBiQWNbM88WXLG8KbwXMpWGJbCm2RPQCprY8u+MOUFonQz7YTcY8 KJ19cLE84ykIEue9ux0w/TgeQCTJctgTP1527lcY5+aEWKklLqBSAgT5QcjqPDaaMzvp iZupl4RlTozCe0NxgsNRfm9f/vyyTXEXjgTVnNGgJqFcOZOoCaMrIM5jKSHvcaql/8PL mOeYFrl5ziHWNVhmrAv8u9W4C/6Q5S+YB4XNcWFUIkQVAMVnxuW3ISqAg3VqSHsyT4s/ /5336sDLDyyd7IFwqYIyOWt0BPF6RuPAzJNZ7Rb7e4BEVq8g/7KKbUC/a6/wtlolcBF3 IxfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="c/5NkgLk"; 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 s24si4289381edc.77.2021.02.04.12.22.41; Thu, 04 Feb 2021 12:23:06 -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="c/5NkgLk"; 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 S239980AbhBDUVC (ORCPT + 99 others); Thu, 4 Feb 2021 15:21:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239972AbhBDUU7 (ORCPT ); Thu, 4 Feb 2021 15:20:59 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF37DC06121D for ; Thu, 4 Feb 2021 12:20:19 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id a16so2360328plh.8 for ; Thu, 04 Feb 2021 12:20:19 -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=F9VJiSBsSJrC2jYFpinGxml1C+FEA2FI359p7GFWxRk=; b=c/5NkgLk9f8BEYqE56ET8+WzEVofqlfPRO+MbMbE//bUeWJRI02oNDJzpV0SLJhIc5 6D9RH/prXQsmSQGf9ZgZnJtulSPKZgpfDnA7ktC3nrpRtv+lWuTHekSo3NZ/Nie2Hyb3 SJOnCJ5RfkMbhhOvVcpnRaN4WpUpxHytY/BYk= 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=F9VJiSBsSJrC2jYFpinGxml1C+FEA2FI359p7GFWxRk=; b=Xs/tiEw7Hc3m9mURWsa2etbsVuVKq4+Qjof40VgF5E1QDRRqjr7lkXsTg4MpRJyKot nw0g4XeXtDP3Zb31R+mhw1FxiJUR6oHoR9Qz7II9I7cMXAPN//dhv1PkFQpquRZbeTH9 hrnyrjZBwuuT6inQOFfzQ66AxxOoRdEOfLfvGsSVzvLiQW0WCw4aoNNBq1IpNCNr6DFr et6VPPtwbqfKUt198CEI6K31DL/8qXHHUjPGIJwCdlgh5qKFo5Tv9bh6cn72HmD+9epg DjBPgvYWW4KkQjHKxiahqKYRb11esjgPMLOGi0s4wKxb7Wjw2YrAARo+R9alQPQLPUYp hitw== X-Gm-Message-State: AOAM532Db+/kwarJ5R1HBie5IJ/tYO/rIwNexr9wRR+X4Zq2pwi//r17 g/AhUdq4ngiF545BeDRiDx4dww== X-Received: by 2002:a17:902:a517:b029:de:79a7:48d9 with SMTP id s23-20020a170902a517b02900de79a748d9mr794632plq.45.1612470019288; Thu, 04 Feb 2021 12:20:19 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u12sm7319901pgi.91.2021.02.04.12.20.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 12:20:18 -0800 (PST) Date: Thu, 4 Feb 2021 12:20:17 -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 10/25] x86/mm: Update pte_modify for _PAGE_COW Message-ID: <202102041220.17A5BFD5BB@keescook> References: <20210203225547.32221-1-yu-cheng.yu@intel.com> <20210203225547.32221-11-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203225547.32221-11-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:32PM -0800, Yu-cheng Yu wrote: > The read-only and Dirty PTE has been used to indicate copy-on-write pages. > However, newer x86 processors also regard a read-only and Dirty PTE as a > shadow stack page. In order to separate the two, the software-defined > _PAGE_COW is created to replace _PAGE_DIRTY for the copy-on-write case, and > pte_*() are updated. > > Pte_modify() changes a PTE to 'newprot', but it doesn't use the pte_*(). > Introduce fixup_dirty_pte(), which sets a dirty PTE, based on _PAGE_RW, > to either _PAGE_DIRTY or _PAGE_COW. > > Apply the same changes to pmd_modify(). > > Signed-off-by: Yu-cheng Yu Reviewed-by: Kees Cook -- Kees Cook