FS#31624 - [util-linux] User-mounted loopback fs cannot be unmounted by user
Attached to Project:
Arch Linux
Opened by Glenn (grepfor) - Thursday, 20 September 2012, 19:44 GMT
Last edited by Tom Gundersen (tomegun) - Friday, 12 October 2012, 13:38 GMT
Opened by Glenn (grepfor) - Thursday, 20 September 2012, 19:44 GMT
Last edited by Tom Gundersen (tomegun) - Friday, 12 October 2012, 13:38 GMT
|
Details
Brief description:
A loopback filesystem with "user" option which has been mounted by a non-root user cannot subsequently be unmounted by that user, only by root. Fails with "operation not permitted". Possibly related to: Pertinent version info: util-linux: util-linux 2.21.2-5 Kernel: Linux 3.5.3-1-ARCH #1 SMP PREEMPT Sun Aug 26 08:15:06 UTC 2012 \ i686 GNU/Linu Other: /etc/mtab is symlinked to /proc/self/mounts. Not sure if this is relevant or not, just mentioning it. Some other reporters of similar-sounding bugs have opined that it might be relevant. How to reproduce: Minimal example attached below. 100% reproducible. When appeared: Unfortunately I do not have a very good idea when this bug first appeared, but suspect it is recent (last 6 months?). With certainty though, umount did used to behave correctly and allow user unmounting of loopback filesystem which had been mounted by the same user. Commentary: IMO, this is a serious issue because it prevents users from being able to freely mount/umount filesystems without either root privs or assistance from an admin (as root). On personal systems where the user is also the admin and has root privs, it is merely annoying; but on systems where users have no root privs and frequently do mount/umount cycles, it's painful, and eventually "uses up" all the loop devices. I realize that this is most likely an upstream issue, but reporting it here first just for completeness. If you determine it is upstream, please let me know, I will (re)file it upstream. #========================= BEGIN MINIMAL EXAMPLE =========================== # # As root, create a loopback filesystem for testing: # $ cd /tmp $ dd bs=4096 count=1000 if=/dev/zero of=test.lfs $ losetup /dev/loop1 test.lfs $ mke2fs /dev/loop1 $ losetup -d /dev/loop1 # # View /etc/fstab entry for above: # $ grep test.lfs /etc/fstab /tmp/test.lfs /mnt/test ext2 defaults,user 0 0 # # As user 'foo', mount the filesystem and verify that the reported mount # options include "user=foo" # $ id uid=501(foo) gid=501(foo) groups=501(foo),19(log),91(video),92(audio) $ mount /mnt/test $ mount | grep test /tmp/test.lfs on /mnt/test type ext2 \ (rw,nosuid,nodev,noexec,relatime,user=foo) $ losetup -a /dev/loop0: []: (/tmp/test.lfs) # # As user 'foo', attempt to umount the filesystem. Fails. Loop device is still # reported as in-use, and filesystem still reported as mounted. (Attempting # the umount as root succeeds normally.) # $ id uid=501(foo) gid=501(foo) groups=501(foo),19(log),91(video),92(audio) $ umount /mnt/test $ umount: /mnt/test: umount failed: Operation not permitted $ mount | grep test.lfs /tmp/test.lfs on /mnt/test type ext2 \ (rw,nosuid,nodev,noexec,relatime,user=foo) $ losetup -a /dev/loop0: []: (/tmp/test.lfs) #=========================== END MINIMAL EXAMPLE =========================== |
This task depends upon
Closed by Tom Gundersen (tomegun)
Friday, 12 October 2012, 13:38 GMT
Reason for closing: Fixed
Additional comments about closing: In 2.22.1-1
Friday, 12 October 2012, 13:38 GMT
Reason for closing: Fixed
Additional comments about closing: In 2.22.1-1
17463: libmount: TAB: [0x96c6aa0]: lookup TARGET: /home/noclaf/foo
17463: libmount: CXT: [0x96c6940]: umount /home/noclaf/foo: mtab disagrees with fstab
17463: libmount: CXT: [0x96c6940]: umount is not allowed for you
17463: libmount: CXT: [0x96c6940]: umount: preparing failed
umount: /home/noclaf/foo: umount failed: Operation not permitted
fstab entry:
/home/noclaf/foo.loop /home/noclaf/foo ext4 loop,user 0 0
mtab entry:
/dev/loop0 /home/noclaf/foo ext4 rw,nosuid,nodev,noexec,relatime,data=ordered 0 0
There does appear to be code in libmount/src/context_umount.c that deals with this (getting the loop device for the backing file), but something's failing. I'll debug more later.
This has nothing to do with
FS#27948, which is a cifs-utils bug, not a libmount bug.https://github.com/karelzak/util-linux/commit/9af2433419bd
There's a release planned, potentially as soon as next week.