From: Mark Rutland <mark.rutland@arm.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Catalin Marinas <catalin.marinas@arm.com>,
James Morse <james.morse@arm.com>,
Laura Abbott <labbott@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Matt Fleming <matt@codeblueprint.co.uk>,
Will Deacon <will.deacon@arm.com>,
"kernel-hardening@lists.openwall.com"
<kernel-hardening@lists.openwall.com>,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCHv2 02/14] fork: allow arch-override of VMAP stack alignment
Date: Tue, 15 Aug 2017 17:30:36 +0100 [thread overview]
Message-ID: <20170815163036.GJ6090@leverpostej> (raw)
In-Reply-To: <CALCETrWAYvKTcgaQgEDC-ihhSuFAw9Phq-xF6FK5AMM6ag6j4A@mail.gmail.com>
On Tue, Aug 15, 2017 at 09:09:36AM -0700, Andy Lutomirski wrote:
> On Tue, Aug 15, 2017 at 5:50 AM, Mark Rutland <mark.rutland@arm.com> 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.
I was a little worried about breaking things, since arches don't define
THREAD_SIZE in a consistent location.
Looking again, it looks like those are all transitiviely included into
each arch's <asm/thread_info.h>, so I think I can move this into
<linux/thread_info.h>, which'll have to be added to kernel.fork.c's
includes.
Are you happy with the below fixup?
Thanks,
Mark.
---->8----
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 250a276..905d769 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -38,6 +38,10 @@ enum {
#ifdef __KERNEL__
+#ifndef THREAD_ALIGN
+#define THREAD_ALIGN THREAD_SIZE
+#endif
+
#ifdef CONFIG_DEBUG_STACK_USAGE
# define THREADINFO_GFP (GFP_KERNEL_ACCOUNT | __GFP_NOTRACK | \
__GFP_ZERO)
diff --git a/kernel/fork.c b/kernel/fork.c
index 696d692..f12882a 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -88,6 +88,7 @@
#include <linux/sysctl.h>
#include <linux/kcov.h>
#include <linux/livepatch.h>
+#include <linux/thread_info.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@@ -217,9 +218,6 @@ static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
return s->addr;
}
-#ifndef THREAD_ALIGN
-#define THREAD_ALIGN THREAD_SIZE
-#endif
stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN,
VMALLOC_START, VMALLOC_END,
THREADINFO_GFP,
next prev parent reply other threads:[~2017-08-15 16:31 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-15 12:50 [PATCHv2 00/14] arm64: VMAP_STACK support Mark Rutland
2017-08-15 12:50 ` [PATCHv2 01/14] arm64: remove __die()'s stack dump Mark Rutland
2017-08-15 12:50 ` [PATCHv2 02/14] fork: allow arch-override of VMAP stack alignment Mark Rutland
2017-08-15 16:09 ` Andy Lutomirski
2017-08-15 16:30 ` Mark Rutland [this message]
2017-08-15 16:33 ` Andy Lutomirski
2017-08-15 16:39 ` Mark Rutland
2017-08-15 17:02 ` Catalin Marinas
2017-08-15 12:50 ` [PATCHv2 03/14] arm64: kernel: remove {THREAD,IRQ_STACK}_START_SP Mark Rutland
2017-08-15 12:50 ` [PATCHv2 04/14] arm64: factor out PAGE_* and CONT_* definitions Mark Rutland
2017-08-15 12:50 ` [PATCHv2 05/14] arm64: clean up THREAD_* definitions Mark Rutland
2017-08-15 12:50 ` [PATCHv2 06/14] arm64: clean up irq stack definitions Mark Rutland
2017-08-15 12:50 ` [PATCHv2 07/14] arm64: move SEGMENT_ALIGN to <asm/memory.h> Mark Rutland
2017-08-15 12:50 ` [PATCHv2 08/14] efi/arm64: add EFI_KIMG_ALIGN Mark Rutland
2017-08-15 12:50 ` [PATCHv2 09/14] arm64: factor out entry stack manipulation Mark Rutland
2017-08-15 12:50 ` [PATCHv2 10/14] arm64: assembler: allow adr_this_cpu to use the stack pointer Mark Rutland
2017-08-15 12:50 ` [PATCHv2 11/14] arm64: use an irq " Mark Rutland
2017-08-15 12:50 ` [PATCHv2 12/14] arm64: add basic VMAP_STACK support Mark Rutland
2017-08-15 12:50 ` [PATCHv2 13/14] arm64: add on_accessible_stack() Mark Rutland
2017-08-15 12:50 ` [PATCHv2 14/14] arm64: add VMAP_STACK overflow detection Mark Rutland
2017-08-15 14:00 ` [PATCHv2 00/14] arm64: VMAP_STACK support Will Deacon
2017-08-15 17:18 ` Laura Abbott
2017-08-15 17:39 ` Mark Rutland
2017-08-15 17:44 ` Catalin Marinas
2017-08-15 18:15 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170815163036.GJ6090@leverpostej \
--to=mark.rutland@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=labbott@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=matt@codeblueprint.co.uk \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox