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 1985818 - openmetrics scripting generates AVCs and no data with selinux enforcing
Summary: openmetrics scripting generates AVCs and no data with selinux enforcing
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: pcp
Version: 8.4
Hardware: All
OS: Linux
medium
medium
Target Milestone: beta
: 8.6
Assignee: pcp-maint
QA Contact: Jan Kurik
Apurva Bhide
URL:
Whiteboard:
Depends On:
Blocks: 1991763
TreeView+ depends on / blocked
 
Reported: 2021-07-26 00:14 UTC by Nathan Scott
Modified: 2022-05-10 13:49 UTC (History)
3 users (show)

Fixed In Version: pcp-5.3.3-1.el8
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-10 13:30:52 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2022:1765 0 None None None 2022-05-10 13:31:02 UTC

Description Nathan Scott 2021-07-26 00:14:37 UTC
Customer (Nationwide UK) reports AVCs attempting to run scripted mode of OpenMetrics agent ... excepts from their (copious) notes:



# tail -f /var/log/audit/audit.log | grep besclient

type=AVC msg=audit(1627127856.524:1612): avc:  denied  { execute } for  pid=9644 comm="bash" name="besclient" dev="dm-0" ino=8563925 scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:object_r:initrc_exec_t:s0 tclass=file permissive=1

type=AVC msg=audit(1627127856.524:1612): avc:  denied  { execute_no_trans } for  pid=9644 comm="bash" path="/etc/rc.d/init.d/besclient" dev="dm-0" ino=8563925 scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:object_r:initrc_exec_t:s0 tclass=file permissive=1

type=SYSCALL msg=audit(1627127856.524:1612): arch=80000016 syscall=11 success=yes exit=0 a0=2aa1adfd510 a1=2aa1ae003e0 a2=2aa1adfdac0 a3=2aa1adfd690 items=3 ppid=9638 pid=9644 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="besclient" exe="/usr/bin/bash" subj=system_u:system_r:pcp_pmcd_t:s0 key=(null)

type=EXECVE msg=audit(1627127856.524:1612): argc=3 a0="/bin/sh" a1="/etc/init.d/besclient" a2="status"

type=PATH msg=audit(1627127856.524:1612): item=0 name="/etc/init.d/besclient" inode=8563925 dev=fd:00 mode=0100755 ouid=0 ogid=707 rdev=00:00 obj=system_u:object_r:initrc_exec_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0

type=AVC msg=audit(1627127856.544:1613): avc:  denied  { read } for  pid=9644 comm="besclient" name="lock" dev="dm-4" ino=158 scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:object_r:var_lock_t:s0 tclass=lnk_file permissive=1

type=SYSCALL msg=audit(1627127856.544:1613): arch=80000016 syscall=106 success=no exit=-2 a0=2aa47aa80d0 a1=3ffe1efcfb0 a2=3ffe1efcfb0 a3=2aa37903568 items=1 ppid=9638 pid=9644 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="besclient" exe="/usr/bin/bash" subj=system_u:system_r:pcp_pmcd_t:s0 key=(null)

 

 

#--- audit2why suggests this

 

type=AVC msg=audit(1627132487.084:1189): avc:  denied  { execute } for  pid=7494 comm="bash" name="besclient" dev="dm-0" ino=8563925 scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:object_r:initrc_exec_t:s0 tclass=file permissive=0

 

        Was caused by:

                Missing type enforcement (TE) allow rule.

 

                You can use audit2allow to generate a loadable module to allow this access.

Comment 1 Mark Goodwin 2021-07-26 07:14:48 UTC
Nathan, this does not seem to repro with a simple scripted config on rhel84, rhel85 nor f34. All with selinux=Enforcing. For both dynamic config and after a reboot. I tested with the load.sh scripted config example from pmdaopenmetrics(1) man page. No AVCs are generated but maybe I'm missing something ..?

Can you please post more details on what the /etc/init.d/besclient script is doing and please include some detail of whatever the customer sent to you?

Thanks

Comment 2 Mark Goodwin 2021-07-27 05:38:35 UTC
Upstream for pcp-5.3.2. Document how to deal with Open Metrics PMDA scripted configs that trigger AVCs. There is no generic fix for this - we can't unilaterally grant an unconstrained execute policy to pmcd or it's children.

commit cdb75d802e08e7bc6560fbf41906c63498e9a5f6
Author: Mark Goodwin <mgoodwin>
Date:   Tue Jul 27 14:23:49 2021 +1000

    docs: add "SELinux Considerations" section to pmdaopenmetrics(1)
    
    Scripted configs executed by pmdaopenmetrics are subject to
    the prevailing pmcd SELinux context and policies. This is normally
    fine for simple scripts such as /proc scrapers etc, but can result
    in AVCs for more complex scripts. The new section includes details
    on creating and loading local site-specific SELinux modules.

Comment 3 Mark Goodwin 2021-08-25 07:54:43 UTC
RHEL86 via rebase BZ1991763

Comment 6 Jan Kurik 2021-09-16 09:58:14 UTC
The 'SELinux CONSIDERATIONS' section is present and describes in details what needs to be done for OpenMetrics scripts to avoid SELinux's AVC records.
Considering as verified.

Comment 9 errata-xmlrpc 2022-05-10 13:30:52 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 (pcp 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:1765


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