linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Cartwright <joshc@ni.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: x86@kernel.org, Borislav Petkov <bp@alien8.de>,
	linux-kernel@vger.kernel.org, Brian Gerst <brgerst@gmail.com>,
	Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH v6 1/3] fork: Add generic vmalloced stack support
Date: Wed, 24 Aug 2016 11:51:02 -0500	[thread overview]
Message-ID: <20160824165102.GB22613@jcartwri.amer.corp.natinst.com> (raw)
In-Reply-To: <14c07d4fd173a5b117f51e8b939f9f4323e39899.1470907718.git.luto@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1816 bytes --]

Hey Andy-

Small non-critical/potential future optimization comment below:

On Thu, Aug 11, 2016 at 02:35:21AM -0700, Andy Lutomirski wrote:
> If CONFIG_VMAP_STACK is selected, kernel stacks are allocated with
> vmalloc_node.
> 
> grsecurity has had a similar feature (called
> GRKERNSEC_KSTACKOVERFLOW) for a long time.
> 
> Cc: Oleg Nesterov <oleg@redhat.com>
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
[..]
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 52e725d4a866..05f7ef796fb4 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -158,19 +158,39 @@ void __weak arch_release_thread_stack(unsigned long *stack)
>   * Allocate pages if THREAD_SIZE is >= PAGE_SIZE, otherwise use a
>   * kmemcache based allocator.
>   */
> -# if THREAD_SIZE >= PAGE_SIZE
> -static unsigned long *alloc_thread_stack_node(struct task_struct *tsk,
> -						  int node)
> +# if THREAD_SIZE >= PAGE_SIZE || defined(CONFIG_VMAP_STACK)
> +static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node)
>  {
> +#ifdef CONFIG_VMAP_STACK
> +	void *stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
> +					   VMALLOC_START, VMALLOC_END,
> +					   THREADINFO_GFP | __GFP_HIGHMEM,
> +					   PAGE_KERNEL,
> +					   0, node,
> +					   __builtin_return_address(0));
> +
> +	/*
> +	 * We can't call find_vm_area() in interrupt context, and
> +	 * free_thread_stack can be called in interrupt context, so cache
> +	 * the vm_struct.
> +	 */
> +	if (stack)
> +		tsk->stack_vm_area = find_vm_area(stack);

This is annoying, we end up having to walk the vm_area tree twice (once
for the allocation, then here to get a handle on area).

Perhaps it's time the vmalloc code learned an allocation API that
returned the vm_area handle as well.

  Josh

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  parent reply	other threads:[~2016-08-24 17:19 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11  9:35 [PATCH v6 0/3] virtually mapped stacks Andy Lutomirski
2016-08-11  9:35 ` [PATCH v6 1/3] fork: Add generic vmalloced stack support Andy Lutomirski
2016-08-15 11:55   ` Michal Hocko
2016-08-24 10:03   ` Ingo Molnar
2016-08-24 16:11     ` Dmitry Vyukov
2016-08-24 13:02   ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2016-08-24 16:51   ` Josh Cartwright [this message]
2016-08-30 22:01     ` [PATCH v6 1/3] " Andy Lutomirski
2016-08-30 22:26       ` Josh Cartwright
2016-08-11  9:35 ` [PATCH v6 2/3] dma-api: Teach the "DMA-from-stack" check about vmapped stacks Andy Lutomirski
2016-08-24 13:02   ` [tip:x86/asm] " tip-bot for Andy Lutomirski
2016-08-11  9:35 ` [PATCH v6 3/3] x86/mm/64: Enable " Andy Lutomirski
2016-08-24 13:03   ` [tip:x86/asm] x86/mm/64: Enable vmapped stacks (CONFIG_HAVE_ARCH_VMAP_STACK=y) tip-bot for Andy Lutomirski
2016-10-21 12:32     ` Matt Fleming
2016-10-22  0:18       ` Andy Lutomirski
2016-10-24 13:09         ` Matt Fleming
2016-10-30 16:21           ` Andy Lutomirski
2016-11-07 12:32             ` Matt Fleming
2016-08-20 18:06 ` [PATCH v6 0/3] virtually mapped stacks Andy Lutomirski
2016-08-24 10:12   ` Ingo Molnar
2016-08-24 15:27     ` Andy Lutomirski
2016-08-24 17:16       ` Ingo Molnar

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=20160824165102.GB22613@jcartwri.amer.corp.natinst.com \
    --to=joshc@ni.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=oleg@redhat.com \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).