Differences between revisions 1 and 2
|Deletions are marked like this.||Additions are marked like this.|
|Line 34:||Line 34:|
|||||||Fork a child to execute /bin/sh with argv="-" and HOME=/home/root||||||||||Fork a child to execute /bin/sh with argv="-" and HOME=/usr/root|||
Back to Kernel001WalkThrough.
This code is a conventional ANSI-C main program called from ThirtyTwoBitInitialization.
Linus' comment at the head of this program points out that "forking from kernel space will result in NO COPY ON WRITE (!!!), until an execve is executed. This is no problem, but for the stack. This is handled by not letting main() use the stack at all after fork(). Thus, no function calls - which means inline code for fork too, as otherwise we would use the stack upon exit from 'fork()'."