Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1424040
| From | Rik van Riel <riel@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [kernel-hardening] Re: [PATCH 12/13] x86/mm/64: Enable vmapped stacks |
| Date | 2016-06-16 15:20 +0200 |
| Message-ID | <rKFnb-pe-3@gated-at.bofh.it> (permalink) |
| References | <rKtm1-1aF-3@gated-at.bofh.it> <rKtm2-1aF-33@gated-at.bofh.it> <rKyc1-4gp-11@gated-at.bofh.it> <rKyc1-4gp-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On Wed, 2016-06-15 at 22:33 -0700, Andy Lutomirski wrote:
>
> > > +++ b/arch/x86/mm/tlb.c
> > > @@ -77,10 +77,25 @@ void switch_mm_irqs_off(struct mm_struct
> > > *prev, struct mm_struct *next,
> > > unsigned cpu = smp_processor_id();
> > >
> > > if (likely(prev != next)) {
> > > + if (IS_ENABLED(CONFIG_VMAP_STACK)) {
> > > + /*
> > > + * If our current stack is in vmalloc space
> > > and isn't
> > > + * mapped in the new pgd, we'll double-
> > > fault. Forcibly
> > > + * map it.
> > > + */
> > > + unsigned int stack_pgd_index =
> > > + pgd_index(current_stack_pointer());
> >
> > stack pointer is still the previous task's, current_stack_pointer()
> > returns that, not
> > next task's which was intention I guess. Things may happen to work
> > if on same pgd, but at least the
> > boot cpu init_task_struct is special.
> This is intentional. When switching processes, we first switch the
> mm
> and then switch the task. We need to make sure that the prev stack
> is
> mapped in the new mm or we'll double-fault and die after switching
> the
> mm which still trying to execute on the old stack.
>
> The change to switch_to makes sure that the new stack is mapped.
>
On a HARDENED_USERCOPY tangential note: by not allowing
copy_to/from_user access to vmalloc memory by default,
with exception of the stack, a task will only be able
to copy_to/from_user from its own stack, not another task's
stack, at least using the kernel virtual address the
kernel uses to access that stack.
This can be accomplished by simply not adding any vmalloc
checking code to the current HARDENED_USERCOPY patch set :)
--
All rights reversed
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:30 +0200
[PATCH 01/13] x86/mm/hotplug: Don't remove PGD entries in remove_pagetable() Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:30 +0200
[PATCH 12/13] x86/mm/64: Enable vmapped stacks Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:30 +0200
Re: [PATCH 12/13] x86/mm/64: Enable vmapped stacks Andy Lutomirski <luto@amacapital.net> - 2016-06-16 07:40 +0200
Re: [kernel-hardening] Re: [PATCH 12/13] x86/mm/64: Enable vmapped stacks Rik van Riel <riel@redhat.com> - 2016-06-16 15:20 +0200
[PATCH 03/13] x86/cpa: Warn if kernel_unmap_pages_in_pgd is used inappropriately Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:30 +0200
[PATCH 08/13] x86/dumpstack: When OOPSing, rewind the stack before do_exit Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:40 +0200
Re: [PATCH 08/13] x86/dumpstack: When OOPSing, rewind the stack before do_exit Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-16 20:00 +0200
Re: [PATCH 08/13] x86/dumpstack: When OOPSing, rewind the stack before do_exit Andy Lutomirski <luto@amacapital.net> - 2016-06-16 20:00 +0200
[PATCH 02/13] x86/cpa: In populate_pgd, don't set the pgd entry until it's populated Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:40 +0200
[PATCH 06/13] fork: Add generic vmalloced stack support Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:40 +0200
Re: [PATCH 06/13] fork: Add generic vmalloced stack support Kees Cook <keescook@chromium.org> - 2016-06-16 19:30 +0200
Re: [PATCH 06/13] fork: Add generic vmalloced stack support Andy Lutomirski <luto@amacapital.net> - 2016-06-16 19:40 +0200
[PATCH 07/13] x86/die: Don't try to recover from an OOPS on a non-default stack Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:40 +0200
[PATCH 10/13] x86/dumpstack: Try harder to get a call trace on stack overflow Andy Lutomirski <luto@kernel.org> - 2016-06-16 02:40 +0200
Re: [PATCH 10/13] x86/dumpstack: Try harder to get a call trace on stack overflow Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-16 20:20 +0200
Re: [PATCH 10/13] x86/dumpstack: Try harder to get a call trace on stack overflow Andy Lutomirski <luto@amacapital.net> - 2016-06-16 20:30 +0200
Re: [PATCH 10/13] x86/dumpstack: Try harder to get a call trace on stack overflow Andy Lutomirski <luto@amacapital.net> - 2016-06-16 20:40 +0200
Re: [PATCH 10/13] x86/dumpstack: Try harder to get a call trace on stack overflow Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-16 21:00 +0200
Re: [PATCH 10/13] x86/dumpstack: Try harder to get a call trace on stack overflow Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-16 20:40 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-06-16 08:10 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Andy Lutomirski <luto@amacapital.net> - 2016-06-16 20:00 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Andy Lutomirski <luto@amacapital.net> - 2016-06-16 20:20 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Andy Lutomirski <luto@amacapital.net> - 2016-06-16 23:30 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Andy Lutomirski <luto@amacapital.net> - 2016-06-17 06:00 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-06-17 09:30 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Andy Lutomirski <luto@amacapital.net> - 2016-06-17 19:40 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-06-20 08:00 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Andy Lutomirski <luto@amacapital.net> - 2016-06-20 08:10 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-06-20 09:40 +0200
Re: [PATCH 00/13] Virtually mapped stacks with guard pages (x86, core) Kees Cook <keescook@chromium.org> - 2016-06-16 19:30 +0200
csiph-web