From patchwork Mon Aug 7 18:35:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 109583 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1952159qge; Mon, 7 Aug 2017 11:37:56 -0700 (PDT) X-Received: by 10.98.194.88 with SMTP id l85mr1583347pfg.252.1502131076643; Mon, 07 Aug 2017 11:37:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502131076; cv=none; d=google.com; s=arc-20160816; b=jgcpQPU7H1OYXz6a3CIU7vKt4CnzGv0bVfag306kFhOL5iFt94pmuIVOe+mMm5XO+/ 9HSrtaHWuPtO18KtJISb6RKjapkiIBOWGo68nrrEgaUiyN1qUaQ1AbLyQILbrgx4P6nw dnaJVaDmKDEUdinuTz1k4HYbzblZFjrtRgrSzwzcQy7pPQnB0prSwZRbuRVJIPhyDZz4 3B1YFqNNP3/f1GJ2AEr0KALVa0OuW74c1gMqh7YFgAcuVjJTyQ+O3v7Dig60Gc8C3A3i IJfRVLtZQ9yJconGtci0gd2fuQKeyIdsr3gzNhbStyIkU8VKCUHYyEM3MzANqJAE0ScG Ut+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=F463WU8StH6ifPP6iNkZUVzkM6XvhR43pwP5TFXKUtw=; b=MD1NSp2Mvf/k+QdZv3UpL695+BnRsx9mCxofSCzfTDKfQm+OuEJNrt/dUVlg8SOC6F CI3rfX9VnquzQkZNK+zn7lNfYX3vPTtoFMkSLrV9cwCu4zbdt5pvl6mvPvriccPY3Rry 6sdN8Fn6dE+FcKPz24uWFVvAIbcR9CUxkAcQBMoMDNjra7lH0W2XXXlQna6iUieRdibB c53o+bXBcv2FyhRTa8TiQKeMdQnlWoKQpb/T4ep0QQDzIm4aVrnTRVm6gXIbTtMHClga E93I17K0yMB5aVOreHRUV9xecKlBgZD+Ibickq2lk2HmH7gIcjpv4KlCz6kFKV4/RSfH kUXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si3174992pfb.161.2017.08.07.11.37.56; Mon, 07 Aug 2017 11:37:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752009AbdHGShx (ORCPT + 25 others); Mon, 7 Aug 2017 14:37:53 -0400 Received: from foss.arm.com ([217.140.101.70]:52506 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508AbdHGShw (ORCPT ); Mon, 7 Aug 2017 14:37:52 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 633E015BE; Mon, 7 Aug 2017 11:37:52 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 508AA3F577; Mon, 7 Aug 2017 11:37:50 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: ard.biesheuvel@linaro.org, catalin.marinas@arm.com, james.morse@arm.com, labbott@redhat.com, linux-kernel@vger.kernel.org, luto@amacapital.net, mark.rutland@arm.com, matt@codeblueprint.co.uk, will.deacon@arm.com, kernel-hardening@lists.openwall.com, keescook@chromium.org Subject: [PATCH 02/14] fork: allow arch-override of VMAP stack alignment Date: Mon, 7 Aug 2017 19:35:53 +0100 Message-Id: <1502130965-18710-3-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502130965-18710-1-git-send-email-mark.rutland@arm.com> References: <1502130965-18710-1-git-send-email-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some cases, an architecture might wish its stacks to be aligned to a boundary larger than THREAD_SIZE. For example, using an alignment of double THREAD_SIZE can allow for stack overflows smaller than THREAD_SIZE to be detected by checking a single bit of the stack pointer. This patch allows architectures to override the alignment of VMAP'd stacks, by defining THREAD_ALIGN. Where not defined, this defaults to THREAD_SIZE, as is the case today. Signed-off-by: Mark Rutland Cc: Andy Lutomirski Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: James Morse Cc: Laura Abbott Cc: Will Deacon Cc: linux-kernel@vger.kernel.org --- kernel/fork.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/kernel/fork.c b/kernel/fork.c index 17921b0..696d692 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -217,7 +217,10 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node) return s->addr; } - stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE, +#ifndef THREAD_ALIGN +#define THREAD_ALIGN THREAD_SIZE +#endif + stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN, VMALLOC_START, VMALLOC_END, THREADINFO_GFP, PAGE_KERNEL,