From patchwork Tue Aug 15 12:50:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 110144 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5439181obb; Tue, 15 Aug 2017 05:52:41 -0700 (PDT) X-Received: by 10.99.122.94 with SMTP id j30mr27176922pgn.188.1502801561552; Tue, 15 Aug 2017 05:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502801561; cv=none; d=google.com; s=arc-20160816; b=opiRAzkTrAMY1bwnwmQgeZn9I6KukKJb5w8mx5TTch9DjbK+1RYLgysKK++5D2d/ki 0eg2J9fxFwPUWq3YcxdS3YUwOt1zojMy0KLeFUXVdfdE3L8xgCNFoxrLP0KeHHNA2yn2 MtGjhdWiGHZRmdfEpgB6KBYclm7oRbnijL4VCssjpYZ7i12dDmccfk8aMZ5eAjj89Y2w kvkrPBnvkrv260xuZa7KPKiqut58l65umv37vv9iUeYRiBkDVYqpfdf4z1Ps4NZZUSDF e26QWl49vU18SFOee/CAc5z/3guvfnivwcmaGhNegsYnQlPvEnxMHAkdTrx9I0opLVKl vcKA== 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=bIgkSG8jbIREvOpxhyHX1vbDDCDBjHKy7q7lejoVxnNHhpsMV0MEFg2zISIxVNnNYw a0UC5KMIet2iLYV0tYgzNew1DgJ7XxyUmkhpWYVHwNm11TjfPY2Ae1xQ1XTttfq6QQGY U9xQeLnlWjvGlrqVR79SmRLIYxgYjf7i1h5TIQGnOY50r0Q3gV8LBgYqspQpuskQ61Ge D2Oy6dyUVy3HIVegAWqzJLbYl5Q6Gv88lLKl6KkU3IRQBtiTjmczy1ea98kl9YVyeKGT FIuUrS7CIBpGYZ/XihjOAHL/hLliNL5/8bruiubaYqc6cmURomiKShjG27Lja6UtAwE1 bZww== 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 k10si6288545pln.658.2017.08.15.05.52.41; Tue, 15 Aug 2017 05:52:41 -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 S1752687AbdHOMwi (ORCPT + 25 others); Tue, 15 Aug 2017 08:52:38 -0400 Received: from foss.arm.com ([217.140.101.70]:51426 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752664AbdHOMwg (ORCPT ); Tue, 15 Aug 2017 08:52:36 -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 263031596; Tue, 15 Aug 2017 05:52:36 -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 13CBD3F540; Tue, 15 Aug 2017 05:52:33 -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: [PATCHv2 02/14] fork: allow arch-override of VMAP stack alignment Date: Tue, 15 Aug 2017 13:50:37 +0100 Message-Id: <1502801449-29246-3-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502801449-29246-1-git-send-email-mark.rutland@arm.com> References: <1502801449-29246-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,