From patchwork Thu Feb 9 04:03:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9564001 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 235B46020C for ; Thu, 9 Feb 2017 04:05:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 871F1284EB for ; Thu, 9 Feb 2017 04:05:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 788C228509; Thu, 9 Feb 2017 04:05:32 +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 86646284EB for ; Thu, 9 Feb 2017 04:05:31 +0000 (UTC) Received: (qmail 7581 invoked by uid 550); 9 Feb 2017 04:05:30 -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 7561 invoked from network); 9 Feb 2017 04:05:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DGu77UZ9QQ43txXQLZcfMkjnhQBVtJ8maNYb6q5GA6c=; b=IbDf+pqYsmuWyESIOsoai88MtyQ/mN9ZfF5vU/Tg3uZeqtD3aH9swv2EfVJkTdVHJ+ 3uZ+0H7rKoNCHPbmO/MJMHekNHw7/Hl+21mT9f81e77AdegHMtb+TxupR/74R+49Of0S amE8BIEObeLK90lrj2+sfanHZo3Uhh7YZDQifajxgNAS1xnUZs+q1qMVCNXzbygYomZq 6/QZZBJRJSmmelr0++5OK+oVJuXkjsCUb65hVj5Jfix6UQrzTzBdPqQYRTqlzdbuagSP 06bEWRY5iU/70Fgdw63q8A4JdgB/E2AMFKx+08mtes/b331BUzVmjlzIjKCkRRBS1/3c mpXQ== 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:in-reply-to :references; bh=DGu77UZ9QQ43txXQLZcfMkjnhQBVtJ8maNYb6q5GA6c=; b=U0CeYKoFG/6kEu63prjjqTe17N+zcFdCPEc6oCSFrMx7y4UixiRPmg7p18/VrKfncD RNJnLtNfO0QyQZhZ/rGm3v9C4riInzEIXFD2o/p4TaFxO6PXWWByXspKUakkmCBjIGEx IKuWb6QeMyq2Wei5qaSyKm2ZQZMmfmhJ+g3/O2waieW1LQY70jWl0Umcb25YMuwndp31 T4SUbjsEWQS6onv7MhWYvMmac/uYLf0+Dtw39+tCeKF58vL22DJMjMB+BzQJM6CA6tAR 4SR0AB/NLjGW/o4e9H3TCgMt3VcOqhPTCWeX6h5zn2VdmxB6RVFnUYn3XyTXRyadQTeG OSSA== X-Gm-Message-State: AMke39m9O3Gvn1cdP6p0Yeb1YmDV7WFKiH7OyoVoP8vj21HB3+wEhTiZQw/CG/3eTxNsvg== X-Received: by 10.98.69.139 with SMTP id n11mr1293622pfi.65.1486613117639; Wed, 08 Feb 2017 20:05:17 -0800 (PST) From: Hoeun Ryu To: Kees Cook , Michal Marek , Andrew Morton , Emese Revfy , Ingo Molnar , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Nicholas Piggin , Andy Lutomirski , Michal Hocko , "Eric W. Biederman" , Mateusz Guzik Cc: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Hoeun Ryu Date: Thu, 9 Feb 2017 13:03:47 +0900 Message-Id: <1486613040-30555-2-git-send-email-hoeun.ryu@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486613040-30555-1-git-send-email-hoeun.ryu@gmail.com> References: <1486613040-30555-1-git-send-email-hoeun.ryu@gmail.com> Subject: [kernel-hardening] [PATCH v2 2/2] 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..066d111 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 7911ed2..73ba1da 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 static DEFINE_PER_CPU(struct vm_struct *, cached_stacks[NR_CACHED_STACKS]); #endif