Bug 703482

Summary: enforcing MLS -- AVCs appear when running "kpartx -v /dev/sda"
Product: Red Hat Enterprise Linux 5 Reporter: Milos Malik <mmalik>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.7CC: dwalsh, jrieden
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-2.4.6-306.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-21 09:20:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Milos Malik 2011-05-10 13:45:31 UTC
Description of problem:

Version-Release number of selected component (if applicable):
selinux-policy-devel-2.4.6-304.el5
selinux-policy-minimum-2.4.6-304.el5
selinux-policy-strict-2.4.6-304.el5
selinux-policy-mls-2.4.6-304.el5
selinux-policy-2.4.6-304.el5
selinux-policy-targeted-2.4.6-304.el5

How reproducible:
always

Steps to Reproduce:
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 21
Policy from config file:        mls
# id -Z
root:sysadm_r:sysadm_t:SystemLow-SystemHigh
# kpartx -v /dev/sda
/dev/mapper/control: open failed: Permission denied
Failure to communicate with kernel device-mapper driver.
/dev/sda: Permission denied
# 

Actual results:
----
time->Tue May 10 09:41:43 2011
type=SYSCALL msg=audit(1305034903.072:185): arch=c0000032 syscall=1028 success=no exit=-13 a0=60000fffff9a7d9c a1=0 a2=0 a3=20000000002b8238 items=0 ppid=13455 pid=29054 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS1 ses=1 comm="kpartx" exe="/sbin/kpartx" subj=root:sysadm_r:sysadm_t:s0-s15:c0.c1023 key=(null)
type=AVC msg=audit(1305034903.072:185): avc:  denied  { read } for  pid=29054 comm="kpartx" name="sda" dev=tmpfs ino=2016 scontext=root:sysadm_r:sysadm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:fixed_disk_device_t:s15:c0.c1023 tclass=blk_file
----
time->Tue May 10 09:41:43 2011
type=SYSCALL msg=audit(1305034903.071:184): arch=c0000032 syscall=1028 success=no exit=-13 a0=60000fffff9a65f8 a1=2 a2=0 a3=20000000002b8238 items=0 ppid=13455 pid=29054 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS1 ses=1 comm="kpartx" exe="/sbin/kpartx" subj=root:sysadm_r:sysadm_t:s0-s15:c0.c1023 key=(null)
type=AVC msg=audit(1305034903.071:184): avc:  denied  { read write } for  pid=29054 comm="kpartx" name="control" dev=tmpfs ino=2047 scontext=root:sysadm_r:sysadm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:lvm_control_t:s0 tclass=chr_file
----

Expected results:
no AVCs

Comment 1 Daniel Walsh 2011-05-12 05:47:12 UTC
ls -lZ /sbin/kpartx

If it is not labeled lvm_exec_t can you change its label to this, and try again

chcon -t lvm_exec_t /sbin/kpartx

Comment 2 Milos Malik 2011-05-12 07:19:20 UTC
Current state:

# ls -Z /sbin/kpartx
-rwxr-xr-x  root root system_u:object_r:sbin_t:SystemLow /sbin/kpartx
# matchpathcon /sbin/kpartx
/sbn/kpartx	system_u:object_r:sbin_t:SystemLow
#

Comment 3 Milos Malik 2011-05-12 07:23:08 UTC
# chcon -t lvm_exec_t /sbin/kpartx
# ls -Z /sbin/kpartx
-rwxr-xr-x  root root system_u:object_r:lvm_exec_t:SystemLow /sbin/kpartx
# setenforce 0
# kpartx -v /dev/sda
sda1 : 0 208782 /dev/sda 63
sda2 : 0 488183220 /dev/sda 208845
# setenforce 1
# kpartx -v /dev/sda
failed to stat() /dev/sda
#

Comment 4 Milos Malik 2011-05-12 07:25:33 UTC
# setenforce 1
# semodule -DB
# kpartx -v /dev/sda
failed to stat() /dev/sda
# ausearch -m avc -m user_avc -ts recent
----
time->Thu May 12 03:23:44 2011
type=SYSCALL msg=audit(1305185024.393:194): arch=c000003e syscall=4 success=no exit=-13 a0=7fff915ddd99 a1=7fff915dc700 a2=7fff915dc700 a3=0 items=0 ppid=3647pid=3754 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=ttyS1 ses=2 comm="kpartx" exe="/sbin/kpartx" subj=root:sysadm_r:lvm_t:s0-s15c0.c1023 key=(null)
type=AVC msg=audit(1305185024.393:194): avc:  denied  { getattr } for  pid=3754 comm="kpartx" path="/dev/sda" dev=tmpfs ino=1142 scontext=root:sysadm_r:lvm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:fixed_disk_device_t:s15:c0.c1023 tclass=blk_file
----

Comment 5 Miroslav Grepl 2011-05-12 08:02:37 UTC
AFAIK we have the same issue in RHEL6?

Comment 6 Milos Malik 2011-05-12 11:50:01 UTC
It is fixed already. Here is the bug report:

https://bugzilla.redhat.com/show_bug.cgi?id=681887

Comment 7 Miroslav Grepl 2011-05-12 14:32:53 UTC
I need to backport

/sbin/kpartx        --  gen_context(system_u:object_r:lvm_exec_t,s0)


mls_file_read_all_levels(lvm_t)
mls_file_upgrade(lvm_t)

and probably other lvm fixes which have been done in RHEL6.

Comment 8 Daniel Walsh 2011-05-12 16:26:15 UTC
Yes

Comment 10 Miroslav Grepl 2011-05-19 15:30:25 UTC
Fixed in selinux-policy-2.4.6-306.el5

Comment 13 errata-xmlrpc 2011-07-21 09:20:15 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-1069.html

Comment 14 errata-xmlrpc 2011-07-21 11:56:44 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-1069.html