From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751120AbdBCPjn (ORCPT ); Fri, 3 Feb 2017 10:39:43 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36060 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873AbdBCPjm (ORCPT ); Fri, 3 Feb 2017 10:39:42 -0500 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 Subject: [PATCH 2/3] fork: make number of cached stacks (vmapped) configurable using Kbuild 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.7.4