Bug 1280280 - restorecon sets an incorrect label on /var/run/tgtd.ipc_abstract_namespace.0.lock file
restorecon sets an incorrect label on /var/run/tgtd.ipc_abstract_namespace.0....
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy (Show other bugs)
7.2
All Linux
medium Severity medium
: rc
: ---
Assigned To: Lukas Vrabec
Milos Malik
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-11-11 07:00 EST by Milos Malik
Modified: 2016-11-03 22:24 EDT (History)
6 users (show)

See Also:
Fixed In Version: selinux-policy-3.13.1-69.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-11-03 22:24:31 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2283 normal SHIPPED_LIVE selinux-policy bug fix and enhancement update 2016-11-03 09:36:25 EDT

  None (edit)
Description Milos Malik 2015-11-11 07:00:36 EST
Description of problem:

Version-Release number of selected component (if applicable):
scsi-target-utils-1.0.46-3.el7.x86_64
selinux-policy-3.13.1-60.el7.noarch
selinux-policy-devel-3.13.1-60.el7.noarch
selinux-policy-doc-3.13.1-60.el7.noarch
selinux-policy-minimum-3.13.1-60.el7.noarch
selinux-policy-mls-3.13.1-60.el7.noarch
selinux-policy-sandbox-3.13.1-60.el7.noarch
selinux-policy-targeted-3.13.1-60.el7.noarch

How reproducible:
always

Steps to Reproduce:
# service tgtd status
Redirecting to /bin/systemctl status  tgtd.service
● tgtd.service - tgtd iSCSI target daemon
   Loaded: loaded (/usr/lib/systemd/system/tgtd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

Nov 11 12:47:18 rhel72.localdomain systemd[1]: Unit tgtd.service entered fai....
Nov 11 12:47:18 rhel72.localdomain systemd[1]: tgtd.service failed.
Nov 11 12:54:03 rhel72.localdomain systemd[1]: Starting tgtd iSCSI target da....
Nov 11 12:54:03 rhel72.localdomain tgtd[4962]: tgtd: iser_ib_init(3355) Fail...?
Nov 11 12:54:03 rhel72.localdomain tgtd[4962]: tgtd: work_timer_start(146) u...r
Nov 11 12:54:03 rhel72.localdomain tgtd[4962]: tgtd: bs_init_signalfd(271) c...e
Nov 11 12:54:03 rhel72.localdomain tgtd[4962]: tgtd: bs_init(390) use signal...n
Nov 11 12:54:08 rhel72.localdomain systemd[1]: Started tgtd iSCSI target daemon.
Nov 11 12:54:17 rhel72.localdomain systemd[1]: Stopping tgtd iSCSI target da....
Nov 11 12:54:18 rhel72.localdomain systemd[1]: Stopped tgtd iSCSI target daemon.
Hint: Some lines were ellipsized, use -l to show in full.
# ls -Z /run/tgtd.*
srwxr-xr-x. root root system_u:object_r:tgtd_var_run_t:s0 /run/tgtd.ipc_abstract_namespace.0
-rw-r--r--. root root system_u:object_r:tgtd_var_run_t:s0 /run/tgtd.ipc_abstract_namespace.0.lock
# restorecon -v /run/tgtd.*
restorecon reset /run/tgtd.ipc_abstract_namespace.0.lock context system_u:object_r:tgtd_var_run_t:s0->system_u:object_r:var_run_t:s0
# service tgtd start
Redirecting to /bin/systemctl start  tgtd.service
Job for tgtd.service failed because the control process exited with error code. See "systemctl status tgtd.service" and "journalctl -xe" for details.
#

Actual results (enforcing mode):
----
type=PATH msg=audit(11/11/2015 12:55:02.609:279) : item=1 name=/var/run/tgtd.ipc_abstract_namespace.0.lock inode=70602 dev=00:12 mode=file,644 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:var_run_t:s0 objtype=NORMAL 
type=PATH msg=audit(11/11/2015 12:55:02.609:279) : item=0 name=/var/run/ inode=6661 dev=00:12 mode=dir,755 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:var_run_t:s0 objtype=PARENT 
type=CWD msg=audit(11/11/2015 12:55:02.609:279) :  cwd=/ 
type=SYSCALL msg=audit(11/11/2015 12:55:02.609:279) : arch=x86_64 syscall=open success=no exit=-13(Permission denied) a0=0x6576a0 a1=O_WRONLY|O_CREAT a2=0644 a3=0x7ffcc559bec0 items=2 ppid=1 pid=5352 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=tgtd exe=/usr/sbin/tgtd subj=system_u:system_r:tgtd_t:s0 key=(null) 
type=AVC msg=audit(11/11/2015 12:55:02.609:279) : avc:  denied  { write } for  pid=5352 comm=tgtd name=tgtd.ipc_abstract_namespace.0.lock dev="tmpfs" ino=70602 scontext=system_u:system_r:tgtd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file 
----

Expected results:
 * no SELinux denails
 * correct file context pattern
Comment 2 Milos Malik 2015-11-18 03:21:38 EST
The tgtd process creates the lock file with correct context

# sesearch -s tgtd_t -t var_run_t -T
Found 2 semantic te rules:
   type_transition tgtd_t var_run_t : file tgtd_var_run_t; 
   type_transition tgtd_t var_run_t : sock_file tgtd_var_run_t; 

#

but the file pattern matches only sockets

# semanage fcontext -l | grep /run/tgt
/var/run/tgtd.*                                    socket             system_u:object_r:tgtd_var_run_t:s0 
# 

which means that restorecon resets the label to var_run_t:

# ls -Z /run/tgtd.ipc_abstract_namespace.0*
srwxr-xr-x. root root system_u:object_r:tgtd_var_run_t:s0 /run/tgtd.ipc_abstract_namespace.0
-rw-r--r--. root root system_u:object_r:tgtd_var_run_t:s0 /run/tgtd.ipc_abstract_namespace.0.lock
# restorecon -v /run/tgtd.ipc_abstract_namespace.0*
restorecon reset /run/tgtd.ipc_abstract_namespace.0.lock context system_u:object_r:tgtd_var_run_t:s0->system_u:object_r:var_run_t:s0
#
Comment 8 errata-xmlrpc 2016-11-03 22:24:31 EDT
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-2016-2283.html

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