RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1106548 - root gets an error accessing to a non-root dir on a snapshot guestmount VMDK img
Summary: root gets an error accessing to a non-root dir on a snapshot guestmount VMDK img
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs
Version: 6.3
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Pino Toscano
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-09 14:48 UTC by Pablo Iranzo Gómez
Modified: 2018-12-09 17:57 UTC (History)
8 users (show)

Fixed In Version: libguestfs-1.20.11-7.el6
Doc Type: Bug Fix
Doc Text:
Cause: There were not particular permission checks for root in the FUSE layer of libguestfs. Consequence: Mount a disk image using guestmount; accessing as root to a directory not owned by root with permissions 700 would fail with a "permission denied" error. Fix: Disable permissions check for root. Result: root can access any directory of a disk image mounted using guestmount.
Clone Of:
Environment:
Last Closed: 2014-10-14 06:35:31 UTC
Target Upstream Version:
Embargoed:
ptoscano: needinfo-


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 135223 0 None None None Never
Red Hat Product Errata RHBA-2014:1458 0 normal SHIPPED_LIVE libguestfs bug fix update 2014-10-14 01:10:57 UTC

Description Pablo Iranzo Gómez 2014-06-09 14:48:08 UTC
Description of problem:

When mounting a vmdk image with guestmount, if the folders inside the image has 0700 permissions for a non-root user, root is unable to access them

How reproducible:

[root@example adm]# df -h .
Filesystem            Size  Used Avail Use% Mounted on
guestmount            992M   40M  902M   5% /mnt/vmdk
[root@example adm]# pwd
/mnt/vmdk/home/adm
[root@example adm]# mount | grep guestmount
guestmount on /mnt/vmdk type fuse.guestmount (rw,nosuid,nodev)
[root@example adm]#

[root@example adm]# cd home/adm
[root@example adm]# ls -l
total 20
drwxr-xr-x 2 root   adm 4096 Jul 11  2012 bin
drwxr-x--- 2 root   adm 4096 Jul 11  2012 etc
drwx------ 2 hpsupp adm 4096 Jul 11  2012 hpsupp
drwxr-xr-x 2 root   adm 4096 Feb  4  2009 man
-r--r----- 1 root   adm  424 Jul 11  2012 profile

[root@example adm]# cd hpsupp
-bash: cd: hpsupp: Permission denied
[root@example adm]# id
uid=0(root) gid=0(root) groups=0(root),4(adm)
[root@example adm]# 


Reading the directory through tar works:

[root@example adm]# pwd
/mnt/vmdk/home/adm
[root@example adm]# tar cfv /tmp/hpsupp.tar hpsupp/
hpsupp/
hpsupp/.bash_profile
[root@example adm]# cd /tmp
[root@example tmp]# tar xfv hpsupp.tar 
hpsupp/
hpsupp/.bash_profile
[root@example tmp]# head -2 hpsupp/.
./             ../            .bash_profile  
[root@example tmp]# head -2 hpsupp/.bash_profile 
# .bash_profile

[root@example tmp]# 


Actual results:

Access not allowed to root


Expected results:

Root should have access as if it were on a normal mountpoint

Additional info:

Comment 2 Richard W.M. Jones 2014-06-12 10:56:38 UTC
Reproducer (on Fedora Rawhide):

cd /tmp
guestfish -N fs -m /dev/sda1 mkdir /foo : touch /foo/bar : chmod 0700 /foo

mkdir /tmp/mnt
guestmount -a test1.img -m /dev/sda1 /tmp/mnt

This works:

$ cd /tmp/mnt

This does not work:

$ cd /tmp/mnt/foo
bash: cd: /tmp/mnt/foo: Permission denied

This works:

$ ls -al /tmp/mnt/foo
total 2
drwx------. 2 root root 1024 Jun 12 11:51 .
drwxr-xr-x. 4 root root 1024 Jun 12 11:51 ..
-rw-r--r--. 1 root root    0 Jun 12 11:51 bar

