Bug 2085392
| Summary: | SELinux prevents dbus-broker from ioctl and getopt on a unix_stream_socket labeled kernel_t | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | Bruno Goncalves <bgoncalv> |
| Component: | selinux-policy | Assignee: | Nikola Knazekova <nknazeko> |
| Status: | CLOSED ERRATA | QA Contact: | Milos Malik <mmalik> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | CentOS Stream | CC: | bstinson, jwboyer, lvrabec, mmalik, nknazeko, omosnace, ssekidde, zpytela |
| Target Milestone: | rc | Keywords: | Triaged |
| Target Release: | 9.1 | Flags: | pm-rhel:
mirror+
|
| Hardware: | s390x | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | selinux-policy-34.1.41-1.el9 | Doc Type: | Bug Fix |
| Doc Text: |
Cause:
Systemd creates and starts to listen on the socket before SELinux policy is loaded and it inherits the kernel secid as its label.
Consequence:
SELinux is preventing system_dbusd ioctl kernel with a unix stream sockets.
Fix:
Allow system_dbusd ioctl kernel with a unix stream sockets. Create interface to allow the specified domain to ioctl a kernel with a unix domain stream sockets
Result:
No AVC
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2022-11-15 11:13:50 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: | |||
Bruno, We need to have more information, preferably reproducing steps, or also access to the system if you happen to catch it again. Full auditing may also help if set prior to the denial: 1) Open the /etc/audit/rules.d/audit.rules file in an editor. 2) Remove the following line if it exists: -a task,never 3) Add the following line to the end of the file: -w /etc/shadow -p w 4) Restart the audit daemon: # service auditd restart 5) Re-run your scenario. 6) Collect AVC denials: # ausearch -i -m avc,user_avc,selinux_err,user_selinux_err -ts today Ondro, Can you help us with understanding what is going on here and to assess if the request is legit, either from SELinux PoV or s390x kernel? If I am not mistaken, it is TIOCOUTQ: https://access.redhat.com/labs/rhcb/RHEL-9.0/kernel-5.14.0-70.13.1.el9/source/blob/include/uapi/asm-generic/ioctls.h#L36 #define TIOCOUTQ 0x5411 https://access.redhat.com/labs/rhcb/RHEL-9.0/kernel-5.14.0-70.13.1.el9/source/blob/include/uapi/linux/sockios.h#L27#define SIOCOUTQ TIOCOUTQ /* output queue size (not sent + not acked) */ Yes, I think the ioctl is legitimate. The label is kernel_t probably because systemd creates and starts to listen on this socket before SELinux policy is loaded and it inherits the kernel secid as its label. (This is the same problem as with the journal socket.) The getopt is probably fine as well (dbusd just wants to get some info about the socket, likely for performance reasons).
BTW, tcp(7) has a slightly more verbose description of SIOCOUTQ/TIOCOUTQ:
SIOCOUTQ
Returns the amount of unsent data in the socket send queue. The socket must not be in LISTEN state, otherwise an error (EINVAL) is returned. SIOCOUTQ is defined in <linux/sockios.h>. Alternatively, you can use the synonymous TIOCOUTQ, defined in <sys/ioctl.h>.
I have been trying to reproduce this issue with full audit enabled, but so far I had no luck reproducing it... 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-2022:8283 |
Description of problem: When booting an s390x kvm machine sometimes we hit the following avc denials: ---- time->Thu May 12 12:43:07 2022 type=AVC msg=audit(1652373787.561:440): avc: denied { ioctl } for pid=731 comm="dbus-broker" path="socket:[45554]" dev="sockfs" ino=45554 ioctlcmd=0x5411 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=1 ---- time->Thu May 12 12:43:24 2022 type=AVC msg=audit(1652373804.591:467): avc: denied { getopt } for pid=731 comm="dbus-broker" path="/run/dbus/system_bus_socket" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=1 ---- time->Thu May 12 12:43:24 2022 type=AVC msg=audit(1652373804.591:468): avc: denied { ioctl } for pid=731 comm="dbus-broker" path="socket:[45847]" dev="sockfs" ino=45847 ioctlcmd=0x5411 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=1 ---- time->Thu May 12 12:44:26 2022 type=AVC msg=audit(1652373866.241:496): avc: denied { getopt } for pid=731 comm="dbus-broker" path="/run/dbus/system_bus_socket" scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=1 ---- time->Thu May 12 12:44:26 2022 type=AVC msg=audit(1652373866.261:497): avc: denied { ioctl } for pid=731 comm="dbus-broker" path="socket:[57881]" dev="sockfs" ino=57881 ioctlcmd=0x5411 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0-s0:c0.c1023 tclass=unix_stream_socket permissive=1 Version-Release number of selected component (if applicable): selinux-policy-34.1.32-1.el9.noarch How reproducible: how sure yet Steps to Reproduce: 1. Boot up the machine 2. Check for avc denial Additional info: SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: permissive Mode from config file: permissive Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: actual (secure) Max kernel policy version: 33 selinux-policy-34.1.32-1.el9.noarch more logs: https://datawarehouse.cki-project.org/kcidb/tests/3490001 https://s3.amazonaws.com/arr-cki-prod-trusted-artifacts/trusted-artifacts/537627901/test%20s390x/2448515113/artifacts/run.done.01/results_0001/index.html cki issue tracker: https://datawarehouse.cki-project.org/issue/1166