yumkam@gmail.com (Yuriy M. Kaminskiy) writes: > Karel Zak writes: > > (this was commited as c84f2590dfdb8570beeb731e0105f8fe597443d1) > >> +static void bind_ns_files_from_child(pid_t *child) >> +{ >> + pid_t ppid = getpid(); >> + ino_t ino = get_mnt_ino(ppid); >> + >> + *child = fork(); >> + >> + switch(*child) { >> + case -1: >> + err(EXIT_FAILURE, _("fork failed")); >> + case 0: /* child */ >> + do { >> + /* wait until parent unshare() */ >> + ino_t new_ino = get_mnt_ino(ppid); >> + if (ino != new_ino) >> + break; >> + } while (1); > > Racing? Suppose, parent died (e.g. unshare(2) failed), (parent) process > was reaped, new (unrelated) process was created with same pid, as a > result this function will bind namespaces from wrong process. ... besides, this is a busyloop, if "imposer process" is in same mnt namespace as original process, it will occupy CPU forever (and this *is* easy to fix; see attached; note that with attached patch race probability is reduced, but not totally avoided, there are still window between read(pipe) and mount() calls [but at least it won't busyloop, and won't trigger racing on unshare(2) error]). P.S. that said, for me, on debian's 3.16.7-ckt* kernel, `touch foo && unshare --mount=foo` still fails with EINVAL (with either unpatched git master or with this patch), so consider this as "compile-tested only". > (That said, pretty unlikely, and no idea how to properly fix it). >