User: Password:
|
|
Subscribe / Log in / New account

4k/8k stacks

4k/8k stacks

Posted May 8, 2008 23:12 UTC (Thu) by kbob (guest, #1770)
Parent article: The last things through the 2.6.26 merge window

I'm asking this from a position of ignorance -- I haven't looked at kernel code in a long
time.  But wouldn't it be possible to allocate 4k stacks with guard pages between them, thus
(a) saving memory and (b) generating a loud exception on stack overflow?

Or is there some kind of overhead in leaving holes into the kernel address space that I'm not
aware of?



(Log in to post comments)

4k/8k stacks

Posted May 9, 2008 0:48 UTC (Fri) by jmspeex (subscriber, #51639) [Link]

I believe we're talking non-virtual memory, so an overflow would just end up on the next
physical page with no way to detect it. Or maybe I'm just talking through my ass (I'm not a
kernel dev).

4k/8k stacks

Posted May 9, 2008 0:57 UTC (Fri) by corbet (editor, #1) [Link]

All memory is virtual memory when the kernel is running. But kernel-space addresses are a sort of special case, in that they are mapped as one big page using a single page table entry. So it's not possible to insert inaccessible guard pages after the kernel stacks - at least, not without dropping the big mapping, which would have a significant performance cost.

4k/8k stacks

Posted May 15, 2008 11:37 UTC (Thu) by cras (guest, #7000) [Link]

Maybe a small (32bit?) canary at the end of the stack would help a bit? Although if an
overflow 
happens I guess by the time it's noticed the kernel might have crashed already.


4k/8k stacks

Posted May 15, 2008 14:01 UTC (Thu) by mcortese (guest, #52099) [Link]

Kernel address space maps 1-to-1 to physical memory (at least for less than 1 GiB of RAM). The argument is 1 page vs. 2 pages of stack. Having just 1 page of stack plus 1 guard page just doesn't save anything.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds