Karel Zak <kzak@xxxxxxxxxx> writes: > On Sat, Jan 30, 2016 at 04:31:06PM +0300, Yuriy M. Kaminskiy wrote: >> >> + 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* > > Would be possible to use any lightweight solution rather than > pipe()+read/write(), for example use sigtimedwait() in child and > kill() in parent? With my patch, if parent dies, child is automatically awoken (got EOF and cleanly exit). With signals, it is not. (Besides, it is not easy to set up without introducing more racing.) > The ideal solution would be to have /proc/self/ns/<name> files poll()-able. I'm not sure how it can fit with the way ns/<name> exposed by kernel currently (symlink to ns inode). (And more racing opportunities too). -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html