FS#36968 - [util-linux] umount as non-privileged user: mountpoint not found

Attached to Project: Arch Linux
Opened by M. P. (mpausch) - Tuesday, 17 September 2013, 20:44 GMT
Last edited by Dave Reisner (falconindy) - Friday, 20 September 2013, 18:47 GMT
Task Type Bug Report
Category Upstream Bugs
Status Closed
Assigned To Dave Reisner (falconindy)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
- in /etc/fstab the entry for a filesystem is with option "user" to allow non-priv users to mount
- mount as non-priv user works
- umount as non-priv user shows error: "mountpoint not found"
- umount as root works


Additional info:
* package version(s)
* config and/or log files etc.

### fstab entry for my
$ cat /etc/fstab
[...]
LABEL=mybackup /mnt auto user,noauto 0 0
[...]



Steps to reproduce:

- create a fstab entry with option "user" (to be able to mount the FS as non-priv user)
- follow procedure:

### show which partition is labeled with mybackup
$ ls -la /dev/disk/by-label/mybackup
lrwxrwxrwx 1 root root 10 17. Sep 21:44 /dev/disk/by-label/manebackup -> ../../sdf1

### mount the FS as non-priv user (-> works)
$ mount /dev/disk/by-label/mybackup

### check, if mounted
$ mount | grep mnt
/dev/sdf1 on /mnt type ext4 (rw,nosuid,nodev,noexec,relatime,data=ordered,user=myuser)


### try to umount (-> does not work)
$ umount /dev/disk/by-label/mybackup
umount: /mnt: mountpoint not found

### also alternate umounts commands don't work:
$ umount /dev/sdf1
umount: /mnt: mountpoint not found
$ umount /mnt
umount: /mnt: mountpoint not found

### umount as super-user works
# umount /dev/disk/by-label/mybackup
# mount | grep mnt
#



- umount as non-priv user worked in the past, but does not work since <unknown> days/weeks/months
- other users seem to face the same issue: https://bbs.archlinux.org/viewtopic.php?pid=1324991

This task depends upon

Closed by  Dave Reisner (falconindy)
Friday, 20 September 2013, 18:47 GMT
Reason for closing:  Fixed
Additional comments about closing:  https://github.com/karelzak/util-linux/c ommit/4e9f59d1ee293108cd1d577f7b1a182f5b 0ac9c0
Comment by Dave Reisner (falconindy) - Tuesday, 17 September 2013, 20:59 GMT
Unmounting by device name has never been supported, since the same device can be mounted in multiple places (though recently, the -A flag was added).

Problem seems to be pretty clear via the debug output:

17760: libmount: CXT: [0x22890e0]: do umount
17760: libmount: UTILS: moving to /opt parent
17760: libmount: CXT: current directory moved to / [last_component='opt']
17760: libmount: CXT: [0x22890e0]: umount(2) [target='pt', flags=0x00000000]
Comment by Dave Reisner (falconindy) - Tuesday, 17 September 2013, 21:05 GMT Comment by M. P. (mpausch) - Wednesday, 18 September 2013, 10:47 GMT
Many thanks for your efforts.

Maybe it has never been supported, but it worked in former times.
And why the _same_ umount command works as root user but not as non-priv user?

Even if I try to unmount with "umount <mountpoint>" (instead of "umount <device-name>") it
does not work as non-priv user (but as root user).

Comment by Dave Reisner (falconindy) - Wednesday, 18 September 2013, 14:15 GMT
> And why the _same_ umount command works as root user but not as non-priv user?
Because it follows different code paths, of course. Unmounting as a non-privileged user causes mount/umount to chdir() for security reasons. mnt_chdir_to_parent() is where this chokes...
Comment by M. P. (mpausch) - Wednesday, 18 September 2013, 17:33 GMT
Thanks. Just for my curiosity: for what security reason mount/umount does chdir() when a non-priv user unmounts a device?
Comment by Dave Reisner (falconindy) - Wednesday, 18 September 2013, 17:39 GMT
I really don't recall the reason, but mount has behaved this way for years. It probably has something to do with symlinks.

Loading...