Message ID | 20180921150351.20898-24-yu-cheng.yu@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 7FF7F15A6 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 21 Sep 2018 15:10:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 719222E4E8 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 21 Sep 2018 15:10:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F28C2E48A; Fri, 21 Sep 2018 15:10:29 +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 13EF72E4C4 for <patchwork-linux-mm@patchwork.kernel.org>; Fri, 21 Sep 2018 15:10:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F05758E001D; Fri, 21 Sep 2018 11:10:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E8E3B8E0019; Fri, 21 Sep 2018 11:10:26 -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 DA3418E001D; Fri, 21 Sep 2018 11:10:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 9C4EA8E0019 for <linux-mm@kvack.org>; Fri, 21 Sep 2018 11:10:26 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 191-v6so5738536pgb.23 for <linux-mm@kvack.org>; Fri, 21 Sep 2018 08:10:26 -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=+hAwkPRrWa1SdzA9lzXBTpLorf0142oXjZbO3utwlJg=; b=Zg62O24vKhph0/wxNzb3yK5vR51BagttjTbsCqmEp1QJvMSuVJsej4Az8bQ40Rcc4p V0r0hNdC7h+pyspGDQyUazLlumgjE9phSIaFrK0Yj6YwcqC56Wc8gKfG0Hl5IhqUMB9F PyqFvTxd/H0D/JMqIj8zxzlJQiBgudGwqxjZOo+WZ3//gEk4ZDMCFC+ODvGbXo+VESYW 7QkQE5DzGr5jQsX5bnYHGIRTwFrB8SKAKFrejtZLfdbHKMVN2SNAb+FhBhNG8pIW7q5I Oodfyp3xZMFm6yAoSB9ps3O5YWoeHpXyRa/30UpxUIN9NbSJVKaFluGf37IuXa36yaeB Z3jQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 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: APzg51CJEHajUubeIg6Nsx8ltPEz+p9uTK6XWzUdqPRyWDYizZdlViN9 i4x9LXpyj9ZYoXLwz2UIFW124Lm0YJMb2tzRMriB7aigF6nZrbmHL2Ezo4KL5g8AcfLEqDmG4DR 6uHlCvrArxF/KYiFxYTIx6jdffoDBPY9Z/UDOqhAB0DgKssh4Ds6kKUHEGFr5v4sf5A== X-Received: by 2002:a62:54c7:: with SMTP id i190-v6mr46774997pfb.155.1537542626342; Fri, 21 Sep 2018 08:10:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZT12X9DienIUFQRV9sX1d/aXdeWhGX/YVp29qgPkGhCN+QAmiaFq38msTLq0+VTMAJOhyj X-Received: by 2002:a62:54c7:: with SMTP id i190-v6mr46774928pfb.155.1537542625436; Fri, 21 Sep 2018 08:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542625; cv=none; d=google.com; s=arc-20160816; b=cYN7oteaih2HPvFtKR8ZAVqPW0nhibYTHs5yYOx3Vm/yf3dlzATWHl5SstqKjBdcb9 1723xfBZA5kuvHY58qr+tzKmt8zTsw04wE1nypAToclUvCd6RYIQ2efGneRua3lRW2vl x5IGV0jOYcTKKaXOJX2CgYIs9IRhbCgbiDA9hcvq45LUJ7QsTn/mOWmrOfDhlCSgJtyt E0X84+hhhOGVwVaHW5bOUxr5JpiOMWpHCPhKXycYLm9qDB9JIfnamCthN1OemUA0xjG1 WwSL7NoZAaZKU3B/LCNbRJK8wWj0cIbG2/tPVLuK/74gHsX6m3byuU9HAP69wF6LWbkS 1r9w== 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=+hAwkPRrWa1SdzA9lzXBTpLorf0142oXjZbO3utwlJg=; b=PqcR3dYgj6tuIe6jnHPLoHGV9QQ0E0bJu8Y1CDmeHsABXUjZmeQlkg+yVJwHEXo9M1 +WcKZmG/D/Qqre7fQINkX+Mb1zVNDoxgrD72jAINhVzR7jk4KyW/5/Sq9CdqitPeOVpx u6rKr0a4QxLhwbEowxXwufOFppMGytLZBJjEDOEL7IinPk9QTV2aqsH/EtdmJqj7QTam Tx9bbQH6OJAFmQ6lqwy5XLbDLmlWcwTCx5icEblxaumaokSEBTgWSNw1punFLF9/fjyO +xZnTndANYExTPJZOJuxqu7Dq+cfFnXD1hNaDxEHz8M7MJpi87f7yh6PtYFGg0K379qM tmcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id z3-v6si26822954pgh.557.2018.09.21.08.10.25 for <linux-mm@kvack.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Sep 2018 08:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 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 fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 08:10:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71856865" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 08:09:53 -0700 From: Yu-cheng Yu <yu-cheng.yu@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@amacapital.net>, Balbir Singh <bsingharora@gmail.com>, Cyrill Gorcunov <gorcunov@gmail.com>, Dave Hansen <dave.hansen@linux.intel.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>, "Ravi V. Shankar" <ravi.v.shankar@intel.com>, Vedvyas Shanbhogue <vedvyas.shanbhogue@intel.com> Cc: Yu-cheng Yu <yu-cheng.yu@intel.com> Subject: [RFC PATCH v4 23/27] mm/map: Add Shadow stack pages to memory accounting Date: Fri, 21 Sep 2018 08:03:47 -0700 Message-Id: <20180921150351.20898-24-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921150351.20898-1-yu-cheng.yu@intel.com> References: <20180921150351.20898-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: <linux-mm.kvack.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
Control Flow Enforcement: Shadow Stack
|
expand
|
On 9/21/18 8:03 AM, Yu-cheng Yu wrote: > Add shadow stack pages to memory accounting. > Also check if the system has enough memory before enabling CET. > > Signed-off-by: Yu-cheng Yu <yu-cheng.yu.intel.com> oops. typo above. > --- > mm/mmap.c | 5 +++++ > 1 file changed, 5 insertions(+)
On Fri, 2018-09-21 at 09:55 -0700, Randy Dunlap wrote: > On 9/21/18 8:03 AM, Yu-cheng Yu wrote: > > Add shadow stack pages to memory accounting. > > Also check if the system has enough memory before enabling CET. > > > > Signed-off-by: Yu-cheng Yu <yu-cheng.yu.intel.com> > > oops. typo above. > I will fix it. Thanks!
diff --git a/mm/mmap.c b/mm/mmap.c index 5f2b2b184c60..de2d0faa1c61 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1671,6 +1671,9 @@ static inline int accountable_mapping(struct file *file, vm_flags_t vm_flags) if (file && is_file_hugepages(file)) return 0; + if (arch_copy_pte_mapping(vm_flags)) + return 1; + return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE; } @@ -3261,6 +3264,8 @@ void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages) mm->stack_vm += npages; else if (is_data_mapping(flags)) mm->data_vm += npages; + else if (arch_copy_pte_mapping(flags)) + mm->data_vm += npages; } static vm_fault_t special_mapping_fault(struct vm_fault *vmf);
Add shadow stack pages to memory accounting. Also check if the system has enough memory before enabling CET. Signed-off-by: Yu-cheng Yu <yu-cheng.yu.intel.com> --- mm/mmap.c | 5 +++++ 1 file changed, 5 insertions(+)