Bug 1806894

Summary: AVC for nm-cloud-setup.service
Product: Red Hat Enterprise Linux 8 Reporter: Vladimir Benes <vbenes>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: high Docs Contact:
Priority: high    
Version: 8.2CC: lmiksik, lvrabec, mmalik, plautrba, ssekidde, thaller, zpytela
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 16:41:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1642461, 1823315    

Description Vladimir Benes 2020-02-25 09:47:05 UTC
Description of problem:
time->Tue Feb 25 04:37:13 2020
type=PROCTITLE msg=audit(1582623433.910:5879): proctitle=73797374656D63746C002D710069732D656E61626C6564006E6D2D636C6F75642D73657475702E73657276696365
type=SYSCALL msg=audit(1582623433.910:5879): arch=c000003e syscall=6 success=no exit=-13 a0=5567f7451130 a1=7fffeff00110 a2=7fffeff00110 a3=0 items=0 ppid=32330 pid=32331 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="systemctl" exe="/usr/bin/systemctl" subj=system_u:system_r:NetworkManager_t:s0 key=(null)
type=AVC msg=audit(1582623433.910:5879): avc:  denied  { getattr } for  pid=32331 comm="systemctl" path="/usr/lib/systemd/system/nm-cloud-setup.service" dev="dm-0" ino=34150428 scontext=system_u:system_r:NetworkManager_t:s0 tcontext=system_u:object_r:systemd_unit_file_t:s0 tclass=file permissive=0

Version-Release number of selected component (if applicable):
1.22.8

How reproducible:
always

Steps to Reproduce:
1. NM test suite

Actual results:
flood of AVCs

Expected results:
no AVCs

Additional info:

Comment 1 Milos Malik 2020-02-25 10:21:19 UTC
Where can I find the NM test suite?

I would like to see why systemctl is running under NetworkManager_t context.

Comment 2 Milos Malik 2020-02-25 14:14:03 UTC
Caught in enforcing mode:
----
type=PROCTITLE msg=audit(02/25/2020 09:12:34.608:661) : proctitle=systemctl -q is-enabled nm-cloud-setup.service 
type=PATH msg=audit(02/25/2020 09:12:34.608:661) : item=0 name=/usr/lib/systemd/system/nm-cloud-setup.service inode=34294278 dev=fd:00 mode=file,644 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:systemd_unit_file_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 
type=CWD msg=audit(02/25/2020 09:12:34.608:661) : cwd=/ 
type=SYSCALL msg=audit(02/25/2020 09:12:34.608:661) : arch=x86_64 syscall=lstat success=no exit=EACCES(Permission denied) a0=0x55f599d0b130 a1=0x7ffd2d4ca470 a2=0x7ffd2d4ca470 a3=0x0 items=1 ppid=29372 pid=29373 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=systemctl exe=/usr/bin/systemctl subj=system_u:system_r:NetworkManager_t:s0 key=(null) 
type=AVC msg=audit(02/25/2020 09:12:34.608:661) : avc:  denied  { getattr } for  pid=29373 comm=systemctl path=/usr/lib/systemd/system/nm-cloud-setup.service dev="dm-0" ino=34294278 scontext=system_u:system_r:NetworkManager_t:s0 tcontext=system_u:object_r:systemd_unit_file_t:s0 tclass=file permissive=0 
----

Caught in permissive mode:
----
type=PROCTITLE msg=audit(02/25/2020 09:13:27.154:670) : proctitle=systemctl -q is-enabled nm-cloud-setup.service 
type=PATH msg=audit(02/25/2020 09:13:27.154:670) : item=0 name=/usr/lib/systemd/system/nm-cloud-setup.service inode=34294278 dev=fd:00 mode=file,644 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:systemd_unit_file_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 
type=CWD msg=audit(02/25/2020 09:13:27.154:670) : cwd=/ 
type=SYSCALL msg=audit(02/25/2020 09:13:27.154:670) : arch=x86_64 syscall=lstat success=yes exit=0 a0=0x558601234130 a1=0x7ffdbd397c50 a2=0x7ffdbd397c50 a3=0x0 items=1 ppid=29560 pid=29561 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=systemctl exe=/usr/bin/systemctl subj=system_u:system_r:NetworkManager_t:s0 key=(null) 
type=AVC msg=audit(02/25/2020 09:13:27.154:670) : avc:  denied  { getattr } for  pid=29561 comm=systemctl path=/usr/lib/systemd/system/nm-cloud-setup.service dev="dm-0" ino=34294278 scontext=system_u:system_r:NetworkManager_t:s0 tcontext=system_u:object_r:systemd_unit_file_t:s0 tclass=file permissive=1 
----

Comment 4 Thomas Haller 2020-02-26 09:54:38 UTC
I think it's done by /usr/lib/NetworkManager/dispatcher.d/90-nm-cloud-setup.sh (which does [1]).

Note that /usr/lib/NetworkManager/dispatcher.d/90-nm-cloud-setup.sh is a symlink to "no-wait.d/90-nm-cloud-setup.sh".

These scripts in dispatcher.d are executed by NetworkManager-dispatcher service. They probably should not be labelled as NetworkManager_t.

See related issues bug 1781806 and bug 1777506.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/9add51ef16356da81a0fd5a8f3f0ddebeb093636/clients/cloud-setup/90-nm-cloud-setup.sh

Comment 5 Thomas Haller 2020-03-04 07:47:53 UTC
Hi Milos,

can this be fixed in time for rhel-8.2?

The SELinux denial in this case seems rather sever as it spams the logs and prevents the package from working. Arguably, nm-cloud-setup is still somewhat experimental and not installed by default. However, I would appreciate if we could solve the trivial(??) issues like this.

Comment 6 Thomas Haller 2020-03-04 07:49:38 UTC
> Hi Milos,

Ups, I meant Zdenek. Sorry.

Comment 7 Zdenek Pytela 2020-03-04 08:10:35 UTC
Thomas,

Given the current RHEL 8.2 state, exception flag is required to move forward.

Comment 10 Zdenek Pytela 2020-03-04 15:55:33 UTC
Granting devel_ack. It is considered as important based on the justification.

Comment 13 Zdenek Pytela 2020-03-06 15:24:50 UTC
I've submitted a Fedora PR to address the issue:

https://github.com/fedora-selinux/selinux-policy-contrib/pull/213

Comment 42 errata-xmlrpc 2020-04-28 16:41:41 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://access.redhat.com/errata/RHBA-2020:1773