You are correct, it does not prevent that. My reasoning is that root
has a large number of ways to screw up the system already and detaching
a filesystem from the namespace by a trick like this is pretty minor
in comparison. After all, the filesystem may be reattached later.
A check could be added for the simplest case (preventing mounting a
filesystem on itself, but consider:
/dev/a /
/dev/b /b
/dev/c /b/c
Now remount /b on /b/c/d and it's gone.
Would a check that the current mount point is not a prefix of the new
mount point be sufficient to catch all possible loops?
Another question... is this necessarily a bad thing? Yes, it can get you
into situations that you can't get into now, but you can always return
to a sensible state. I'm having trouble thinking of a use for this that
chroot doesn't give you, to be fair.
-- Matthew Wilcox <willy@bofh.ai> "Windows and MacOS are products, contrived by engineers in the service of specific companies. Unix, by contrast, is not so much a product as it is a painstakingly compiled oral history of the hacker subculture." - N Stephenson- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/