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 2085392 - SELinux prevents dbus-broker from ioctl and getopt on a unix_stream_socket labeled kernel_t
Summary: SELinux prevents dbus-broker from ioctl and getopt on a unix_stream_socket la...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: selinux-policy
Version: CentOS Stream
Hardware: s390x
OS: Linux
medium
medium
Target Milestone: rc
: 9.1
Assignee: Nikola Knazekova
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-05-13 08:55 UTC by Bruno Goncalves
Modified: 2022-11-15 12:58 UTC (History)
8 users (show)

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
Clone Of:
Environment:
Last Closed: 2022-11-15 11:13:50 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-121948 0 None None None 2022-05-13 09:05:45 UTC
Red Hat Product Errata RHBA-2022:8283 0 None None None 2022-11-15 11:14:09 UTC

Description Bruno Goncalves 2022-05-13 08:55:02 UTC
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

Comment 1 Zdenek Pytela 2022-05-27 11:55:20 UTC
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

Comment 2 Zdenek Pytela 2022-05-27 11:59:00 UTC
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) */

Comment 3 Ondrej Mosnacek 2022-05-27 12:56:42 UTC
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>.

Comment 4 Bruno Goncalves 2022-06-01 15:08:25 UTC
I have been trying to reproduce this issue with full audit enabled, but so far I had no luck reproducing it...

Comment 13 errata-xmlrpc 2022-11-15 11:13:50 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-2022:8283


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