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 85472C433E6 for ; Thu, 4 Feb 2021 20:21:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33DE964F45 for ; Thu, 4 Feb 2021 20:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239878AbhBDUUq (ORCPT ); Thu, 4 Feb 2021 15:20:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239989AbhBDUUe (ORCPT ); Thu, 4 Feb 2021 15:20:34 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD022C061786 for ; Thu, 4 Feb 2021 12:20:19 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id g3so2378407plp.2 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=pNfuxMcLgcHk3PS8/v8ymae6QUYw3eWlUJoNRJ3i5fEWA2I3nHERGTPkdecYfKaRmW GgZPnviGO2xq0JmkS7Vci1HvX619BDTuRld439myrCDqmXeONheNol37Ojqju0oPx8Do 6Mz1TWV6nSZfTr3JJz3OJxjJBJWZ9XQuLaEQmT074H7kWpfy6VltQUB1VLFKfztgIoCQ hnj3sA1+Re3Lcw0kYoef/kPLwQgRDcNjgyGbxlJWMOVIkgLISJ8a4jsDmRF2WD/eLlv8 BELJb3YBGaGhF+koGp/STEcWs2cNghXfiaCantM0aVNPOqXkG8AKATmg2u2kDiapBqO4 CKwg== X-Gm-Message-State: AOAM533PAQAevxRoVO1tFGjnIc7wyBS37vS5tpWjXM4J9zll1d10rMmh Ap/s+NABbpsP3M/0srdG6qjMDw== 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> Precedence: bulk List-ID: X-Mailing-List: linux-api@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