From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A2E1C433E0 for ; Thu, 4 Feb 2021 20:20:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EA86164F59 for ; Thu, 4 Feb 2021 20:20:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA86164F59 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 601616B0005; Thu, 4 Feb 2021 15:20:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5895E6B0006; Thu, 4 Feb 2021 15:20:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 479C76B006E; Thu, 4 Feb 2021 15:20:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id 3009D6B0005 for ; Thu, 4 Feb 2021 15:20:21 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E43F38249980 for ; Thu, 4 Feb 2021 20:20:20 +0000 (UTC) X-FDA: 77781702600.22.smile72_1804c98275df Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 9584318038E6C for ; Thu, 4 Feb 2021 20:20:20 +0000 (UTC) X-HE-Tag: smile72_1804c98275df X-Filterd-Recvd-Size: 4582 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 20:20:20 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id nm1so2354522pjb.3 for ; Thu, 04 Feb 2021 12:20:20 -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=J0Zot+o0eqbcitXneKLMPdKhe2pFjHfnzfFgN66PnN8Y30PC8oG6YeqE8NxJ7H0X+3 fRM8SQQyPYDjWJi86Z80HoFoDS86NKHwxCsRMcjWDuJsVw7/tE4ObdflRzIEpr+/TP2w seC5IceuOCQ89dO6Key4ctwehuxkxjbAh2haMhcd7M3RfO7ev+QH8plrC5yIchBv0suT pSzmHyRPD0xtsyUUEdwvRjh5BkkiKFWuIOhR3kYLLh/8Wm/5dv82qhkdSqk6UsnpG6dI eVJSzwSyAI80G1XlXTHHCSs8RTE2SlP8kbBy0NiuNgY/bZQhOnaSPLuEVHxbdinAUxXN oGHQ== X-Gm-Message-State: AOAM531mM8rEoTZ/CjKTx3I81uA+l+b4ZUmr3zhJXHkernaSk/mf2KmQ 2U+g7vXn9v8F3BywgnG7BFxI0g== X-Google-Smtp-Source: ABdhPJzAoT/duN3/3cQeFbJsfsFNnEoob6e0vNs7paRZBNrsjtPhY9hV5JE0VMUySldPrJ1O+2IAhg== 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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