Bug 1510976

Summary: [regression] ordinary user is unable to unmount fs mounted with "user" option
Product: Red Hat Enterprise Linux 7 Reporter: Boyang Xue <bxue>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: high Docs Contact:
Priority: high    
Version: 7.4CC: eguan, xzhou, zlang
Target Milestone: rcKeywords: Regression
Target Release: 7.5   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-08 14:31:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Failed unmount with EPERM none

Description Boyang Xue 2017-11-08 13:40:34 UTC
Created attachment 1349457 [details]
Failed unmount with EPERM

Description of problem:
An ordinary user is unable to unmount fs mounted with "user" option:

log
---
[root@vm mount]# id test
uid=1000(test) gid=1000(test) groups=1000(test),6(disk),10(wheel)
[root@vm mount]# tail -n1 /etc/fstab
/dev/vdb1 /media ext4 user 0 0
[root@vm mount]# su - test -c "mount /dev/vdb1"
[root@vm mount]# strace -o umount.nofork.strace -u test umount /dev/vdb1
umount: /media: umount failed: Operation not permitted
[root@vm mount]# rpm -q util-linux
util-linux-2.23.2-46.el7.x86_64
---

strace log is attached. Here umount operation should return without error. It's suspected that this is a regression introduced by the fix of BZ 1499760.

Copied from https://bugzilla.redhat.com/show_bug.cgi?id=1499760#c14
---
The 'user' option is described in mount(8) as
"user   Allow an ordinary user to mount the filesystem.  The name of the mounting user is written to mtab so that he can unmount the filesystem again."

I think the problem is that previously we use open(2) to check if a file was writable, and we passed O_CREAT to open(2) too, so file would be created if it was not there. But eaccess(3) doesn't create new file, so /run/mount/utab file won't be created now, and information about the 'user' mount is lost.
---

Since BZ 1499760 has been cloned to 7.4.z as BZ 1506533. Please consider clone this BZ to 7.4.z as well if necessary.

This bug has been found by running test "user" sub-test of "/kernel/filesystems/general/functional/mount" at side of kernel fs-qe.

Version-Release number of selected component (if applicable):
util-linux-2.23.2-46.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. echo "/dev/vdb1 /media ext4 user 0 0" >> /etc/fstab
2. su - test -c "mount /dev/vdb1"
3. su - test -c "umount /dev/vdb1"

Actual results:
umount returns without error

Expected results:
umount fails with "Operation not permitted"

Additional info:
N/A

Comment 3 Karel Zak 2017-11-08 14:31:09 UTC

*** This bug has been marked as a duplicate of bug 1499760 ***