From patchwork Fri Feb 3 15:32:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9554437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A2EE60424 for ; Fri, 3 Feb 2017 15:40:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92BCC28425 for ; Fri, 3 Feb 2017 15:40:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83EF728428; Fri, 3 Feb 2017 15:40:12 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 8AE3B28425 for ; Fri, 3 Feb 2017 15:40:10 +0000 (UTC) Received: (qmail 20204 invoked by uid 550); 3 Feb 2017 15:40:09 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 20186 invoked from network); 3 Feb 2017 15:40:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fSPR5Ilf/T03SrXKnIqYrn9Db9dqyUgkgQno6hLATXo=; b=ITL1WYJcrP6tDlPlnU6qjoCcDWTWBozrJVAXuxyZaXBeNSsQonrOGqgjMKbApj5u12 7P4mMtN7YCQxzGZU4diuWWwgjOb6t4fZZKbRUleEeNXyYyk1FWHQfwse5uGh346Nfa5i mL7Lp2Ln+/+HoVHt3ECu94e8K6l7MC2HaeLAuRT8bmIvWyGy2YaSlCS9ckwjZaTh085e k2PFN8jdnohPOTyYtyD3VgZLBIOKQg1ZfWEQkajNjBxI5KVQTaf1BUWOPx1+BotYIAwR Kh85awZVSbnm35EVOTJGU8ncylZOiG58q2xsBVKdSCLBSmULakPhEX3hqRbxXPVQGGzH Xzmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fSPR5Ilf/T03SrXKnIqYrn9Db9dqyUgkgQno6hLATXo=; b=MWVT5ol8TIfWJp55lTTAXncU28zgin/+p91UUVm66itHP0wro047GpDTMCS6aPmhWk UNWKrt5GaTbJmNfIjSm2hOFMYPx5auNHi+mi3wpfRXVMsRYqzvrJPtTBQpSWlaNqta8/ XFvBPL2Uf7BwpoUfgqFFc+4qt8oS9mHNJa1rnVNjBTEDowlk2dgo4LuhOPZYq5y0lOi8 k7jOXMQEDgAMCC9kPOpvnMB3jmqK2JUW9g3GMZMtg2UQq/DoPSYDW1uGy/jt1ZPUaPmj Ty4vvjMUSbhO/0GNVV4M5oqHLoKkfObGGPuXn71s0BWxG1ZEFe1HubXlpv6RkBffavbN HnEw== X-Gm-Message-State: AIkVDXJ/gXJGwEi4rw+6X71uD8v+MXJnEOPyIu9KGb+W3nk5tirOuQkDr+G72LYR4KMj1g== X-Received: by 10.98.65.15 with SMTP id o15mr18542315pfa.42.1486135993950; Fri, 03 Feb 2017 07:33:13 -0800 (PST) From: Hoeun Ryu To: Kees Cook , Michal Marek , Andrew Morton , Emese Revfy , Nicholas Piggin , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Andy Lutomirski , Michal Hocko , Ingo Molnar , "Eric W. Biederman" , Mateusz Guzik Cc: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Hoeun Ryu Date: Sat, 4 Feb 2017 00:32:39 +0900 Message-Id: <1486135977-27444-1-git-send-email-hoeun.ryu@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [kernel-hardening] [PATCH 2/3] fork: make number of cached stacks (vmapped) configurable using Kbuild X-Virus-Scanned: ClamAV using ClamSMTP Introducing NR_VMAP_STACK_CACHE, the number of cached stacks for virtually mapped kernel stack can be configurable using Kbuild system. default value is 2. Signed-off-by: Hoeun Ryu --- arch/Kconfig | 8 ++++++++ kernel/fork.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/Kconfig b/arch/Kconfig index d49a8e6..e94c432 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -849,6 +849,14 @@ config VMAP_STACK the stack to map directly to the KASAN shadow map using a formula that is incorrect if the stack is in vmalloc space. +config NR_VMAP_STACK_CACHE + int "Number of cached stacks" + default "2" + depends on VMAP_STACK + ---help--- + This determines how many stacks can be cached for virtually + mapped kernel stacks. + config ARCH_WANT_RELAX_ORDER bool diff --git a/kernel/fork.c b/kernel/fork.c index 54421a9..50de6cf 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -166,7 +166,7 @@ void __weak arch_release_thread_stack(unsigned long *stack) * vmalloc() is a bit slow, and calling vfree() enough times will force a TLB * flush. Try to minimize the number of calls by caching stacks. */ -#define NR_CACHED_STACKS 2 +#define NR_CACHED_STACKS CONFIG_NR_VMAP_STACK_CACHE struct vm_stack_cache { struct vm_struct **vm_stacks;