Bug 703482 - enforcing MLS -- AVCs appear when running "kpartx -v /dev/sda"
enforcing MLS -- AVCs appear when running "kpartx -v /dev/sda"
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: selinux-policy (Show other bugs)
5.7
All Linux
medium Severity medium
: rc
: ---
Assigned To: Miroslav Grepl
Milos Malik
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-10 09:45 EDT by Milos Malik
Modified: 2012-10-16 07:16 EDT (History)
2 users (show)

See Also:
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 05:20:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Milos Malik 2011-05-10 09:45:31 EDT
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 01:47:12 EDT
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 03:19:20 EDT
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 03:23:08 EDT
# 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 03:25:33 EDT
# 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 04:02:37 EDT
AFAIK we have the same issue in RHEL6?
Comment 6 Milos Malik 2011-05-12 07:50:01 EDT
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 10:32:53 EDT
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 12:26:15 EDT
Yes
Comment 10 Miroslav Grepl 2011-05-19 11:30:25 EDT
Fixed in selinux-policy-2.4.6-306.el5
Comment 13 errata-xmlrpc 2011-07-21 05:20:15 EDT
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 07:56:44 EDT
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

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