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 2017838 - Running systemctl status of user triggered AVC denials
Summary: Running systemctl status of user triggered AVC denials
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: selinux-policy
Version: 9.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 9.0
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks: 1778780 2046481
TreeView+ depends on / blocked
 
Reported: 2021-10-27 14:04 UTC by Patrik Koncity
Modified: 2022-05-17 16:11 UTC (History)
3 users (show)

Fixed In Version: selinux-policy-34.1.19-1.el9
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 2046481 (view as bug list)
Environment:
Last Closed: 2022-05-17 15:49:53 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-101291 0 None None None 2021-11-01 19:34:18 UTC
Red Hat Product Errata RHBA-2022:3918 0 None None None 2022-05-17 15:50:11 UTC

Description Patrik Koncity 2021-10-27 14:04:43 UTC
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

Comment 1 Milos Malik 2021-11-02 07:17:47 UTC
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.
$

Comment 2 Patrik Koncity 2021-11-02 12:02:54 UTC
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

Comment 3 Zdenek Pytela 2021-11-26 16:34:11 UTC
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

Comment 14 errata-xmlrpc 2022-05-17 15:49: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 (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


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