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 2009769 - DBus unable to send_msg to cloud-init when "sudo" or "su" is used in cloud-init "user-data" scripts
Summary: DBus unable to send_msg to cloud-init when "sudo" or "su" is used in cloud-in...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.4
Hardware: Unspecified
OS: Linux
medium
medium
Target Milestone: rc
: 8.6
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-01 14:19 UTC by Stepan Broz
Modified: 2024-03-25 18:17 UTC (History)
4 users (show)

Fixed In Version: selinux-policy-3.14.3-84.el8
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-10 15:15:05 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-98677 0 None None None 2021-10-01 14:51:53 UTC
Red Hat Knowledge Base (Solution) 5692661 0 None None None 2021-10-01 14:25:34 UTC
Red Hat Product Errata RHBA-2022:1995 0 None None None 2022-05-10 15:15:23 UTC

Description Stepan Broz 2021-10-01 14:19:43 UTC
Description of problem:


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


How reproducible:
Always

Steps to Reproduce:
1. Download KVM Guest Image from:
    https://access.redhat.com/downloads/content/479/ver=/rhel---8/8.4/x86_64/product-software

2.Place it in "/var/lib/libvirt/images/rhel-guest-image-8.4-992.x86_64.qcow2"

3. Create cidata.iso using the steps below:

    # mkdir ci; cd ci
    # vi meta-data
--8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<------
instance-id: foobar
local-hostname: foobar.example.com
--8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<------

    # vi user-data
--8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<------
#cloud-config
password: redhat
chpasswd: { expire: False }
ssh_pwauth: True
ssh_authorized_keys:
   - <place_your_SSH_pubkey_here>
runcmd:
   - su - -c date >~/testfile
--8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<------

    # mkisofs -o /var/lib/libvirt/images/cidata.iso -J -R -V cidata .

4. Create a new VM using rhel-guest-image-8.4-992.x86_64.qcow2 as disk drive and cidata.iso as a CD-ROM, boot it.


Actual results:
Extra 25 seconds delay with SELinux enabled and enforcing, AVC denial in audit.log as follows:

type=USER_AVC msg=audit(1633097673.446:66): pid=652 uid=81 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_return dest=:1.19 spid=723 tpid=1434 scontext=system_u:system_r:systemd_logind_t:s0 tcontext=system_u:system_r:cloud_init_t:s0 tclass=dbus permissive=0  exe="/usr/bin/dbus-daemon" sauid=81 hostname=? addr=? terminal=?'UID="dbus" AUID="unset" SAUID="dbus"

Expected results:
No AVC, no extra delay.

Additional info:
https://access.redhat.com/solutions/5692661

Suggests:
--8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<------

policy_module(cloud_init_sudo, 1.0)

gen_require(`
type cloud_init_t;
type systemd_logind_t;
class dbus send_msg;
')

allow systemd_logind_t cloud_init_t:dbus send_msg;
allow cloud_init_t systemd_logind_t:dbus send_msg;

--8<--------8<--------8<--------8<--------8<--------8<--------8<--------8<------

Comment 1 Patrik Koncity 2021-10-20 09:55:23 UTC
Hi Stepan, 

please can you reproduce the scenario again and attach here full AVC's messages in permissive mode?

Steps to enable full auditing and permissive SELinux mode:

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) Open the /etc/selinux/config file in an editor.
change line
SELINUX=enforcing
to
SELINUX=permissive
6) Re-run your scenario 
7) Collect AVC denials:
# ausearch -i -m avc,user_avc,selinux_err,user_selinux_err -ts today

Thank you,
Patrik

Comment 2 Stepan Broz 2021-11-04 14:00:02 UTC
Unfortunately the reproducer uses a vanilla guest image, as taken from the customer portal, that I am unable to modify. (guestfish fails to mount the image read-write)
cloud-init does not run the second time post-install, I believe.

I cannot provide the data you requested.

Comment 4 Zdenek Pytela 2021-11-25 11:15:13 UTC
(In reply to Stepan Broz from comment #2)
> Unfortunately the reproducer uses a vanilla guest image, as taken from the
> customer portal, that I am unable to modify. (guestfish fails to mount the
> image read-write)
> cloud-init does not run the second time post-install, I believe.
> 
> I cannot provide the data you requested.

Stepane,

The new policy build is on the way, we will however hardly be able to test a complex scenario similar enough to the customer's environment, so there is a risk the fix is not complete. Do you think they will be able to test the selinux-policy package?

Comment 5 Stepan Broz 2021-11-25 11:18:18 UTC
I will do my test and will follow-up with the customer, no worries!

Just let me know when it's ready.

Comment 12 errata-xmlrpc 2022-05-10 15:15:05 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:1995


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