Skip to content

Commit bc462c9

Browse files
author
Mrunal Patel
authored
Merge pull request #1165 from cyphar/nsenter-fix-comments
nsenter: fix up comments
2 parents 509b1db + 9b15bf1 commit bc462c9

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

libcontainer/nsenter/nsexec.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,17 @@ void nsexec(void)
447447
/*
448448
* Okay, so this is quite annoying.
449449
*
450-
* In order to make sure that deal with older kernels (when CLONE_NEWUSER
451-
* wasn't guaranteed to be done first if you specify multiple namespaces in
452-
* a clone(2) invocation) as well as with certain usecases like rootless
453-
* containers, we cannot just dump all of the cloneflags into clone(2).
450+
* In order for this unsharing code to be more extensible we need to split
451+
* up unshare(CLONE_NEWUSER) and clone() in various ways. The ideal case
452+
* would be if we did clone(CLONE_NEWUSER) and the other namespaces
453+
* separately, but because of SELinux issues we cannot really do that. But
454+
* we cannot just dump the namespace flags into clone(...) because several
455+
* usecases (such as rootless containers) require more granularity around
456+
* the namespace setup. In addition, some older kernels had issues where
457+
* CLONE_NEWUSER wasn't handled before other namespaces (but we cannot
458+
* handle this while also dealing with SELinux so we choose SELinux support
459+
* over broken kernel support).
460+
*
454461
* However, if we unshare(2) the user namespace *before* we clone(2), then
455462
* all hell breaks loose.
456463
*
@@ -623,9 +630,9 @@ void nsexec(void)
623630
* containers). But for now, it's not possible to split this into
624631
* CLONE_NEWUSER + [the rest] because of some RHEL SELinux issues.
625632
*
626-
* We also can't be sure if the current kernel supports
627-
* clone(CLONE_PARENT | CLONE_NEWPID), so we'll just do it the long
628-
* way anyway.
633+
* Note that we don't merge this with clone() because there were
634+
* some old kernel versions where clone(CLONE_PARENT | CLONE_NEWPID)
635+
* was broken, so we'll just do it the long way anyway.
629636
*/
630637
if (unshare(config.cloneflags) < 0)
631638
bail("failed to unshare namespaces");
@@ -701,7 +708,7 @@ void nsexec(void)
701708
syncfd = syncpipe[0];
702709

703710
/* For debugging. */
704-
prctl(PR_SET_NAME, (unsigned long) "runc:[1:INIT]", 0, 0, 0);
711+
prctl(PR_SET_NAME, (unsigned long) "runc:[2:INIT]", 0, 0, 0);
705712

706713
if (setsid() < 0)
707714
bail("setsid failed");

0 commit comments

Comments
 (0)