Bug 989468 - vhostmd doesn't set supplemental groups correctly.
vhostmd doesn't set supplemental groups correctly.
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: vhostmd (Show other bugs)
7.0
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Richard W.M. Jones
Virtualization Bugs
:
Depends On: 741289
Blocks: 1018952
  Show dependency treegraph
 
Reported: 2013-07-29 06:24 EDT by Richard W.M. Jones
Modified: 2014-06-13 08:04 EDT (History)
10 users (show)

See Also:
Fixed In Version: vhostmd-0.5-6.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 741289
Environment:
Last Closed: 2014-06-13 08:04:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2013-07-29 06:24:31 EDT
+++ This bug was initially created as a clone of Bug #741289 +++

Description of problem:

(reported by Steve Grubb)

vhostmd does not set supplemental groups correctly when it
changes (drops) privs.  Between setgid and setuid, there
should be a call to either initgroups or setgroups as appropriate.

---

Util-linux's login program does something like this:

    if (initgroups(user, pwd->pw_gid) < 0) {
            syslog(LOG_ERR, "initgroups: %m");
            fprintf(stderr, _("\nSession setup problem, abort.\n"));
            exit(1);
    }

This can be adapted to vhostmd.c. The problem is that supplemental groups from the root account can be leaked into daemons unless they specifically clear the supplemental groups.

To test this, go into a system as root. Use the id program to verify root has some supplemental groups. Restart vhostmd. Get its pid. Look in /proc/<pid>/status for the "Groups" line. You should see some leaked groups. 

When patched, you should not.

---

The test is simple.  After starting vhostmd, run the
following command:

$ grep ^Groups: /proc/`pidof vhostmd`/status

If the bug is fixed, you should see one group, which is the
group of vhostmd (112 on Fedora, not sure about RHEL, but you
can check in /etc/group for the right number).  eg:

$ grep ^Groups: /proc/`pidof vhostmd`/status
Groups:	112 

However if you see a list of groups here, then there is an error.
For example, on Fedora with the unfixed vhostmd you see:

$ grep ^Groups: /proc/`pidof vhostmd`/status
Groups:	0 1 2 3 4 6 10 

This is very bad because (eg) '0' is the group of the root
account.

---

Upstream fix:
https://gitorious.org/vhostmd/vhostmd/commit/8684995d87e08fadd44e1814e810c770a1f60273
Comment 2 bfan 2013-07-30 02:46:43 EDT
Can reproduce with libguestfs-1.22.5-2.el7

[root@]# cat /etc/group | grep vhostmd
vhostmd:x:112:
[root@]# grep ^Groups: /proc/`pidof vhostmd`/status
Groups:
Comment 3 Lingfei Kong 2013-12-06 02:44:09 EST
Verified with vhostmd-0.5-6.el7.x86_64

#cat /etc/group | grep vhostmd
vhostmd:x:112:
[host-b]#grep ^Groups: /proc/`pidof vhostmd`/status
Groups:	112 


Only see one group, which is the group of vhostmd ,so this bug is fixed.
Comment 4 Ludek Smid 2014-06-13 08:04:38 EDT
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.

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