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 32A70C4332F for ; Mon, 3 Oct 2022 18:17:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbiJCSRY (ORCPT ); Mon, 3 Oct 2022 14:17:24 -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-Google-Smtp-Source: AMsMyM7R1eYi6BdCJuNjc9yq5g+SkFoqirO1gAwAdKpmAlfGtFdUBZPaQLGRzF2mymr5XfWRjx2KIw== 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> 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