From patchwork Fri Feb 3 15:33:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9554441 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 0D94660424 for ; Fri, 3 Feb 2017 15:41:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04ABB26E96 for ; Fri, 3 Feb 2017 15:41:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED91B27D13; Fri, 3 Feb 2017 15:41:46 +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 341FF26E96 for ; Fri, 3 Feb 2017 15:41:46 +0000 (UTC) Received: (qmail 23622 invoked by uid 550); 3 Feb 2017 15:41:44 -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 23593 invoked from network); 3 Feb 2017 15:41:43 -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=qXDAUSTcP2aq9eA7XKroAjnRvY+Nd1/ONNFwTNNtAQ0=; b=ck64peGWBi6pt2FGK1im2c8fD+4MsLzQj5tZ2drC872MGamIFLtjcvEpZkyiy7XsAx KND8SuMv5HFRCh0qZxQGd0nDyCq2uJWy40D0jZbbiA4pBotx7ETZEbmpavqpJy3nfZTA eEzFbIxfEQ2k6mIC5uGYHeozwut9o5WDB4BIlRs184BBnh4GveWSJ43cnomtNVXHzibm /BnUJaX4HQRIIZUVDaAtc8abl701gc2vnAKmk6r5cbaVX7WibpIKG2xwQ02+hyKJHocj ynSWeY5qwMTTPF2u2JHuQGeao3i9XQwDAzCodIkv4+vqCMyiCqwEzlu3vsdIC271crJ1 0gZA== 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=qXDAUSTcP2aq9eA7XKroAjnRvY+Nd1/ONNFwTNNtAQ0=; b=B6mPbY/Mzq1OSNC2G/fi9jhIUah52b2ZbjZ93M/mPWFnfy5hLSgOP0HRS6Hi0Mk7xt zNy66nq6snkXPhzH4O7E+hloV/Yt5vimrWzqWV1lPnNSdcnOkO2DvyMlZQaO20AsVswu obKIZk8KFg29fyY0CwM+I03e8SDPwYiJ2UQgLKW9HIQlxul+LUMviF4d4yuInGLUw/nu hRZ1aeidwhgkBCvcPs5JNcCHhSIQCZ5cWTk3K43Z49wdvN7dORvXbb+h7lcVhGGjn4TG L6BC6rwFrqNiJ3bpcsEVCzyrkd8sV1NNZncY4erXdJRB3LTZYbOVTnfDy5SJH+Xm8w6a sQ1g== X-Gm-Message-State: AIkVDXI4iQa2ULwNdswedjaKKbTZOKkNwXtbq/Jo/rxG7gAqDz596FoN4v6vOcrN4EVlBg== X-Received: by 10.84.213.151 with SMTP id g23mr21770521pli.43.1486136020221; Fri, 03 Feb 2017 07:33:40 -0800 (PST) From: Hoeun Ryu To: Andrew Morton , Michal Hocko , Ingo Molnar , Andy Lutomirski , Kees Cook , "Eric W. Biederman" , Mateusz Guzik Cc: linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Hoeun Ryu Date: Sat, 4 Feb 2017 00:33:21 +0900 Message-Id: <1486136013-27565-1-git-send-email-hoeun.ryu@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [kernel-hardening] [PATCH 3/3] fork: allocate vmapped kernel stacks for cache when a cpu is up X-Virus-Scanned: ClamAV using ClamSMTP when a cpu is up, predefined number of stacks are allocated and cached immediately. Signed-off-by: Hoeun Ryu --- kernel/fork.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/fork.c b/kernel/fork.c index 50de6cf..ee4067d 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -194,6 +194,21 @@ static int alloc_vm_stack_cache(unsigned int cpu) vm_stack_cache->cur = 0; vm_stack_cache->nr = 0; + for (i = 0; i < NR_CACHED_STACKS; i++) { + void *stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE, + VMALLOC_START, VMALLOC_END, + THREADINFO_GFP | __GFP_HIGHMEM, + PAGE_KERNEL, + 0, cpu_to_node(cpu), + __builtin_return_address(0)); + if (!stack) + return -ENOMEM; + + vm_stacks[i] = find_vm_area(stack); + vm_stack_cache->cur++; + vm_stack_cache->nr++; + } + return 0; }