Message ID | 20230319001535.23210-23-rick.p.edgecombe@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp515277wrt; Sat, 18 Mar 2023 17:34:03 -0700 (PDT) X-Google-Smtp-Source: AK7set+gTZUT/tv0pAnuTtFBl8RHen3MUSXlHSWqJvzlIKvaK0UpDeqBtnDzxl0zUBJsgTLE7rTY X-Received: by 2002:aa7:9a1a:0:b0:600:cc40:2589 with SMTP id w26-20020aa79a1a000000b00600cc402589mr10959990pfj.3.1679186043043; Sat, 18 Mar 2023 17:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679186043; cv=none; d=google.com; s=arc-20160816; b=I3xvsCm9S/Fhtm2WKyE/RELPOkQiH/Fgoum/b+ws2BCrQj3l1eDdB4feouud8N1qR2 w2/HlC+1/WBeqIF6T07oJ/GbKyPaaoVJgRUlnahXqwt44DBil9NSf6fpCOyc/TaoiDdg 5fR65guu86G9n/DBvdTxEfBIpFiwudVNXcaCdyYekaIq9IslEZmKwr5Alq5S8qc6DA12 MY/p5ZSczvqr0bkJmDr5bT515AlT+8deXofWCKJ8p3V7bAfkcLTygvKpvJlg7WdfVjBX ZTiHPxkcteQHsBkN1ZUD3kxqykhpzD9lAxdDw6k0+Ftu3ciRyRwxRvE4zHi40qrwMXhN Uutg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=85mBto0Sll7IRfEByhCC7vuZskZGVCPWl8XWWuDZvdA=; b=E1gBJ8DlTSh3dIYZWEzkCbM0IhP6PDB7DvcgPaz1iDW5kkpNqQXMTS+TsC6JGPQYmc ZzDOyg4NRDQeOEPqbeE6dDuqslVz4DQWNr7inwZ519fDRHdc4pqzog7HSSLwfeSOkouY VsMFA7Fx+BDe7PRFHGj6szVdCoTROOAljeII2qQNMbX303Dow9uaD4gCcorXm9CQcffn JlKVFxEvk5HSRnDl6RAGHNpTd8bUyNM/MdmVjGvXfyPjI+ltkZLQlbRrsBkCqZlXM/ns m3R4kAMEZjh1E3/tWTdU6jZomB7i9q5Yrky6Xvmiavfy163vtPQe/FzPNWa59ftN+xYb x7dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KjrAtLf1; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 15-20020a63174f000000b004fb7e7ef77dsi6269928pgx.693.2023.03.18.17.33.49; Sat, 18 Mar 2023 17:34:03 -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=@intel.com header.s=Intel header.b=KjrAtLf1; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230232AbjCSAU1 (ORCPT <rfc822;pusanteemu@gmail.com> + 99 others); Sat, 18 Mar 2023 20:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbjCSATj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 18 Mar 2023 20:19:39 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4059FB776; Sat, 18 Mar 2023 17:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679185100; x=1710721100; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Y8Z54H+73n2LbfSOdI84l/ZPS4qK7Tl7I0RpDbdZ/iA=; b=KjrAtLf1PYOlA2PxSvyyY5JKF8NqnTZP1uejV/lWdRjrTnIJiRC26pea IUwdt1H8E9h9XiHa/Iymo3jKE8/ssk1LGJmXwe/6JaJAZrgkaIqi/OSay rfenCwPUjTgiIYDvdlcqwplgrQ3ObCi8otc5gFYi+HtqVJZdEKqyKqwnZ +3dtD7vKyuF3oC2vQImGHTFwW0BLd3cTWrtKsj/fPHjcIGxTAoxKCPvcU mkPybTK1cXH8FocJolb3Cn9B2T4G593HWcwXwyhOTt9UcP27YBcEd9EEM 8oREoYVCpFWV9AvCl33MRZpk0Fo0SAp8T5jwOA9ziKViKbHSWCqCZv110 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10653"; a="338491209" X-IronPort-AV: E=Sophos;i="5.98,272,1673942400"; d="scan'208";a="338491209" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2023 17:16:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10653"; a="749672869" X-IronPort-AV: E=Sophos;i="5.98,272,1673942400"; d="scan'208";a="749672869" Received: from bmahatwo-mobl1.gar.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.135.34.5]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2023 17:16:30 -0700 From: Rick Edgecombe <rick.p.edgecombe@intel.com> To: x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, 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 <arnd@arndb.de>, Andy Lutomirski <luto@kernel.org>, Balbir Singh <bsingharora@gmail.com>, Borislav Petkov <bp@alien8.de>, Cyrill Gorcunov <gorcunov@gmail.com>, Dave Hansen <dave.hansen@linux.intel.com>, Eugene Syromiatnikov <esyr@redhat.com>, Florian Weimer <fweimer@redhat.com>, "H . J . Lu" <hjl.tools@gmail.com>, Jann Horn <jannh@google.com>, Jonathan Corbet <corbet@lwn.net>, Kees Cook <keescook@chromium.org>, Mike Kravetz <mike.kravetz@oracle.com>, Nadav Amit <nadav.amit@gmail.com>, Oleg Nesterov <oleg@redhat.com>, Pavel Machek <pavel@ucw.cz>, Peter Zijlstra <peterz@infradead.org>, Randy Dunlap <rdunlap@infradead.org>, Weijiang Yang <weijiang.yang@intel.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, John Allen <john.allen@amd.com>, 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, david@redhat.com, debug@rivosinc.com, szabolcs.nagy@arm.com Cc: rick.p.edgecombe@intel.com, Yu-cheng Yu <yu-cheng.yu@intel.com> Subject: [PATCH v8 22/40] mm/mmap: Add shadow stack pages to memory accounting Date: Sat, 18 Mar 2023 17:15:17 -0700 Message-Id: <20230319001535.23210-23-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230319001535.23210-1-rick.p.edgecombe@intel.com> References: <20230319001535.23210-1-rick.p.edgecombe@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760754184336877202?= X-GMAIL-MSGID: =?utf-8?q?1760754184336877202?= |
Series |
Shadow stacks for userspace
|
|
Commit Message
Edgecombe, Rick P
March 19, 2023, 12:15 a.m. UTC
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. Co-developed-by: Yu-cheng Yu <yu-cheng.yu@intel.com> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Mike Rapoport (IBM) <rppt@kernel.org> Acked-by: David Hildenbrand <david@redhat.com> Tested-by: Pengfei Xu <pengfei.xu@intel.com> Tested-by: John Allen <john.allen@amd.com> Tested-by: Kees Cook <keescook@chromium.org> --- v8: - Update commit log verbaige (Boris) - Update comment around is_stack_mapping() (David Hildenbrand) v7: - Change is_stack_mapping() to know about VM_SHADOW_STACK so the additions in vm_stat_account() can be dropped. (David Hildenbrand) v3: - Remove unneeded VM_SHADOW_STACK check in accountable_mapping() (Kirill) v2: - Remove is_shadow_stack_mapping() and just change it to directly bitwise and VM_SHADOW_STACK. --- mm/internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/internal.h b/mm/internal.h index 7920a8b7982e..2e9f313fcf67 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -491,14 +491,14 @@ static inline bool is_exec_mapping(vm_flags_t flags) } /* - * Stack area - automatically grows in one direction + * Stack area (including shadow stacks) * * VM_GROWSUP / VM_GROWSDOWN VMAs are always private anonymous: * do_mmap() forbids all other combinations. */ static inline bool is_stack_mapping(vm_flags_t flags) { - return (flags & VM_STACK) == VM_STACK; + return ((flags & VM_STACK) == VM_STACK) || (flags & VM_SHADOW_STACK); } /*