However, you should always be able to tell from the Oops output if you've suffered a stack overrun - that's the case if the stack pointer is below task->stack. Of course this won't trigger on all stack overruns, only the ones that clobber the stack canary. In the page fault handler, if a fault in kernel space occurs this canary is checked - see for example the x86 fault handler which prints the message Thread overran stack, or stack corrupted after the Oops message if the stack canary has been clobbered. The kernel does check for kernel stack overflows, by placing a canary value STACK_END_MAGIC at the end of the stack. The stack pointer in the struct task_struct is updated in dup_task_struct(), which is called as part of cloning a thread. The stacks are allocated in alloc_thread_stack_node(). These thread stacks are THREADSIZE (2PAGESIZE) big. Like all other architectures, x8664 has a kernel stack for every active thread. Most of the text from Keith Owens, hacked by AK. When kernel services are invoked in the current process context, they need to validate the process’s prerogative before it commits to any relevant operations. The code is really the best documentation - for example, the THREAD_SIZE macro defines the (architecture-dependent) per-thread kernel stack size. Kernel Stacks The Linux Kernel documentation. The kernel stack by default is 8kb for x86-32 and most other 32-bit systems (with an option of 4k kernel stack to be configured during kernel build), and 16kb on an x86-64 system. The reason that documentation is scarce is that it's an area that's quite architecture-dependent.
0 Comments
Leave a Reply. |