From: Linus Torvalds <torvalds@osdl.org>
To: Rob Landley <rob@landley.net>
Cc: Ram Pai <linuxram@us.ibm.com>, Miklos Szeredi <miklos@szeredi.hu>,
Al Viro <viro@ftp.linux.org.uk>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 12/18] shared mount handling: bind and rbind
Date: Wed, 16 Nov 2005 08:18:25 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.64.0511160808430.13959@g5.osdl.org> (raw)
In-Reply-To: <200511160241.20016.rob@landley.net>
On Wed, 16 Nov 2005, Rob Landley wrote:
>
> So does mounting over / actually accomplish anything? Or is it sort of an
> undermount instead of an overmount, resulting in a mounted but inaccessible
> filesystem?
I'd say that _usually_ you're better off using chroot() than mounting over
"/".
> So all chroot(2) really does is reset the "/" reference?
Yes. Literally. Everything else stays the same, including any open files
(and cwd).
It's a "flaw" in chroot if you consider it a jail, but it's used for so
much more than that. In fact, you shouldn't consider it jail: it's really
just a small _part_ of the notion of limiting somebody to a specific area.
(The smallest part, in fact. And you should be aware that root can always
get out of a chdir() if he just has enough tools - and the tools aren't
even very big. "mknod" + "mount" will do it even in the absense of a way
to add binaries, as will /proc access).
Note that the most common use of chroot isn't actually the "jail" kind of
usage, but building and installation environments (ie a lot of package
building stuff end up using chroot as a way to create the "target
environment").
> In the specific case of "mount --move . /" || chroot ("."), I don't see why we
> need a chdir afterwards, because cwd points to the correct filesystem. (In
> fact, for a moment there between the mount move and the chroot it's the
> _only_ reference we have to this filesystem.)
>
> Perhaps ".." isn't correct unless we chdir again...?
Indeed. The issue ends up being ".." and "getcwd()", which both want to
know what your root is in order to know where to stop.
Linus
next prev parent reply other threads:[~2005-11-16 16:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 2:01 [PATCH 12/18] shared mount handling: bind and rbind Al Viro
2005-11-08 14:11 ` Miklos Szeredi
2005-11-08 15:48 ` Ram Pai
2005-11-08 15:55 ` Miklos Szeredi
2005-11-09 18:44 ` Ram Pai
2005-11-09 18:59 ` Linus Torvalds
2005-11-09 19:26 ` Al Viro
2005-11-09 19:28 ` Ram Pai
2005-11-16 3:29 ` Rob Landley
2005-11-16 3:53 ` Linus Torvalds
2005-11-16 5:35 ` Al Boldi
2005-11-16 8:19 ` Miklos Szeredi
2005-11-16 9:10 ` Rob Landley
2005-11-16 10:14 ` Miklos Szeredi
2005-11-16 13:59 ` Shaya Potter
2005-11-16 16:35 ` Miklos Szeredi
2005-11-16 20:05 ` Al Boldi
2005-11-16 20:21 ` Shaya Potter
2005-11-16 8:47 ` Rob Landley
2005-11-16 8:41 ` Rob Landley
2005-11-16 16:18 ` Linus Torvalds [this message]
2005-11-09 10:54 ` Miklos Szeredi
2005-11-09 14:31 ` Al Viro
2005-11-09 15:22 ` Miklos Szeredi
2005-11-09 15:56 ` Al Viro
2005-11-09 16:33 ` Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0511160808430.13959@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxram@us.ibm.com \
--cc=miklos@szeredi.hu \
--cc=rob@landley.net \
--cc=viro@ftp.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).