LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Question about kernel stack (https://www.linuxquestions.org/questions/linux-kernel-70/question-about-kernel-stack-4175459499/)

saurin 04-24-2013 09:49 PM

Question about kernel stack
 
linux kernel maintains the stack for each user-space process as well as kernel level thread(in kernel space), but not sure if kernel also maintains the stack for the user level thread, would somebody help me to understand this?

sundialsvcs 04-25-2013 08:10 AM

The user-process stack is in virtual memory, and in any case it is not to be trusted. When the system enters kernel mode, the stack-pointer is switched to a kernel stack for the duration of the call. (The successful execution of a kernel request must not depend in any way upon the user environment: the kernel operates in a "known-good," trustworthy state which the user cannot tamper with.)

Part of the procedure for switching from user-mode to kernel-mode is to preserve all of the values in the CPU registers, including the user-process stack pointer. The kernel has ready access to these values, which will be restored when the system transitions back into user-mode.

The kernel can retrieve information from the user-process stack as it sees fit, but the user-process cannot access the kernel stack area.


All times are GMT -5. The time now is 01:18 PM.