Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752852AbdHOQKB (ORCPT ); Tue, 15 Aug 2017 12:10:01 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:36871 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752563AbdHOQJ6 (ORCPT ); Tue, 15 Aug 2017 12:09:58 -0400 MIME-Version: 1.0 In-Reply-To: <1502801449-29246-3-git-send-email-mark.rutland@arm.com> References: <1502801449-29246-1-git-send-email-mark.rutland@arm.com> <1502801449-29246-3-git-send-email-mark.rutland@arm.com> From: Andy Lutomirski Date: Tue, 15 Aug 2017 09:09:36 -0700 Message-ID: Subject: Re: [PATCHv2 02/14] fork: allow arch-override of VMAP stack alignment To: Mark Rutland Cc: "linux-arm-kernel@lists.infradead.org" , Ard Biesheuvel , Catalin Marinas , James Morse , Laura Abbott , "linux-kernel@vger.kernel.org" , Matt Fleming , Will Deacon , "kernel-hardening@lists.openwall.com" , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1806 Lines: 52 On Tue, Aug 15, 2017 at 5:50 AM, Mark Rutland wrote: > 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. This looks okay, but it might make sense to move that to a header file so THREAD_ALIGN is always available. > > 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(-) > > 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, > -- > 1.9.1 > -- Andy Lutomirski AMA Capital Management, LLC