Reputation: 234
What happens when I call clone system call by passing 0 as the stack_start?
According to manual pages on clone it should return -EINVAL
, but when I do that, it is showing SIGSEGV (11)
error.
clone(func,NULL,0,args);
should return -EINVAL, but its failing with SIGSEGV
Upvotes: 2
Views: 1705
Reputation: 4024
According to linux kernel there is such a call chain:
sys_clone(...stack_start...) -> do_fork
do_fork(...stack_start...) -> copy_process
copy_process(...stack_start...) -> copy_thread
copy_thread(...stack_start...) on X86_32 OR copy_thread(...stack_start...) on X86_64
Looking at the copy_thread
leads me to assumption that as this function doesn't check for stack_start
correctness (sp argument in code) so after cloning we have a task with invalid stack pointer and first reference at zero address leads to SIGSEGV
.
I'll suggest you to look at the glibc wrapper for clone function also.
Upvotes: 1