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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF5A9C47088 for ; Sat, 3 Dec 2022 02:38:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235095AbiLCCif (ORCPT ); Fri, 2 Dec 2022 21:38:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235031AbiLCCid (ORCPT ); Fri, 2 Dec 2022 21:38:33 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 124D0EC089 for ; Fri, 2 Dec 2022 18:38:33 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id v3so5850220pgh.4 for ; Fri, 02 Dec 2022 18:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gY59Fkmvz/8ABweO9p7GPk5PRE6er0EUBOixMOBIZII=; b=augaWf6GXd9U6BdDDe7DQtiyBUROf4u8aSOBMTvbdV9soqeHINlVqORoAlWlcSnFIJ A6G/rau+z3mESfnnELYgyGtAiSBOoqnQRoNFR81xieE0Lun+vc/zzKgMALA5H3YgRR+h uPPpnIPsKxYgFZlcIItboAh8jK9HLc9g/yUos= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gY59Fkmvz/8ABweO9p7GPk5PRE6er0EUBOixMOBIZII=; b=WZJ5lLRqCwnKcUVGyuyuELVn+9MJugrnM/nyXYtnDqSdGlVIRk+PfrjeN2RCeVHOfi 0cInUFfYq15pYCYVQ3QPjkJ/AHhCZ//NxnB9oQcc2tWnGH0WIFaVg1eS4aMBPClkBDbQ N9y9qKfbVFKFYGAKOwegPQeS4IJB1DwcD0GTUSqm12aK7vnYu0c1lZVKC/2LPCBSIjdx rmO4+ISaYaDy8jZvh/xGAEgpca3tFIjevPPcW9BIY6admS9D9nMhkRdVcniq8EmT5BnP uSTpYrMh28P8QoeIAs5fBAI33k6KaY9lgIMbTdQrfurWoL2KM4ow/6vpfVNs6DKtHl3V Gh3g== X-Gm-Message-State: ANoB5pnI1D8Og4d3XPIRwqsO/GvhFx9KZE8bmXxw7/A38p4XoXE9slWq lQZ9MgJKEKC8LbPpKVrHlse3yw== X-Google-Smtp-Source: AA0mqf6WTehuBNCmz0UyKCIFRRqKtrKxlHeTLSUldJI0j/UdtIvxFRjDpcmmJNpeC3TH41FOco9P2g== X-Received: by 2002:a63:f506:0:b0:470:14fa:a294 with SMTP id w6-20020a63f506000000b0047014faa294mr47726112pgh.361.1670035112600; Fri, 02 Dec 2022 18:38:32 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y25-20020aa79af9000000b0055f209690c0sm5739192pfp.50.2022.12.02.18.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 18:38:32 -0800 (PST) Date: Fri, 2 Dec 2022 18:38:31 -0800 From: Kees Cook To: Rick Edgecombe 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 , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, Yu-cheng Yu Subject: Re: [PATCH v4 21/39] mm/mprotect: Exclude shadow stack from preserve_write Message-ID: <202212021838.E8645AD@keescook> References: <20221203003606.6838-1-rick.p.edgecombe@intel.com> <20221203003606.6838-22-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221203003606.6838-22-rick.p.edgecombe@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-arch@vger.kernel.org On Fri, Dec 02, 2022 at 04:35:48PM -0800, Rick Edgecombe wrote: > From: Yu-cheng Yu > > The x86 Control-flow Enforcement Technology (CET) feature includes a new > type of memory called shadow stack. This shadow stack memory has some > unusual properties, which requires some core mm changes to function > properly. > > In change_pte_range(), when a PTE is changed for prot_numa, _PAGE_RW is > preserved to avoid the additional write fault after the NUMA hinting fault. > However, pte_write() now includes both normal writable and shadow stack > (Write=0, Dirty=1) PTEs, but the latter does not have _PAGE_RW and has no > need to preserve it. > > Exclude shadow stack from preserve_write test, and apply the same change to > change_huge_pmd(). > > Tested-by: Pengfei Xu > Tested-by: John Allen > Signed-off-by: Yu-cheng Yu Reviewed-by: Kees Cook -- Kees Cook