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 1247114 - SELinux is preventing /usr/bin/lsmd from using the setuid capability
Summary: SELinux is preventing /usr/bin/lsmd from using the setuid capability
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.2
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Lukas Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-27 11:30 UTC by Bruno Goncalves
Modified: 2015-11-19 10:42 UTC (History)
8 users (show)

Fixed In Version: selinux-policy-3.13.1-39.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 10:42:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2300 0 normal SHIPPED_LIVE selinux-policy bug fix update 2015-11-19 09:55:26 UTC

Description Bruno Goncalves 2015-07-27 11:30:25 UTC
Description of problem:
SElinux is preventing libstoragemgmt service (lsmd) to start.

Version-Release number of selected component (if applicable):
selinux-policy-3.13.1-34.el7.noarch
libstoragemgmt-1.2.3-3.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.# service libstoragemgmt start
Redirecting to /bin/systemctl start  libstoragemgmt.service

2.# service libstoragemgmt status
Redirecting to /bin/systemctl status  libstoragemgmt.service
● libstoragemgmt.service - libstoragemgmt plug-in server daemon
   Loaded: loaded (/usr/lib/systemd/system/libstoragemgmt.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2015-07-27 07:26:43 EDT; 18s ago
  Process: 4298 ExecStart=/usr/bin/lsmd -d (code=exited, status=1/FAILURE)
 Main PID: 4298 (code=exited, status=1/FAILURE)

Jul 27 07:26:43 lenovo-rd230-03.lab.bos.redhat.com systemd[1]: Started libstoragemgmt plug-in server daemon.
Jul 27 07:26:43 lenovo-rd230-03.lab.bos.redhat.com systemd[1]: Starting libstoragemgmt plug-in server daemon...
Jul 27 07:26:43 lenovo-rd230-03.lab.bos.redhat.com lsmd[4298]: Unexpected error on setuid(errno 1)
Jul 27 07:26:43 lenovo-rd230-03.lab.bos.redhat.com systemd[1]: libstoragemgmt.service: main process exited, code=exited, status=1/FAILURE
Jul 27 07:26:43 lenovo-rd230-03.lab.bos.redhat.com systemd[1]: Unit libstoragemgmt.service entered failed state.
Jul 27 07:26:43 lenovo-rd230-03.lab.bos.redhat.com systemd[1]: libstoragemgmt.service failed.


Actual results:
# grep lsmd /var/log/audit/audit.log
type=AVC msg=audit(1437996046.691:83): avc:  denied  { setuid } for  pid=1751 comm="lsmd" capability=7  scontext=system_u:system_r:lsmd_t:s0 tcontext=system_u:system_r:lsmd_t:s0 tclass=capability
type=SYSCALL msg=audit(1437996046.691:83): arch=c000003e syscall=105 success=no exit=-1 a0=3e1 a1=7f3e8a4c6274 a2=0 a3=7ffd64cd9690 items=0 ppid=1 pid=1751 auid=4294967295 uid=0 gid=991 euid=0 suid=0 fsuid=0 egid=991 sgid=991 fsgid=991 tty=(none) ses=4294967295 comm="lsmd" exe="/usr/bin/lsmd" subj=system_u:system_r:lsmd_t:s0 key=(null)

Comment 1 Bruno Goncalves 2015-07-27 11:35:30 UTC
It works well with selinux-policy-3.13.1-33.el7.noarch

# getenforce 
Enforcing

# service libstoragemgmt status
Redirecting to /bin/systemctl status  libstoragemgmt.service
● libstoragemgmt.service - libstoragemgmt plug-in server daemon
   Loaded: loaded (/usr/lib/systemd/system/libstoragemgmt.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2015-07-27 07:32:41 EDT; 4s ago
 Main PID: 5043 (lsmd)
   CGroup: /system.slice/libstoragemgmt.service
           └─5043 /usr/bin/lsmd -d

Jul 27 07:32:41 lenovo-rd230-03.lab.bos.redhat.com systemd[1]: Started libstoragemgmt plug-in server daemon.
Jul 27 07:32:41 lenovo-rd230-03.lab.bos.redhat.com systemd[1]: Starting libstoragemgmt plug-in server daemon...

Comment 4 Milos Malik 2015-08-06 12:25:34 UTC
You can find following lines in /usr/lib/systemd/system/libstoragemgmt.service:

[Service]
ExecStart=/usr/bin/lsmd -d
ExecReload=/bin/kill -HUP $MAINPID
StandardError=syslog
User=root

I changed "User=root" to "User=libstoragemgmt" and the AVC stopped appearing.

# rpm -q --scripts libstoragemgmt | grep -C2 useradd
getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
getent passwd libstoragemgmt >/dev/null || \
    useradd -r -g libstoragemgmt -d /var/run/lsm -s /sbin/nologin \
    -c "daemon account for libstoragemgmt" libstoragemgmt
postinstall scriptlet (using /bin/sh):
#

The lsmd process starts successfully via systemctl and it runs as:

# ps -efZ | grep lsmd
system_u:system_r:lsmd_t:s0     libstor+ 27766     1  0 14:18 ?        00:00:00 /usr/bin/lsmd -d
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 28093 4462  0 14:24 pts/0 00:00:00 grep --color=auto lsmd
#

There seems to be a dedicated user/group for running the daemon.

Comment 5 Bruno Goncalves 2015-08-06 12:45:48 UTC
Gris,

Could you check what is the right user to run lsmd?

Comment 6 Gris Ge 2015-08-06 13:27:29 UTC
Hi Milos Malik,

The lsmd is running as root by default[1], unless plugin require root
privilege[2], the plugin will run in libstoragemgmt/libstoragemgmt 
user/group. 

So, please allow lsmd running as root in order to support 
libstoragemgmt-plugin-hpsa and libstoragemgmt-plugin-megaraid.

Let me know if you need more detail.

[1] The 'lsmd.conf' is controlling it. Check manpage lsmd.conf(5) for detail.
[2] libstoragemgmt-plugin-hpsa and libstoragemgmt-plugin-megaraid require root
    privilege to run local command as root user. They will indicate that
    in their plugin configuration file. Other plugins will still running as
    unprivileged user.

Comment 7 Gris Ge 2015-08-06 13:38:36 UTC
Removing 'Regression' tag as this is caused by an expected change
in libstoragemgmt 1.2(rebase in RHEL 7.2):

  Since libstoragemgmt version 1.2, we need root privileged to support 
  hardware RAID support:
    libstoragemgmt-plugin-hpsa and libstoragemgmt-plugin-megaraid

We still run other plugins as unprivileged user.
User could force lsmd and all plugins to run as unprivileged user
via /etc/lsm/lsmd.conf, please check manpage lsmd.conf(5) for detail.

Comment 9 Lukas Vrabec 2015-08-10 12:12:51 UTC
commit fd65f7ea8eda195598e555819dc4e931ed6420c1
Author: Miroslav Grepl <mgrepl>
Date:   Fri Aug 7 12:00:59 2015 +0200

    Allow lsmd also setuid capability. Some commands need to executed under root privs. Other commands are executed under unprivileged user.

Comment 13 errata-xmlrpc 2015-11-19 10:42:18 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.

https://rhn.redhat.com/errata/RHBA-2015-2300.html


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