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 1754719 - [RHEL-8] avc: denied { write } for pid=3026 comm="ibacm" name="shm" dev="devtmpfs"
Summary: [RHEL-8] avc: denied { write } for pid=3026 comm="ibacm" name="shm" dev="d...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
: 1813841 (view as bug list)
Depends On:
Blocks: 1802014
TreeView+ depends on / blocked
 
Reported: 2019-09-24 02:10 UTC by zguo
Modified: 2020-11-04 01:56 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 01:55:53 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:4528 0 None None None 2020-11-04 01:56:19 UTC

Description zguo 2019-09-24 02:10:25 UTC
Description of problem:


Version-Release number of selected component (if applicable):
RHEL-8.1.0-20190917.0
selinux-policy-3.14.3-20.el8.noarch
4.18.0-144.el8.x86_64

How reproducible:


Steps to Reproduce:
1. Run /kernel/infiniband/ibacm on machines with RDMA HCA.

A specific reproducer: 
https://beaker.engineering.redhat.com/jobs/3790857
https://beaker.engineering.redhat.com/recipes/7361750#task99350627

Actual results:
https://beaker.engineering.redhat.com/recipes/7361750/tasks/99350627/results/457272286/logs/avc.log

SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      31
selinux-policy-3.14.3-20.el8.noarch
----
time->Tue Sep 17 21:40:52 2019
type=PROCTITLE msg=audit(1568770852.331:894): proctitle=2F7573722F7362696E2F696261636D002D2D73797374656D64
type=SYSCALL msg=audit(1568770852.331:894): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=7f6b22f90b30 a2=a0042 a3=1a4 items=0 ppid=1 pid=2518 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="ibacm" exe="/usr/sbin/ibacm" subj=system_u:system_r:ibacm_t:s0 key=(null)
type=AVC msg=audit(1568770852.331:894): avc:  denied  { write } for  pid=2518 comm="ibacm" name="shm" dev="devtmpfs" ino=15466 scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:object_r:device_t:s0 tclass=dir permissive=0
----
time->Tue Sep 17 21:40:53 2019
type=PROCTITLE msg=audit(1568770853.960:899): proctitle=2F7573722F7362696E2F696261636D002D2D73797374656D64
type=SYSCALL msg=audit(1568770853.960:899): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=7fe1ce509b30 a2=a0042 a3=1a4 items=0 ppid=1 pid=2816 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="ibacm" exe="/usr/sbin/ibacm" subj=system_u:system_r:ibacm_t:s0 key=(null)
type=AVC msg=audit(1568770853.960:899): avc:  denied  { write } for  pid=2816 comm="ibacm" name="shm" dev="devtmpfs" ino=15466 scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:object_r:device_t:s0 tclass=dir permissive=0
----
time->Tue Sep 17 21:40:54 2019
type=PROCTITLE msg=audit(1568770854.896:905): proctitle=2F7573722F7362696E2F696261636D002D2D73797374656D64
type=SYSCALL msg=audit(1568770854.896:905): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=7fcfef0d0b30 a2=a0042 a3=1a4 items=0 ppid=1 pid=2921 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="ibacm" exe="/usr/sbin/ibacm" subj=system_u:system_r:ibacm_t:s0 key=(null)
type=AVC msg=audit(1568770854.896:905): avc:  denied  { write } for  pid=2921 comm="ibacm" name="shm" dev="devtmpfs" ino=15466 scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:object_r:device_t:s0 tclass=dir permissive=0
----
time->Tue Sep 17 21:40:55 2019
type=PROCTITLE msg=audit(1568770855.807:911): proctitle=2F7573722F7362696E2F696261636D002D2D73797374656D64
type=SYSCALL msg=audit(1568770855.807:911): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=7fb83aa87b30 a2=a0042 a3=1a4 items=0 ppid=1 pid=3026 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="ibacm" exe="/usr/sbin/ibacm" subj=system_u:system_r:ibacm_t:s0 key=(null)
type=AVC msg=audit(1568770855.807:911): avc:  denied  { write } for  pid=3026 comm="ibacm" name="shm" dev="devtmpfs" ino=15466 scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:object_r:device_t:s0 tclass=dir permissive=0


