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 664406 - qemu process is spawned with no supplementary groups
Summary: qemu process is spawned with no supplementary groups
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.0
Hardware: Unspecified
OS: Unspecified
urgent
medium
Target Milestone: rc
: ---
Assignee: Laine Stump
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 602640 668692
TreeView+ depends on / blocked
 
Reported: 2010-12-20 10:37 UTC by Dan Kenigsberg
Modified: 2013-01-11 03:41 UTC (History)
16 users (show)

Fixed In Version: libvirt-0.8.7-1.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-05-19 13:25:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0596 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2011-05-18 17:56:36 UTC

Description Dan Kenigsberg 2010-12-20 10:37:07 UTC
Description of problem:
By default, libvirt spawns qemu with qemu:qemu uid:gid. However, on RHEL6, qemu user has a default supplementary group ('kvm'). Without libvirt calling initgroups(), qemu process cannot enjoy the credentials of 'kvm' group.

We need this in order for qemu to access group-readable ISO images with gid=kvm.

Version-Release number of selected component (if applicable):
libvirt-0.8.1-27.el6_0.2.x86_64

Upstream discussion under
https://www.redhat.com/archives/libvir-list/2010-December/msg00756.html

Comment 2 Laine Stump 2010-12-21 20:50:04 UTC
Fix posted upstream. Once it's ACKed, this will be in the next libvirt release / rebase.

https://www.redhat.com/archives/libvir-list/2010-December/msg00846.html

Comment 5 Laine Stump 2011-01-05 16:33:42 UTC
BTW, the patches mentioned in Comment 2 were pushed upstream prior to the recent libvirt-0.8.7 release, so the fix will be in the upcoming rebase:

commit f42cf7cb7902196382a65e5316c974a5c2106401
Author: Laine Stump <laine>
Date:   Tue Dec 21 15:34:41 2010 -0500

    Replace setuid/setgid/initgroups with virSetUIDGID()
    
    This patch fixes https://bugzilla.redhat.com/show_bug.cgi?id=664406
    
    If qemu is run as a different uid, it has been unable to access mode
    0660 files that are owned by a different user, but with a group that
    the qemu is a member of (aside from the one group listed in the passwd
    file), because initgroups() is not being called prior to the
    exec. initgroups will change the group membership of the process (and
    its children) to match the new uid.
    
    To make this happen, the setregid()/setreuid() code in
    qemuSecurityDACSetProcessLabel has been replaced with a call to
    virSetUIDGID(), which does both of those, plus calls initgroups.
    
    Similar, but not identical, code in qemudOpenAsUID() has been replaced
    with virSetUIDGID(). This not only consolidates the functionality to a
    single location, but also potentially fixes some as-yet unreported
    bugs.

commit d596c6dc9b64ca0c910a87127de72ed2ef47b692
Author: Laine Stump <laine>
Date:   Thu Dec 23 01:44:02 2010 -0500

    new virSetUIDGID() utility function
    
    virSetUIDGID() sets both the real and effective group and user of the
    process, and additionally calls initgroups() to assure that the
    process joins all the auxiliary groups that the given uid is a member
    of.

Comment 6 Eric Blake 2011-01-05 17:21:05 UTC
And one other related patch also made it into 0.8.7:

commit c685993d71c1cf561af2cf34a5077781566aa0e0
Author: Eric Blake <eblake>
Date:   Mon Jan 3 15:26:33 2011 -0700

    build: avoid compilation warnings
    
    Detected on cygwin:
    util/util.c: In function 'virSetUIDGID':
    util/util.c:2824: warning: format '%d' expects type 'int', but argument 7 has type 'gid_t' [-Wformat]s)
    
    * src/util/util.c (virSetUIDGID): Cast, as is done elsewhere in
    this file, to avoid printf type mismatch warnings.

Comment 7 Jiri Denemark 2011-01-09 23:58:17 UTC
Built into libvirt-0.8.7-1.el6

Comment 10 Gunannan Ren 2011-01-11 09:50:58 UTC
The bug has been tested in libvirt-0.8.7-1.el6.

1, setup a NFS server with exports configuration as follows
/tmp/nfstest  *(rw,root_squash)

2, copy a guest image file into the shared fold. Using chmod to set the ownership and groupship of the image file to (otheruser):kvm, the other user shouldn't be qemu.
# chown 500:36 rhel6.img 

3, In the client server, mount the NFS shared folder, then, try to boot up a guest which use the image file as its OS disk.

For the libvirt-0.8.7-1.el6, the guest started successfully, but libvirt-0.8.6-1.el6 failed.

Comment 12 Vivian Bian 2011-02-16 07:19:10 UTC
retested this bug with 
libvirt-0.8.7-6.el6.x86_64  --- verification pkg
libvirt-0.8.1-27.el6.x86_64 --- reproducer pkg

steps:

1, setup a NFS server with exports configuration as follows
/tmp/nfstest  *(rw,root_squash)

2, copy a guest image file into the shared fold. Using chmod+chown to set the access right ,ownership and groupship of the image file to (otheruser):kvm, the other user
shouldn't be qemu.

# chown 500:36 rhel6.img 
# chmod 755 rhel6.img

3, In the client machine, mount the NFS shared folder, then, try to boot up a
guest which use the image file as its OS disk.


[reproducer]
error: Failed to start domain test1
error: internal error Process exited while reading console log output: char device redirected to /dev/pts/3
qemu: could not open disk image /var/lib/libvirt/migration/rhel6.img: Permission denied


[verification]

# virsh start test1
Domain test1 started

# ll /var/lib/libvirt/migration/rhel6.img
-rwxrwxrwx. 1 xguest kvm 8589934592 Feb 16 07:09 /var/lib/libvirt/migration/rhel6.img

the ownership wasn't changed by qemu , and it kept kvm group . 

So set bug status to VERIFIED

Comment 15 errata-xmlrpc 2011-05-19 13:25:06 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0596.html


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