Skip to main content
Expand on the purpose.
Source Link
Stephen Kitt
  • 482.8k
  • 60
  • 1.2k
  • 1.4k

The required stack argument goes hand-in-hand with the fn argument. The raw kernel syscall doesn’t always need a stack because it behaves like fork: execution in the child starts at the return of the system call. The libc wrapper then needs to set things up to call fn, and to do so, it needs the stack (and has always done so).

As a result, a stack is always required when calling the wrapper, to pass information across the clone system call to the code which calls the fn function (thread_start in the glibc code).

The required stack argument goes hand-in-hand with the fn argument. The raw kernel syscall doesn’t always need a stack because it behaves like fork: execution in the child starts at the return of the system call. The libc wrapper then needs to set things up to call fn, and to do so, it needs the stack (and has always done so).

As a result, a stack is always required when calling the wrapper.

The required stack argument goes hand-in-hand with the fn argument. The raw kernel syscall doesn’t always need a stack because it behaves like fork: execution in the child starts at the return of the system call. The libc wrapper then needs to set things up to call fn, and to do so, it needs the stack (and has always done so).

As a result, a stack is always required when calling the wrapper, to pass information across the clone system call to the code which calls the fn function (thread_start in the glibc code).

Source Link
Stephen Kitt
  • 482.8k
  • 60
  • 1.2k
  • 1.4k

The required stack argument goes hand-in-hand with the fn argument. The raw kernel syscall doesn’t always need a stack because it behaves like fork: execution in the child starts at the return of the system call. The libc wrapper then needs to set things up to call fn, and to do so, it needs the stack (and has always done so).

As a result, a stack is always required when calling the wrapper.