Expected results:

No avc:  denied  { write } for  pid=3026 comm="ibacm" name="shm" dev="devtmpfs" ino=15466 

Additional info:

Comment 1 Milos Malik 2019-09-24 07:00:45 UTC
Could you tell me the whole path to "shm" directory which is mentioned in the SELinux denial? The "ino=15466" part of the SELinux denial indicates the inode number.

# find / -type d -inum 15466

Unfortunately, the inode number can be different on each machine.

If the "shm" directory is in fact /dev/shm directory, then it is mislabeled. The correct label for /dev/shm is tmpfs_t:

$ matchpathcon /dev/shm
/dev/shm	system_u:object_r:tmpfs_t:s0
$

Comment 2 zguo 2019-10-12 02:46:59 UTC
I ran another test, 

https://beaker.engineering.redhat.com/jobs/3837163
https://beaker.engineering.redhat.com/recipes/7460083/tasks/100675158/results/463431172/logs/avc.log

[root@rdma-perf-01 ~]$ find / -type d -inum 19468
/dev/shm
find: ‘/proc/27613’: No such file or directory
[root@rdma-perf-01 ~]$ matchpathcon /dev/shm
/dev/shm	system_u:object_r:tmpfs_t:s0

Comment 4 zguo 2020-03-17 03:57:48 UTC
*** Bug 1813841 has been marked as a duplicate of this bug. ***

Comment 5 Zdenek Pytela 2020-03-17 15:57:06 UTC
Hi,

I'd like to start with the write permission. The /dev/shm is a tmpfs filesystem with the default tmpfs_t type. In the denials, we can see a write attempt:

time->Fri Mar 13 05:38:22 2020
type=AVC msg=audit(1584092302.386:591): avc:  denied  { write } for  pid=188857 comm="ibacm" name="shm" dev="devtmpfs" ino=24617 scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:object_r:device_t:s0 tclass=dir permissive=0

actually to devtmpfs which should be mounted on the parent directory, to a filename in comment c#2 isolated as /dev/shm. Is it possible that at some point of the test the /dev/shm filesystem was unmounted and the directory removed?

Please run the following commands at the time of the denials reported:

ls -Zla /dev/shm
cat /proc/mounts

