Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3256482rwb; Mon, 3 Oct 2022 12:00:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SwXkYDOv5q1u+LDyT9V84jA1XhmUuKF8uZGg3EiFm3RHAceWkrp/GSzWCRU/vaSZjDurA X-Received: by 2002:a17:906:846a:b0:78c:21c4:e94c with SMTP id hx10-20020a170906846a00b0078c21c4e94cmr3370127ejc.221.1664823648725; Mon, 03 Oct 2022 12:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664823648; cv=none; d=google.com; s=arc-20160816; b=MQXOVYTAkuvw7iQ13PhRKgINRbnioGx6YphcUI2EVqSpL/E9xXDtrTwG0FUNYK6Nsu iwcwUKjFNnmaoA0p6zEZx187HzaF4ozQi29Idl81aKtcTmW1sTB0kIHQG7VP6Vd4O408 bnupWu+o0agb2Jo6GMV7QrcjfXyzp3I+mkNvz/wtunY8Q4hqyKbve7uEAGK42wIOPpt/ LODz+gHfEO8PMT+Wxfih9+N77HdM2BXx9irw3qU8TKg86TXc+XglCBFegCvWlO1zOQHN ct8wwCNrBXq1JLTqCh/CYxr/oYMdvZcPLiLuF7ZEuoqcRq2hBbqavXB9fHtidzbG2WEF +UZg== 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=DBHYwkpApAIABn5XcTL1sIyH02ALe7H/mB3LgfPMN3k=; b=IicYVPR9bpwZX5S92NvDCSfOijLeJSSPbKH1F7H/esFegIO0o5xemQqPGb4HGW8okc 92wuKRPnqsC0b4aTeVhtQcs8Jly9H7OhRjrUsVZ4a5aIgdhkaHHptzkj0jI8CEcjJBfY 2bsIj9HwQyPXf57NhxPbqGcb1sqy0egBSd9Fw908/QvEp+k/DrAYTb21wwLdSb7DiF/v eFMO16Faz1IMtb+NwzMwmapFvEJ4yguAPE4PVF466P+NHjYk6FQkBXg0JDbDDzEFY8Cy Xlu6G1EgKi1avMRAW9U9kwA/eb7pnJZtKP2z0ALgYDos9AVwUHa0F1oRNhJlcA+NnAKT 41iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kHzL1DsI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a056402349200b00457d8a93aa3si10067482edc.553.2022.10.03.12.00.22; Mon, 03 Oct 2022 12:00:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kHzL1DsI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229940AbiJCSRX (ORCPT + 99 others); Mon, 3 Oct 2022 14:17:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230025AbiJCSRR (ORCPT ); Mon, 3 Oct 2022 14:17:17 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CB5C41508 for ; Mon, 3 Oct 2022 11:17:12 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id x32-20020a17090a38a300b00209dced49cfso8089822pjb.0 for ; Mon, 03 Oct 2022 11:17:12 -0700 (PDT) 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; bh=DBHYwkpApAIABn5XcTL1sIyH02ALe7H/mB3LgfPMN3k=; b=kHzL1DsIZG6UyJD0H4Y2gyQK42lrd46BEA08dhT4984lLZjuZ+t3T6ihFZm7ctHiXT FJvnBV/hZHQndEO1qssqPK2WLnC3aEuwgl5O0ItlYjzqIr0fl4pn+au+FCUU2lDsB+KQ MRAZSxf7gnx57svX5gYl/RcbrD6H+53B429XQ= 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; bh=DBHYwkpApAIABn5XcTL1sIyH02ALe7H/mB3LgfPMN3k=; b=wX1O9x5ePgbQAs300A+RyQ9X6klSl6YMkQwIRJXpWZgqsVOoK4nf025TFwgHeP5oES PiCWAYDJNpaEUbVdOUWpDgbsSj0UcM3QVM9oq1BFuVq6LvRxmmfRdmSMP1Q2rcsGWSE1 h8FmFoyP/+uGvzyT5xp2OU11mHnQqzLn6hjyER3fogKkrXB1CZDKu1G7Nbfr9GQlPCem czEIV1GWoNgGOZPaRwkQLVgf6R/Iv5/sD/05Dv6vLBARoXEfgFLhF/F9cIEboI/IeWBS oTDw2O0ZET/Acbvog9wGIpoePGc78OEc8wZvPUT3mO22xq+RRPqrnOZ4pSAongjyko32 y5xQ== X-Gm-Message-State: ACrzQf35X/23Dlmx/2/LZL40k9X8USQGr7Qdg1uBPWJ/VjpM2T0R4rpK CzIjoXRRVmzWgTvQ+bFWYkAJRg== X-Received: by 2002:a17:903:2309:b0:176:de48:e940 with SMTP id d9-20020a170903230900b00176de48e940mr23282806plh.15.1664821031947; Mon, 03 Oct 2022 11:17:11 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q12-20020a65624c000000b0043a1c0a0ab1sm6913582pgv.83.2022.10.03.11.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 11:17:11 -0700 (PDT) Date: Mon, 3 Oct 2022 11:17:10 -0700 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 , "Ravi V . Shankar" , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, Yu-cheng Yu Subject: Re: [PATCH v2 14/39] mm: Introduce VM_SHADOW_STACK for shadow stack memory Message-ID: <202210031113.FCBAD74@keescook> References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-15-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220929222936.14584-15-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 29, 2022 at 03:29:11PM -0700, Rick Edgecombe wrote: > From: Yu-cheng Yu > > A shadow stack PTE must be read-only and have _PAGE_DIRTY set. However, > read-only and Dirty PTEs also exist for copy-on-write (COW) pages. These > two cases are handled differently for page faults. Introduce > VM_SHADOW_STACK to track shadow stack VMAs. > > Signed-off-by: Yu-cheng Yu > Reviewed-by: Kirill A. Shutemov > Signed-off-by: Rick Edgecombe > Cc: Kees Cook > --- > Documentation/filesystems/proc.rst | 1 + > arch/x86/mm/mmap.c | 2 ++ > fs/proc/task_mmu.c | 3 +++ > include/linux/mm.h | 8 ++++++++ > 4 files changed, 14 insertions(+) > > diff --git a/Documentation/filesystems/proc.rst b/Documentation/filesystems/proc.rst > index e7aafc82be99..d54ff397947a 100644 > --- a/Documentation/filesystems/proc.rst > +++ b/Documentation/filesystems/proc.rst > @@ -560,6 +560,7 @@ encoded manner. The codes are the following: > mt arm64 MTE allocation tags are enabled > um userfaultfd missing tracking > uw userfaultfd wr-protect tracking > + ss shadow stack page > == ======================================= > > Note that there is no guarantee that every flag and associated mnemonic will > diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c > index c90c20904a60..f3f52c5e2fd6 100644 > --- a/arch/x86/mm/mmap.c > +++ b/arch/x86/mm/mmap.c > @@ -165,6 +165,8 @@ unsigned long get_mmap_base(int is_legacy) > > const char *arch_vma_name(struct vm_area_struct *vma) > { > + if (vma->vm_flags & VM_SHADOW_STACK) > + return "[shadow stack]"; > return NULL; > } I agree with Kirill: this should be in the arch-agnostic code. -- Kees Cook