Comment 3 Richard W.M. Jones 2014-06-12 12:08:02 UTC
Actually the reproducer in comment 2 is wrong, although it does
reveal a different-but-related bug.

> This does not work:
> 
> $ cd /tmp/mnt/foo
> bash: cd: /tmp/mnt/foo: Permission denied

It's good that this doesn't work!  A root-owned drwx------ directory
should not be enterable or readable by an ordinary user.

> This works:
> 
> $ ls -al /tmp/mnt/foo
> total 2
> drwx------. 2 root root 1024 Jun 12 11:51 .
> drwxr-xr-x. 4 root root 1024 Jun 12 11:51 ..
> -rw-r--r--. 1 root root    0 Jun 12 11:51 bar

This is a bug!  The directory should not be readable by the
non-root user.

Comment 4 Richard W.M. Jones 2014-06-12 12:21:24 UTC
Let's try a different reproducer which is more similar to the
original problem ...

Run the following commands *as root*:

cd /tmp
mkdir /tmp/mnt
guestfish -N fs -m /dev/sda1 <<EOF
  mkdir /foo
  touch /foo/bar
  chmod 0700 /foo
  chown 1 1 /foo
EOF
guestmount -a test1.img -m /dev/sda1 /tmp/mnt

Run the following test *as root*:

# cd /tmp/mnt/foo
bash: cd: /tmp/mnt/foo: Permission denied
# ls -al /tmp/mnt/foo
total 2
drwx------. 2 bin  bin  1024 Jun 12 13:16 .
drwxr-xr-x. 4 root root 1024 Jun 12 13:16 ..
-rw-r--r--. 1 root root    0 Jun 12 13:16 bar

Because we are running as root, we would NOT expect that
permissions are honoured, since normally root causes
file permissions to be ignored.  In other words, the
'cd' command should NOT fail.

We can compare this situation to a regular (non-FUSE)
directory which is owned by bin:bin:

root@choo:/tmp/p# cd foo2
root@choo:/tmp/p/foo2# ls -al
total 8
drwx------. 2 bin    bin    4096 Jun 12 11:58 .
drwxrwxr-x. 3 rjones rjones 4096 Jun 12 11:58 ..
-rw-rw-r--. 1 rjones rjones    0 Jun 12 11:58 bar

Comment 5 Richard W.M. Jones 2014-06-12 12:33:31 UTC
Patch posted upstream:
https://www.redhat.com/archives/libguestfs/2014-June/msg00053.html

Comment 6 Richard W.M. Jones 2014-06-18 13:54:55 UTC
Patch is upstream, but waiting for QA ack.

Comment 7 Pino Toscano 2014-06-19 14:57:52 UTC
9b5cdc874784437d7a59bd024043c2abd930b6c3 is the upstream commit fixing this bug, part of libguestfs >= 1.27.16.

Comment 37 Wei Shi 2014-09-02 09:14:07 UTC
Reproduced on libguestfs-1.20.11-2.el6.x86_64

Verified on libguestfs-1.20.11-10.el6.x86_64

# cd /tmp
# mkdir /tmp/mnt

# guestfish -N fs -m /dev/sda1 <<EOF
>   mkdir /foo
>   touch /foo/bar
>   chmod 0700 /foo
>   chown 1 1 /foo
> EOF
# guestmount -a test1.img -m /dev/sda1 /tmp/mnt
# cd /tmp/mnt/foo
# ls -al /tmp/mnt/foo
total 2
drwx------. 2 bin  bin  1024 Sep  3 01:05 .
drwxr-xr-x. 4 root root 1024 Sep  3 01:05 ..
-rw-r--r--. 1 root root    0 Sep  3 01:05 bar

Comment 42 errata-xmlrpc 2014-10-14 06:35:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1458.html


Note You need to log in before you can comment on or make changes to this bug.