Re: kernel stack torture

David S. Miller (davem@caip.rutgers.edu)
Fri, 16 Feb 1996 03:07:59 -0500


From: "Ulrich Windl" <Ulrich.Windl@rz.uni-regensburg.de>
Date: Fri, 16 Feb 1996 09:00:13 +0100

> Yes, growing the stack would be really neat. It would require
> implementing a unmapped page before each and every stack page, I

Isn't the stack for i386 located in the stack segment which has its
own size limit. I imagine that a stack overflow will be detected by
hardware (i886), causes a trap, and then the stack grows. This would
require that the kernel uses virtual addresses. I'm not sure about
this.

I haven't checked but it would depend on how Linus sets the stack
segment register while in kernel mode. Basically on the sparc I
allocate a chunk of kernel vmspace for task structs and kernel stacks,
each bucket looks like:

entry[0] --> one page for task_struct
--> unmapped page for kstack redzone
--> two pages for kernel_stack_page

and this works out pretty nicely.

Later,
David S. Miller
davem@caip.rutgers.edu