|
Message-ID: <CALCETrWLAS4sSmN4ejVhK3vDsqNEQEh3RU5ps1iXtAoighaYsw@mail.gmail.com> Date: Tue, 21 Jun 2016 10:28:05 -0700 From: Andy Lutomirski <luto@...capital.net> To: Kees Cook <keescook@...omium.org> Cc: Jann Horn <jannh@...gle.com>, Andy Lutomirski <luto@...nel.org>, X86 ML <x86@...nel.org>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, linux-arch <linux-arch@...r.kernel.org>, Borislav Petkov <bp@...en8.de>, Nadav Amit <nadav.amit@...il.com>, Brian Gerst <brgerst@...il.com>, "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>, Linus Torvalds <torvalds@...ux-foundation.org>, Josh Poimboeuf <jpoimboe@...hat.com>, Jann Horn <jann@...jh.net>, Heiko Carstens <heiko.carstens@...ibm.com> Subject: Re: [PATCH v3 06/13] fork: Add generic vmalloced stack support On Tue, Jun 21, 2016 at 10:13 AM, Kees Cook <keescook@...omium.org> wrote: > On Tue, Jun 21, 2016 at 9:59 AM, Andy Lutomirski <luto@...capital.net> wrote: >> On Tue, Jun 21, 2016 at 12:30 AM, Jann Horn <jannh@...gle.com> wrote: >>> On Tue, Jun 21, 2016 at 1:43 AM, Andy Lutomirski <luto@...nel.org> wrote: >>>> If CONFIG_VMAP_STACK is selected, kernel stacks are allocated with >>>> vmalloc_node. >>> [...] >>>> static struct thread_info *alloc_thread_info_node(struct task_struct *tsk, >>>> int node) >>>> { >>>> +#ifdef CONFIG_VMAP_STACK >>>> + struct thread_info *ti = __vmalloc_node_range( >>>> + THREAD_SIZE, THREAD_SIZE, VMALLOC_START, VMALLOC_END, >>>> + THREADINFO_GFP | __GFP_HIGHMEM, PAGE_KERNEL, >>>> + 0, node, __builtin_return_address(0)); >>>> + >>> >>> After spender gave some hints on IRC about the guard pages not working >>> reliably, I decided to have a closer look at this. As far as I can >>> tell, the idea is that __vmalloc_node_range() automatically adds guard >>> pages unless the VM_NO_GUARD flag is specified. However, those guard >>> pages are *behind* allocations, not in front of them, while a stack >>> guard primarily needs to be in front of the allocation. This wouldn't >>> matter if all allocations in the vmalloc area had guard pages behind >>> them, but if someone first does some data allocation with VM_NO_GUARD >>> and then a stack allocation directly behind that, there won't be a >>> guard between the data allocation and the stack allocation. >> >> I'm tempted to explicitly disallow VM_NO_GUARD in the vmalloc range. >> It has no in-tree users for non-fixed addresses right now. > > What about the lack of pre-range guard page? That seems like a > critical feature for this. :) > Agreed. There's a big va hole there on x86_64, but I don't know about other arches. It might pay to add something to the vmalloc core code. Any volunteers? > -Kees > > -- > Kees Cook > Chrome OS & Brillo Security -- Andy Lutomirski AMA Capital Management, LLC
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.