Call sys_clone according to Linux doc
Call sys_clone with 5 arguments and pass flags as unsigned long, as
specified by the Linux doc.
Bug: crbug.com/1022674
Test: Unit tests pass
Change-Id: Icdeec084192cc744843ddf623fb1c82ce6e3c92f
diff --git a/libminijail.c b/libminijail.c
index 6b697e7..8531c76 100644
--- a/libminijail.c
+++ b/libminijail.c
@@ -2815,23 +2815,23 @@
* case.
*/
if (pid_namespace) {
- int clone_flags = CLONE_NEWPID | SIGCHLD;
+ unsigned long clone_flags = CLONE_NEWPID | SIGCHLD;
if (j->flags.userns)
clone_flags |= CLONE_NEWUSER;
- child_pid = syscall(SYS_clone, clone_flags, NULL);
+
+ child_pid = syscall(SYS_clone, clone_flags, NULL, 0L, 0L, 0L);
+
+ if (child_pid < 0) {
+ if (errno == EPERM)
+ pdie("clone(CLONE_NEWPID | ...) failed with EPERM; "
+ "is this process missing CAP_SYS_ADMIN?");
+ pdie("clone(CLONE_NEWPID | ...) failed");
+ }
} else {
child_pid = fork();
- }
- if (child_pid < 0) {
- if (use_preload) {
- free(oldenv_copy);
- }
- if (pid_namespace && errno == EPERM) {
- warn("clone(CLONE_NEWPID) failed with EPERM, maybe "
- "this process is not running with CAP_SYS_ADMIN?");
- }
- pdie("failed to fork child");
+ if (child_pid < 0)
+ pdie("fork failed");
}
if (child_pid) {