public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* unprivileged mount problems: device permissions ignored, mount sharing
@ 2007-04-29 18:59 utz lehmann
  2007-05-02  7:56 ` Miklos Szeredi
  0 siblings, 1 reply; 3+ messages in thread
From: utz lehmann @ 2007-04-29 18:59 UTC (permalink / raw)
  To: Miklos Szeredi, LKML

Hello

I tried the unprivileged mount v5 patches with 2.6.21.1. I made some
experiments with normal filesystems (ext3, xfs, iso9660). I removed the
FS_SAFE checks for that.

Mounting and umounting as unprivileged user (user1) works, e.g.
(/mnt/user1 is a mount owned by user1)

[user1@segv ~]$ mmount -t xfs /dev/mapper/vg00-test /mnt/user1

But the device permissions are ignored. The unprivileged user can mount
the block device even there are no permissions to access it:

brw------- 1 root root 253, 5 Apr 29 18:32 /dev/mapper/vg00-test


And there is another problem with sharing the device (superblock?).
If user1 mount a device readonly:

[user1@segv ~]$ mmount -r -t xfs /dev/mapper/vg00-test /mnt/user1

Than root cannot mount the device rw:

[root@segv ~]# mount /dev/mapper/vg00-test /mnt/test/
mount: /dev/mapper/vg00-test already mounted or /mnt/test/ busy

Mounting ro works and than remounting rw work. But than /mnt/user1 is rw
too.

This can DoS e.g. the automounter mounting /dev/mapper/vg00-test rw.


utz



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: unprivileged mount problems: device permissions ignored, mount sharing
  2007-04-29 18:59 unprivileged mount problems: device permissions ignored, mount sharing utz lehmann
@ 2007-05-02  7:56 ` Miklos Szeredi
  2007-05-06 10:21   ` Frank van Maarseveen
  0 siblings, 1 reply; 3+ messages in thread
From: Miklos Szeredi @ 2007-05-02  7:56 UTC (permalink / raw)
  To: lkml123; +Cc: linux-kernel

> I tried the unprivileged mount v5 patches with 2.6.21.1. I made some
> experiments with normal filesystems (ext3, xfs, iso9660). I removed the
> FS_SAFE checks for that.

Thanks for looking at this.

> Mounting and umounting as unprivileged user (user1) works, e.g.
> (/mnt/user1 is a mount owned by user1)
> 
> [user1@segv ~]$ mmount -t xfs /dev/mapper/vg00-test /mnt/user1
> 
> But the device permissions are ignored. The unprivileged user can mount
> the block device even there are no permissions to access it:
> 
> brw------- 1 root root 253, 5 Apr 29 18:32 /dev/mapper/vg00-test

Yes, I'm aware of this.  Before we enable FS_SAFE for block
filesystems, this must be addressed.

But I'm not sure _if_ we'll ever want this.  It is very likely that
there are some other security holes in most filesystems that are
difficult to address.  One example is checking for hard-linked
directories, which is normally only done during an fsck.

> And there is another problem with sharing the device (superblock?).
> If user1 mount a device readonly:
> 
> [user1@segv ~]$ mmount -r -t xfs /dev/mapper/vg00-test /mnt/user1
> 
> Than root cannot mount the device rw:
> 
> [root@segv ~]# mount /dev/mapper/vg00-test /mnt/test/
> mount: /dev/mapper/vg00-test already mounted or /mnt/test/ busy
> 
> Mounting ro works and than remounting rw work. But than /mnt/user1 is rw
> too.
> 
> This can DoS e.g. the automounter mounting /dev/mapper/vg00-test rw.

Right.

There are patches for enabling per-mount read-only, but this shows
well, that unprivileged block device mounts are far from trivial.

Miklos

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: unprivileged mount problems: device permissions ignored, mount sharing
  2007-05-02  7:56 ` Miklos Szeredi
@ 2007-05-06 10:21   ` Frank van Maarseveen
  0 siblings, 0 replies; 3+ messages in thread
From: Frank van Maarseveen @ 2007-05-06 10:21 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: lkml123, linux-kernel

On Wed, May 02, 2007 at 09:56:52AM +0200, Miklos Szeredi wrote:
> > I tried the unprivileged mount v5 patches with 2.6.21.1. I made some
> > experiments with normal filesystems (ext3, xfs, iso9660). I removed the
> > FS_SAFE checks for that.
> 
> Thanks for looking at this.
> 
> > Mounting and umounting as unprivileged user (user1) works, e.g.
> > (/mnt/user1 is a mount owned by user1)
> > 
> > [user1@segv ~]$ mmount -t xfs /dev/mapper/vg00-test /mnt/user1
> > 
> > But the device permissions are ignored. The unprivileged user can mount
> > the block device even there are no permissions to access it:
> > 
> > brw------- 1 root root 253, 5 Apr 29 18:32 /dev/mapper/vg00-test
> 
> Yes, I'm aware of this.  Before we enable FS_SAFE for block
> filesystems, this must be addressed.
> 
> But I'm not sure _if_ we'll ever want this.  It is very likely that
> there are some other security holes in most filesystems that are
> difficult to address.  One example is checking for hard-linked
> directories, which is normally only done during an fsck.

Some filesystems are not hardened against mounting a corrupted image and
can Oops. This is also a problem for automounting USB sticks except that
in that case you're (probably) sitting next to the hardware so there
are other ways to do bad things.

>From a security point of view I'd like to restrict unprivileged mounts
to a configurable list of filesystem types.

-- 
Frank

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-05-06 10:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-29 18:59 unprivileged mount problems: device permissions ignored, mount sharing utz lehmann
2007-05-02  7:56 ` Miklos Szeredi
2007-05-06 10:21   ` Frank van Maarseveen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox