From patchwork Thu Oct 11 15:15:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10636857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1348C17E1 for ; Thu, 11 Oct 2018 15:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 023002B9BF for ; Thu, 11 Oct 2018 15:21:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6C8C2B9F1; Thu, 11 Oct 2018 15:21:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F282B9F1 for ; Thu, 11 Oct 2018 15:21:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 721076B026D; Thu, 11 Oct 2018 11:20:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 65FDA6B026A; Thu, 11 Oct 2018 11:20:52 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3E3966B026B; Thu, 11 Oct 2018 11:20:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id C82A26B000E for ; Thu, 11 Oct 2018 11:20:51 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id m4-v6so6230336pgv.15 for ; Thu, 11 Oct 2018 08:20:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=D27RwH8NeKlKuxHKwLxQrrM0B4XZoNvu8mXVfNenXUU=; b=HzD/+1/PiB2iob9szw2ZypN5pcxaTehF9ZypL89RQ9zSHUP0YhPtebMPnUe3HvNBsD nL+0+NwzfWPzLdxmIEFnhpjt7VdmhPyHqLvbCutSOKth4vG+JaX0k6eq4NzZXScZE/sh 7QdXUK/2xztUwi52aM1Igk+za9bDe70ujcOaZxF9QRbOQJK0g4QNPU0GI3l2bPUyfkb7 0Ckpq/DF0RJ9CY5/UFcKdMyzoAzR6bgSENXR0n202XvDxwkeZPqzj0xESbJnMYfHKL1T OkuUPMZCIWyMtuaJJT2s1lEX/GK+3ALq1xsNucZAtybqe1C6Rd/lJXELOm1QKwQxlRLB PFbA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfohjayrNQd0K9b8AjhsjTfZScvM1NDxdiLK1RyrdctnWRDUCz6uu EgkIAqtxx+rrOB2QuZoPbdo9X6gkGd0eSEAstT5xSPXLY26ycJ/bGUTZiDm7jpRIqYRepzmpGxj ODVyDb7PzilESD/oFnAb2WCAlkC+eqjnvpC/vLgSF6rSBhXOuH+6ep3xodSEO9LhhEw== X-Received: by 2002:a17:902:d01:: with SMTP id 1-v6mr2055167plu.88.1539271251507; Thu, 11 Oct 2018 08:20:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV62S1Ln4or9vNkLNkXXkpJfGoHQvI4pcMXkYheeASz8NZh5LFNWwkRaUDPuvnfngLBZIr026 X-Received: by 2002:a17:902:d01:: with SMTP id 1-v6mr2054920plu.88.1539271246877; Thu, 11 Oct 2018 08:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271246; cv=none; d=google.com; s=arc-20160816; b=DNMubwIfIoN84SkwOqEKWIfKCyPyRnX69mZ1pgciNJQcJ/+NSbQ+WqYbMNJlntGWgp 7aQSuYT63x7h5gJqJudgrBiH9uCQHVb8lc5A+8n917Bp5yqcxNuiJP7fPz3r2xS56O+y dbPS76Av2Q1dqRbHq36IfHDdfxUUCO3F+ktfsK3Zj0lk9tLYJhK4nE0+rFHwSxMARD6K 0YYhixaAOrFQkbJ+17PAjmVP2hLWO25UiJcJQXIr0NaSmvBT5ff4+KOLmTN2nDnQ6HBN SlTTzr6JYvG9koY663CnWHs0lbuDYAhhYUARLZCqX+Dq37haBy/mwnRP1wemKaFAvJBE uc7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=D27RwH8NeKlKuxHKwLxQrrM0B4XZoNvu8mXVfNenXUU=; b=kxGnRlWB/haVDgI3ArryCrLNc3w5kfTPeS5MyE5sUrsVakCkOT0i17Rac5aPLgmPLH ukFCSSLroGnaUU9rk8hOh25sZOFdNj2bHCRRPQZ/Cc3s7mTo1WqEQJGE3yK2FzaK7aLc OHgZBTnBjlB19IvtSe6s2nX1df3zQwfNSvJTLjf22uwraoCNqiOo3VmaTiYTFhpliRv7 lwA+2/ifgJfI4PSxTR2/kekW+siJMc6kocVUKwhyeIA+uTjl45fybtPqcAJwqpbIviqN 9nooIHr++vIfa0laEQDmI+obONh7nRkoxcVwGp/br2IU2vLrcbKh27ZShIZ6+YlhclsY yh9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga09.intel.com (mga09.intel.com. [134.134.136.24]) by mx.google.com with ESMTPS id m7-v6si30485701pfi.286.2018.10.11.08.20.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 08:20:46 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) client-ip=134.134.136.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:20:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="78019105" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga008.fm.intel.com with ESMTP; 11 Oct 2018 08:20:44 -0700 From: Yu-cheng Yu To: 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 , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [PATCH v5 09/27] mm: Introduce VM_SHSTK for shadow stack memory Date: Thu, 11 Oct 2018 08:15:05 -0700 Message-Id: <20181011151523.27101-10-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151523.27101-1-yu-cheng.yu@intel.com> References: <20181011151523.27101-1-yu-cheng.yu@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP VM_SHSTK indicates a shadow stack memory area. The shadow stack is implemented only for the 64-bit kernel. Signed-off-by: Yu-cheng Yu --- fs/proc/task_mmu.c | 3 +++ include/linux/mm.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5ea1d64cb0b4..b20450dde5b7 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -652,6 +652,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) [ilog2(VM_PKEY_BIT4)] = "", #endif #endif /* CONFIG_ARCH_HAS_PKEYS */ +#ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER + [ilog2(VM_SHSTK)] = "ss" +#endif }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index 53cfc104c0fb..f658923e76ad 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -224,11 +224,13 @@ extern unsigned int kobjsize(const void *objp); #define VM_HIGH_ARCH_BIT_2 34 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_3 35 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_4 36 /* bit only usable on 64-bit architectures */ +#define VM_HIGH_ARCH_BIT_5 37 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_0 BIT(VM_HIGH_ARCH_BIT_0) #define VM_HIGH_ARCH_1 BIT(VM_HIGH_ARCH_BIT_1) #define VM_HIGH_ARCH_2 BIT(VM_HIGH_ARCH_BIT_2) #define VM_HIGH_ARCH_3 BIT(VM_HIGH_ARCH_BIT_3) #define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4) +#define VM_HIGH_ARCH_5 BIT(VM_HIGH_ARCH_BIT_5) #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ #ifdef CONFIG_ARCH_HAS_PKEYS @@ -266,6 +268,12 @@ extern unsigned int kobjsize(const void *objp); # define VM_MPX VM_NONE #endif +#ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER +# define VM_SHSTK VM_HIGH_ARCH_5 +#else +# define VM_SHSTK VM_NONE +#endif + #ifndef VM_GROWSUP # define VM_GROWSUP VM_NONE #endif