Re: Chroot bug

From: Olivier Galibert
Date: Wed Sep 26 2007 - 11:02:54 EST

On Wed, Sep 26, 2007 at 08:43:44PM +0930, David Newall wrote:
> Olivier Galibert wrote:
> >chroot does not allow you to walk out if you're in.
> You're mistaken. Or more properly, further use of chroot lets you walk
> out. This really has been said before, and before, and before.
> chroot("subtree"); // enter chroot
> chdir("/"); // now at subtree
> chroot("/tmp"); // now outside of chroot

Of course. chroots are not a stack, they're just a point in the
namespace. You change it, the conditions apply to the new one.

> BSD redefined chroot so that the working directory is set to the new
> root on subsequent uses of chroot; that's how they solved the bug.

They didn't solve a thing. fchdir baby. Unless you want to remove
fchdir. And mknod. And mount. And so many other different syscalls
that I don't even know the list.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at