Comment 6 zguo 2020-03-20 02:42:06 UTC
(In reply to Zdenek Pytela from comment #5)
> Hi,
> 
> I'd like to start with the write permission. The /dev/shm is a tmpfs
> filesystem with the default tmpfs_t type. In the denials, we can see a write
> attempt:
> 
> time->Fri Mar 13 05:38:22 2020
> type=AVC msg=audit(1584092302.386:591): avc:  denied  { write } for 
> pid=188857 comm="ibacm" name="shm" dev="devtmpfs" ino=24617
> scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:object_r:device_t:s0
> tclass=dir permissive=0
> 
> actually to devtmpfs which should be mounted on the parent directory, to a
> filename in comment c#2 isolated as /dev/shm. Is it possible that at some
> point of the test the /dev/shm filesystem was unmounted and the directory
> removed?
> 
> Please run the following commands at the time of the denials reported:
> 
> ls -Zla /dev/shm
> cat /proc/mounts

[root@rdma-qe-14 ~]$ ls -Zla /dev/shm
total 4
drwxrwxrwt.  2 root root system_u:object_r:tmpfs_t:s0         60 Mar 19 22:27 .
drwxr-xr-x. 21 root root system_u:object_r:device_t:s0      3280 Mar 20  2020 ..
-rw-r--r--.  1 root root system_u:object_r:ibacm_tmpfs_t:s0  160 Mar 19 22:33 INTEL_SA_DSC

[root@rdma-qe-14 ~]$ cat /proc/mounts
sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=16317908k,nr_inodes=4079477,mode=755 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
tmpfs /sys/fs/cgroup tmpfs ro,seclabel,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,seclabel,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,seclabel,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,seclabel,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,seclabel,nosuid,nodev,noexec,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,seclabel,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,seclabel,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,seclabel,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,seclabel,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,seclabel,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/rdma cgroup rw,seclabel,nosuid,nodev,noexec,relatime,rdma 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,seclabel,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,seclabel,nosuid,nodev,noexec,relatime,perf_event 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
/dev/mapper/rhel_rdma--qe--14-root / xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=39,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=26798 0 0
debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0
mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0
/dev/sda1 /boot xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
/dev/mapper/rhel_rdma--qe--14-home /home xfs rw,seclabel,relatime,attr2,inode64,noquota 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
tmpfs /run/user/0 tmpfs rw,seclabel,nosuid,nodev,relatime,size=3267152k,mode=700 0 0

Comment 7 Zdenek Pytela 2020-03-20 08:12:01 UTC
Thank you for the commands output, it looks correct, type for /dev/shm is tmpfs_t and the tmpfs filesystem is mounted. Are there any AVC denials audited now?

Comment 8 zguo 2020-03-20 08:40:20 UTC
(In reply to Zdenek Pytela from comment #7)
> Thank you for the commands output, it looks correct, type for /dev/shm is
> tmpfs_t and the tmpfs filesystem is mounted. Are there any AVC denials
> audited now?


Did not notice denied  { write }, still can see below denied.

[root@rdma-qe-14 ~]$ rpm -q selinux-policy
selinux-policy-3.14.3-41.el8.noarch

type=AVC msg=audit(1584671533.260:199): avc:  denied  { create } for  pid=29470 comm="sm" scontext=system_u:system_r:opafm_t:s0 tcontext=system_u:system_r:opafm_t:s0 tclass=netlink_rdma_socket permissive=0
type=AVC msg=audit(1584671536.105:200): avc:  denied  { ipc_lock } for  pid=29188 comm="ibacm" capability=14  scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:system_r:ibacm_t:s0 tclass=capability permissive=0
type=SERVICE_START msg=audit(1584671543.905:201): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'^]UID="root" AUID="unset"
type=SERVICE_STOP msg=audit(1584671554.078:202): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=NetworkManager-dispatcher comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'^]UID="root" AUID="unset"
type=SERVICE_START msg=audit(1584671589.611:203): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=ibacm comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'^]UID="root" AUID="unset"
type=SERVICE_STOP msg=audit(1584671589.611:204): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=ibacm comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'^]UID="root" AUID="unset"
type=AVC msg=audit(1584671589.620:205): avc:  denied  { ipc_lock } for  pid=29604 comm="ibacm" capability=14  scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:system_r:ibacm_t:s0 tclass=capability permissive=0
type=AVC msg=audit(1584671589.626:206): avc:  denied  { ipc_lock } for  pid=29604 comm="ibacm" capability=14  scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:system_r:ibacm_t:s0 tclass=capability permissive=0
type=AVC msg=audit(1584671589.634:207): avc:  denied  { ipc_lock } for  pid=29604 comm="ibacm" capability=14  scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:system_r:ibacm_t:s0 tclass=capability permissive=0

Comment 10 Zdenek Pytela 2020-03-20 09:46:49 UTC
Hi,

ibacm requests this capability:

/* Allow locking of shared memory segments */
/* Allow mlock and mlockall (which doesn't really have anything to do
   with IPC) */

#define CAP_IPC_LOCK         14

Is it correct and expected?

Comment 11 Zdenek Pytela 2020-03-20 09:49:52 UTC
The netlink_rdma_socket permission will be allowed with resolving the following bz:
https://bugzilla.redhat.com/show_bug.cgi?id=1786670

Comment 12 Honggang LI 2020-03-23 08:52:16 UTC
(In reply to Zdenek Pytela from comment #10)
> Hi,
> 
> ibacm requests this capability:
> 
> /* Allow locking of shared memory segments */
> /* Allow mlock and mlockall (which doesn't really have anything to do
>    with IPC) */
> 
> #define CAP_IPC_LOCK         14
> 
> Is it correct and expected?

Why you suspect it may be incorrect?

I tried to locate which function in ibacm requests this capability. But I failed.
I tried to check the mlock/mlockall/mmap/shmctl functions in source code.

How to locate which function triggered the AVC message?

thanks

Comment 13 Zdenek Pytela 2020-03-23 16:12:06 UTC
(In reply to Honggang LI from comment #12)
> (In reply to Zdenek Pytela from comment #10)
> > Hi,
> > 
> > ibacm requests this capability:
> > 
> > /* Allow locking of shared memory segments */
> > /* Allow mlock and mlockall (which doesn't really have anything to do
> >    with IPC) */
> > 
> > #define CAP_IPC_LOCK         14
> > 
> > Is it correct and expected?
> 
> Why you suspect it may be incorrect?
It is not considered as suspect, but rather caution is in place. If a new permission is required, is it due to a new functionality or is it a side-effect of some other change? What has changed in the software recently? Questions like this need to be answered first.

> I tried to locate which function in ibacm requests this capability. But I
> failed.
> I tried to check the mlock/mlockall/mmap/shmctl functions in source code.
> 
> How to locate which function triggered the AVC message?
Full auditing can be enabled with a similar command:

auditctl -w /etc/shadow -p w -k shadow-write

so that additional data, which may turn out to be useful, are audited.

Comment 14 Honggang LI 2020-03-24 14:05:40 UTC
(In reply to Zdenek Pytela from comment #13)
> (In reply to Honggang LI from comment #12)
> > (In reply to Zdenek Pytela from comment #10)
> > > Hi,
> > > 
> > > ibacm requests this capability:
> > > 
> > > /* Allow locking of shared memory segments */
> > > /* Allow mlock and mlockall (which doesn't really have anything to do
> > >    with IPC) */
> > > 
> > > #define CAP_IPC_LOCK         14
> > > 
> > > Is it correct and expected?
> > 
> > Why you suspect it may be incorrect?
> It is not considered as suspect, but rather caution is in place. If a new
> permission is required, is it due to a new functionality or is it a
> side-effect of some other change? What has changed in the software recently?
> Questions like this need to be answered first.

kernel drivers/infiniband/core changes between kernel-4.18.0-80.el8 and kernel-4.18.0-81.el8
requests the new permission.

Comment 15 Ondrej Mosnacek 2020-03-24 14:17:36 UTC
(In reply to Honggang LI from comment #14)
> kernel drivers/infiniband/core changes between kernel-4.18.0-80.el8 and
> kernel-4.18.0-81.el8 requests the new permission.

Ah, looks like the backport of this commit caused it:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d4b4dd1b9706e48c370f88d3adfe713e43423cc9

Not familiar with Infiniband, but from the code it looks like the need to lock memory is inherently needed when interfacing with the Infiniband driver, so I'd say the need for CAP_IPC_LOCK is justified here. It wasn't needed before only as a result of kernel bug (IIUC).

Thank you for helping us identify the root cause, Honggang!

Comment 16 Zdenek Pytela 2020-03-24 14:43:16 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy-contrib/pull/224

For the record: There were also 2 other permission mentioned earlier in the bug:

type=AVC msg=audit(1584092302.386:591): avc:  denied  { write } for  pid=188857 comm="ibacm" name="shm" dev="devtmpfs" ino=24617 scontext=system_u:system_r:ibacm_t:s0 tcontext=system_u:object_r:device_t:s0 tclass=dir permissive=0

This one was not reproduced again.

type=AVC msg=audit(1584671533.260:199): avc:  denied  { create } for  pid=29470 comm="sm" scontext=system_u:system_r:opafm_t:s0 tcontext=system_u:system_r:opafm_t:s0 tclass=netlink_rdma_socket permissive=0

Handled in https://bugzilla.redhat.com/show_bug.cgi?id=1786670. Based on comment #2, is expected to be fixed in RHEL 8.3.

Comment 17 Lukas Vrabec 2020-03-24 15:26:42 UTC
Fixed in Fedora: 
commit b5e7044dbca7f591d275e9b7895ad6e76e3ca906 (HEAD -> rawhide, origin/rawhide, origin/HEAD)
Author: Zdenek Pytela <zpytela>
Date:   Tue Mar 24 15:28:35 2020 +0100

    Add ibacm_t ipc_lock capability
    
    Add ibacm_t the ipc_lock capability to support the update in kernel
    to handle memory locking when interfacing with the Infiniband driver.

Comment 29 errata-xmlrpc 2020-11-04 01:55:53 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 (selinux-policy bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2020:4528


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