Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1423685
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 12/13] x86/mm/64: Enable vmapped stacks |
| Date | 2016-06-16 07:40 +0200 |
| Message-ID | <rKyc1-4gp-9@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> |
| Organization | linux.* mail to news gateway |
On Jun 15, 2016 9:32 PM, "Mika Penttilä" <mika.penttila@nextfour.com> wrote:
>
> Hi,
>
> > diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
> > index 5643fd0b1a7d..fbf036ae72ac 100644
> > --- a/arch/x86/mm/tlb.c
> > +++ 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.
--Andy
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