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 1965001 - Fix possible AVC denial when copystat-ing some /proc/sys/vm/ files
Summary: Fix possible AVC denial when copystat-ing some /proc/sys/vm/ files
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: sos
Version: ---
Hardware: All
OS: Linux
high
medium
Target Milestone: beta
: ---
Assignee: Pavel Moravec
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-26 14:07 UTC by Pavel Moravec
Modified: 2021-11-10 07:44 UTC (History)
6 users (show)

Fixed In Version: sos-4.1-3.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-09 19:36:31 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github sosreport sos pull 2560 0 None open [archive] skip copying SELinux context for /proc and /sys everytime 2021-05-26 14:07:19 UTC
Red Hat Product Errata RHEA-2021:4388 0 None None None 2021-11-09 19:36:56 UTC

Description Pavel Moravec 2021-05-26 14:07:19 UTC
Description of problem:
TL;DR: backport https://github.com/sosreport/sos/pull/2560 to RHEL8.5.

Longer version: sosreport still attempts to copystat also SELinux context of some files from /proc or /sys (when adding the files as strings, or for special device files like pipe/shmem/..). This affects newer versions of SELinux policy than what probably appears in 8.5 GA, but it will harm us once the policy is updated a bit.


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


How reproducible:
100%


Steps to Reproduce:
1. Have a SELinux policy preventing to relabel files under /tmp to system_u:object_r:sysctl_vm_t:s0 context (like /proc/sys/vm/drop_caches has).
2. Run sos report in temp dir under /tmp:
TmpDir=$(mktemp -d)
sos report -o system --batch -vvv --tmp-dir=$TmpDir
3. Check AVC denials
4. Check if all files under _collected_ /proc/sys/vm/ dir (esp drop_caches and compact_memory) has unconfined_u:object_r:user_tmp_t:s0 context and not system_u:object_r:sysctl_vm_t:s0 one, and proper mode&permissions.


Actual results:
sos reports an error:
[archive:TarFileArchive] Unable to add '/tmp/tmp.tlrpbtJP3y/sos.n4i00rxe/sosreport-pmoravec-rhel9-2021-05-26-taiozlo/proc/sys/vm/drop_caches' to archive: [Errno 13] Permission denied: '/tmp/tmp.tlrpbtJP3y/sos.n4i00rxe/sosreport-pmoravec-rhel9-2021-05-26-taiozlo/proc/sys/vm/drop_caches'

and the same for compact_memory.

AVC denials:

type=AVC msg=audit(1622032383.981:332): avc:  denied  { associate } for  pid=1456 comm="sosreport" name="compact_memory" dev="tmpfs" ino=5873 scontext=system_u:object_r:sysctl_vm_t:s0 tcontext=system_u:object_r:tmpfs_t:s0 tclass=filesystem permissive=0
type=AVC msg=audit(1622032384.292:333): avc:  denied  { associate } for  pid=1456 comm="sosreport" name="drop_caches" dev="tmpfs" ino=6374 scontext=system_u:object_r:sysctl_vm_t:s0 tcontext=system_u:object_r:tmpfs_t:s0 tclass=filesystem permissive=0


Expected results:
No sos errors, and no AVCs.


Additional info:

Comment 1 Pavel Moravec 2021-05-27 12:14:47 UTC
Yet better test is to verify, if sos_logs/sos.log does contain something like:

2021-05-27 14:11:14,526 ERROR: [archive:TarFileArchive] Unable to add '/tmp/sos.2u13ssqj/sosreport-pmoravec-rhel9-2021-05-27-oppitki/proc/sys/vm/compact_memory' to archive: [Errno 13] Permission denied: '/tmp/sos.2u13ssqj/sosreport-pmoravec-rhel9-2021-05-27-oppitki/proc/sys/vm/compact_memory'
2021-05-27 14:11:14,863 ERROR: [archive:TarFileArchive] Unable to add '/tmp/sos.2u13ssqj/sosreport-pmoravec-rhel9-2021-05-27-oppitki/proc/sys/vm/drop_caches' to archive: [Errno 13] Permission denied: '/tmp/sos.2u13ssqj/sosreport-pmoravec-rhel9-2021-05-27-oppitki/proc/sys/vm/drop_caches'

or not.

Comment 6 errata-xmlrpc 2021-11-09 19:36:31 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 (sos 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/RHEA-2021:4388


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