Description of problem: The syscall() system call using the __NR_clone parameter as an alternative to clone(), does not accept any stack pointer size larger than zero. According to various documents, the user application is supposed to allocate memory for the child's stack pointer when using the CLONE_NEWNS flag. However, a segfault occurs and shows up in /var/log/messages reqardless of the size of the child's stack pointer. I have tried the following, without success: #define CHILD_STACK_MEM 65536 pid = syscall(__NR_clone, flags, cstack); pid = syscall(__NR_clone, flags, cstack+CHILD_STACK_MEM); Version-Release number of selected component (if applicable): RHEL 5.0 + 5.1 How reproducible: This is easily reproduced with a simple program included here. Usage is <progname> newns #include "includes.h" #include <sched.h> #define CHILD_STACK_MEM 65536 int main(int argc, char **argv) { int exitval, result; int flags = CLONE_VFORK; char *cstack; pid_t pid; if (argc != 2) { fprintf(stderr, "Usage:\n%s <flag>\n", argv[0]); return TEST_ERROR; } if (!strcmp(argv[1], "newns")) { flags |= CLONE_NEWNS; } else { fprintf(stderr, "Usage:\n%s: unknown flag: %s\n", argv[0], argv[1]); return TEST_ERROR; } cstack = malloc(CHILD_STACK_MEM); if (!cstack) { perror("do_clone: malloc"); return TEST_ERROR; } /* use syscall() to force clone over clone2 */ errno = 0; pid = syscall(__NR_clone, flags, cstack); /* child */ if (pid == 0) _exit(0); /* parent */ free(cstack); exitval = pid; result = exitval < 0; printf("%d %d %d\n", result, result ? errno : exitval, getpid()); return result; } Steps to Reproduce: 1. Compile and use the program included above. 2. Usage is: <progname> newns 3. Check /var/log/messages for the segfault. Actual results: Segfault in /var/logs/messages Expected results: No segfault Additional info:
Jon, please try to reproduce it in RHEL5.2. I didn't get segfault in kernel-2.6.18-92.1.1 /me looking how the __NR_clone stuff implemented...