Bug 2017838
| Summary: | Running systemctl status of user triggered AVC denials | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | Patrik Koncity <pkoncity> | |
| Component: | selinux-policy | Assignee: | Zdenek Pytela <zpytela> | |
| Status: | CLOSED ERRATA | QA Contact: | Milos Malik <mmalik> | |
| Severity: | medium | Docs Contact: | ||
| Priority: | medium | |||
| Version: | 9.0 | CC: | lvrabec, mmalik, ssekidde | |
| Target Milestone: | rc | Keywords: | AutoVerified, Triaged | |
| Target Release: | 9.0 | Flags: | pm-rhel:
mirror+
|
|
| Hardware: | All | |||
| OS: | Linux | |||
| Whiteboard: | ||||
| Fixed In Version: | selinux-policy-34.1.19-1.el9 | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 2046481 (view as bug list) | Environment: | ||
| Last Closed: | 2022-05-17 15:49:53 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: | 1778780, 2046481 | |||
Surprisingly, there are no SELinux denials in enforcing mode and the systemctl output looks this way:
$ id
uid=1000(basic_user) gid=1000(basic_user) groups=1000(basic_user),10(wheel) context=user_u:user_r:user_t:s0
$ systemctl status user@1000
× user - User Manager for UID 1000
Loaded: loaded (/usr/lib/systemd/system/user@.service; static)
Active: failed (Result: exit-code) since Tue 2021-11-02 03:08:29 EDT; 6min ago
Docs: man:user@.service(5)
Process: 3957 ExecStart=/usr/lib/systemd/systemd --user (code=exited, status=1/FAILURE)
Main PID: 3957 (code=exited, status=1/FAILURE)
CPU: 53ms
$
After switching to permissive mode, the picture becomes clearer now:
$ id
uid=1000(basic_user) gid=1000(basic_user) groups=1000(basic_user),10(wheel) context=user_u:user_r:user_t:s0
$ systemctl status user@1000
× user - User Manager for UID 1000
Loaded: loaded (/usr/lib/systemd/system/user@.service; static)
Active: failed (Result: exit-code) since Tue 2021-11-02 03:08:29 EDT; 3min 30s ago
Docs: man:user@.service(5)
Process: 3957 ExecStart=/usr/lib/systemd/systemd --user (code=exited, status=1/FAILURE)
Main PID: 3957 (code=exited, status=1/FAILURE)
CPU: 53ms
Nov 02 03:08:29 localhost systemd[1]: Starting User Manager for UID 1000...
Nov 02 03:08:29 localhost systemd[3957]: pam_unix(systemd-user:session): session opened for user basic_user(uid=1000) by (uid=0)
Nov 02 03:08:29 localhost systemd[3957]: Failed to allocate manager object: Permission denied
Nov 02 03:08:29 localhost systemd[1]: user: Main process exited, code=exited, status=1/FAILURE
Nov 02 03:08:29 localhost systemd[1]: user: Failed with result 'exit-code'.
Nov 02 03:08:29 localhost systemd[1]: Failed to start User Manager for UID 1000.
$
Hi Milos,
we have several way how reproduce AVC's.
First,
try to change the configuration file /etc/selinux/config
in line
SELINUX=enforcing
to
SELINUX=permissive
then, reboot machine and you'll see AVC's in permissive mode. Machine need to be run in permissive mode for sucessfully start of systemctl.
Second way,
you must as root restart systemctl, but firstly you should set permissive mode via
# setenforce 0
then restart
# systemctl restart user@{UID of basic_user}
and then when you log in like user_u and show systemctl status of user, you are able to see whole permissive output.
Thanks, Patrik
Commits to backport:
commit 5d0c765573488ac5f1bf5f377d51173b3180883f
Author: Zdenek Pytela <zpytela>
Date: Wed May 5 13:38:36 2021 +0200
Allow login_userdomain read and map /var/lib/systemd files
and
https://github.com/fedora-selinux/selinux-policy/pull/955
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 (new packages: selinux-policy), 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-2022:3918 |
Description of problem: After running systemctl status of user, it appears a lot of AVC's. Version-Release number of selected component (if applicable): libselinux-3.2-6.el9.x86_64 libselinux-utils-3.2-6.el9.x86_64 rpm-plugin-selinux-4.16.1.3-7.el9.x86_64 selinux-policy-34.1.16-1.el9_b.noarch selinux-policy-targeted-34.1.16-1.el9_b.noarch python3-libselinux-3.2-6.el9.x86_64 selinux-policy-devel-34.1.16-1.el9_b.noarch How reproducible: Steps to Reproduce: 1.create user # useradd -Z user_u -G wheel basic_user # passwd basic_user 2.log into new user 3.systemctl status user@{UID of basic_user} Actual results: The audit shows a several AVC's ---- time->Wed Oct 27 09:45:16 2021 type=PROCTITLE msg=audit(1635342316.341:455): proctitle=73797374656D63746C0073746174757300757365724031303031 type=SYSCALL msg=audit(1635342316.341:455): arch=c000003e syscall=257 success=yes exit=6 a0=ffffff9c a1=7fff96d6e1c0 a2=80800 a3=0 items=0 ppid=4739 pid=4764 auid=1001 uid=1001 gid=1001 euid=1001 suid=1001 fsuid=1001 egid=1001 sgid=1001 fsgid=1001 tty=pts1 ses=10 comm="systemctl" exe="/usr/bin/systemctl" subj=user_u:user_r:user_t:s0 key=(null) type=AVC msg=audit(1635342316.341:455): avc: denied { open } for pid=4764 comm="systemctl" path="/run/log/journal/edb15570307f47dd805feee9003d4e08/system.journal" dev="tmpfs" ino=429 scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=1 type=AVC msg=audit(1635342316.341:455): avc: denied { read } for pid=4764 comm="systemctl" name="system.journal" dev="tmpfs" ino=429 scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=1 ---- time->Wed Oct 27 09:45:16 2021 type=PROCTITLE msg=audit(1635342316.342:456): proctitle=73797374656D63746C0073746174757300757365724031303031 type=SYSCALL msg=audit(1635342316.342:456): arch=c000003e syscall=9 success=yes exit=140444817846272 a0=0 a1=471000 a2=1 a3=1 items=0 ppid=4739 pid=4764 auid=1001 uid=1001 gid=1001 euid=1001 suid=1001 fsuid=1001 egid=1001 sgid=1001 fsgid=1001 tty=pts1 ses=10 comm="systemctl" exe="/usr/bin/systemctl" subj=user_u:user_r:user_t:s0 key=(null) type=AVC msg=audit(1635342316.342:456): avc: denied { map } for pid=4764 comm="systemctl" path="/run/log/journal/edb15570307f47dd805feee9003d4e08/system.journal" dev="tmpfs" ino=429 scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:syslogd_var_run_t:s0 tclass=file permissive=1 ---- time->Wed Oct 27 09:45:16 2021 type=PROCTITLE msg=audit(1635342316.343:457): proctitle=73797374656D63746C0073746174757300757365724031303031 type=SYSCALL msg=audit(1635342316.343:457): arch=c000003e syscall=257 success=yes exit=4 a0=ffffff9c a1=7fbbdcec9958 a2=80000 a3=0 items=0 ppid=4739 pid=4764 auid=1001 uid=1001 gid=1001 euid=1001 suid=1001 fsuid=1001 egid=1001 sgid=1001 fsgid=1001 tty=pts1 ses=10 comm="systemctl" exe="/usr/bin/systemctl" subj=user_u:user_r:user_t:s0 key=(null) type=AVC msg=audit(1635342316.343:457): avc: denied { open } for pid=4764 comm="systemctl" path="/var/lib/systemd/catalog/database" dev="vda1" ino=6352066 scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:init_var_lib_t:s0 tclass=file permissive=1 type=AVC msg=audit(1635342316.343:457): avc: denied { read } for pid=4764 comm="systemctl" name="database" dev="vda1" ino=6352066 scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:init_var_lib_t:s0 tclass=file permissive=1 ---- time->Wed Oct 27 09:45:16 2021 type=PROCTITLE msg=audit(1635342316.343:458): proctitle=73797374656D63746C0073746174757300757365724031303031 type=SYSCALL msg=audit(1635342316.343:458): arch=c000003e syscall=9 success=yes exit=140444813029376 a0=0 a1=27000 a2=1 a3=1 items=0 ppid=4739 pid=4764 auid=1001 uid=1001 gid=1001 euid=1001 suid=1001 fsuid=1001 egid=1001 sgid=1001 fsgid=1001 tty=pts1 ses=10 comm="systemctl" exe="/usr/bin/systemctl" subj=user_u:user_r:user_t:s0 key=(null) type=AVC msg=audit(1635342316.343:458): avc: denied { map } for pid=4764 comm="systemctl" path="/var/lib/systemd/catalog/database" dev="vda1" ino=6352066 scontext=user_u:user_r:user_t:s0 tcontext=system_u:object_r:init_var_lib_t:s0 tclass=file permissive=1 Expected results: It should not trigger these any denials. Additional info: Possible part of this fix is to add this commit to RHEL-9.0 https://github.com/fedora-selinux/selinux-policy/commit/5d0c765573488ac5f1bf5f377d51173b3180883f