mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Vagin <avagin@parallels.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
	Andrey Vagin <avagin@openvz.org>, <linux-fsdevel@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Serge Hallyn <serge.hallyn@canonical.com>
Subject: Re: [PATCH] umount:  Do not allow unmounting rootfs.
Date: Tue, 07 Oct 2014 16:35:10 -0700	[thread overview]
Message-ID: <878ukrmp1t.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20141007215959.GA4622@paralelels.com> (Andrew Vagin's message of "Wed, 8 Oct 2014 02:00:00 +0400")

Andrew Vagin <avagin@parallels.com> writes:

> On Tue, Oct 07, 2014 at 01:58:01PM -0700, Eric W. Biederman wrote:
>> Andrew Vagin <avagin@parallels.com> writes:
>> 
>> > On Tue, Oct 07, 2014 at 12:27:06PM -0700, Eric W. Biederman wrote:
>> >> 
>> >> Which in practice is totally uninteresting.  Only the global root user can
>> >> do it, and it is just a stupid thing to do.
>> >> 
>> >> However that is no excuse to allow a silly way to oops the kernel.
>> >> 
>> >> We can avoid this silly problem by setting MNT_LOCKED on the rootfs
>> >> mount point and thus avoid needing any special cases in the unmount
>> >> code.
>> >
>> > I had this idea too, but it doesn't work.
>> >
>> > MNT_LOCKED isn't inherited, if the privileged user creates a new mount
>> > namespace.
>> >
>> > So "unshame -m ./nsenter" reproduces the same BUG.
>> 
>> Which broken tree do you have where MNT_LOCKED is not inherited?
>
> It is Linus' tree with your patch.
>
> I commented out one line and the BUG isn't triggered any more.

Ok.  That is very very weird.  It works for me and not for you.

Doh!  I ran your test program first on the primary mount namespace
and didn't have /proc mounted when I tried to run your test program
later.

Thanks for the hint about copy_tree that does seem to be where the logic
goes haywire.  In copy_mnt_ns we want an exact copy not a partial copy.
The good news is that this bug could only affect rootfs, so it is not a
security hole with respect to mount namespaces, created with user
namespace permissions.

mount --rbind and mount propogation should not be locked to their parent
mounts so we do need to clear MNT_LOCKED in a few places.

A patch that fixes copy_tree carefully in a moment.

Eric

  reply	other threads:[~2014-10-07 23:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-07 12:00 [PATCH] mnt: don't allow to detach the namespace root Andrey Vagin
2014-10-07 13:24 ` Al Viro
2014-10-07 13:40   ` Andrew Vagin
2014-10-07 19:27     ` [PATCH] umount: Do not allow unmounting rootfs Eric W. Biederman
2014-10-07 19:53       ` Andrew Vagin
2014-10-07 20:58         ` Eric W. Biederman
2014-10-07 22:00           ` Andrew Vagin
2014-10-07 23:35             ` Eric W. Biederman [this message]
2014-10-07 23:40               ` [PATCH] mnt: Move the clear of MNT_LOCKED from copy_tree to it's Eric W. Biederman
2014-10-08 10:46                 ` Andrew Vagin
2014-10-08 10:47       ` [PATCH] umount: Do not allow unmounting rootfs Andrew Vagin

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=878ukrmp1t.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=avagin@openvz.org \
    --cc=avagin@parallels.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serge.hallyn@canonical.com \
    --cc=viro@ZenIV.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

all inboxes | Powered by JetHome®