MajorasKid
MajorasKid

Reputation: 873

Umount("/proc") syscall for mount namespaces "Invalid Argument" error

i'm currently trying to use different namespaces for test purposes. For this i tried to implement a MNT namespace (combined with a PID namespace) so that a program within this namespace cannot see other processes on the system.

When trying to use the umount system call like this (same goes with umount("/proc"), or with umount2 and the Force-option ):

  if (umount2("/proc", 0)!= 0) 
{
    fprintf(stderr, "Error when unmounting /proc: %s\n",strerror(errno));
    printf("\tKernel version might be incorrect\n");
    exit(-1);
}

the system call execution ends with error number 22 "Invalid Argument".

This code snipped is called within a function that gets called when a child process with the namespaces is created:

 pid_t child_pid = clone(child_exec, child_stack+1024*1024, Child_Flags,&args);

(the child_exec function). Flags are set as following:

int Child_Flags = CLONE_NEWIPC | CLONE_NEWUSER  | CLONE_NEWUTS | CLONE_NEWNET |CLONE_NEWPID |  CLONE_NEWNS |SIGCHLD  ;

With the CLONE_NEWNS for a new mount namespace (http://man7.org/linux/man-pages/man7/namespaces.7.html)

Output of the program is as follows:

Testing with Isolation
Starting Container engine
In-Child-PID: 1
Error number 22
Error when unmounting /proc: Invalid argument

Can somebody point me to my error, so i can unmount the folder? Thank you in advance

Upvotes: 0

Views: 1049

Answers (1)

Timothy Baldwin
Timothy Baldwin

Reputation: 3675

You can't unmount things that were mounted in a different user namespace except by using pivot_root followed by umount to unmount /. You can overmount /proc without unmounting the old /proc.

Upvotes: 0

Related Questions