This bug has been migrated to another issue tracking site. It has been closed here and may no longer be being monitored.

If you would like to get updates for this issue, or to participate in it, you may do so at Red Hat Issue Tracker .
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 2222005 - AVC "sys_admin" pops up when rhsmcertd-worker queries a repository file it creates itself on /tmp
Summary: AVC "sys_admin" pops up when rhsmcertd-worker queries a repository file it cr...
Keywords:
Status: CLOSED MIGRATED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: librepo
Version: 8.8
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Jaroslav Rohel
QA Contact: swm-qe
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-11 13:07 UTC by Renaud Métrich
Modified: 2023-09-21 17:23 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-09-21 17:23: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   RHEL-6395 0 None Migrated None 2023-09-21 17:23:40 UTC
Red Hat Issue Tracker RHELPLAN-162026 0 None None None 2023-07-11 13:09:30 UTC
Red Hat Knowledge Base (Solution) 7024092 0 None None None 2023-07-11 13:27:17 UTC

Description Renaud Métrich 2023-07-11 13:07:11 UTC
Description of problem:

We have a customer getting the following AVC on "sys_admin" capability:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
type=PROCTITLE msg=audit(07/10/2023 16:16:25.141:28612) : proctitle=/usr/libexec/platform-python /usr/libexec/rhsmcertd-worker 
type=SYSCALL msg=audit(07/10/2023 16:16:25.141:28612) : arch=x86_64 syscall=flistxattr success=yes exit=17 a0=0xb a1=0x0 a2=0x0 a3=0x55abcbafc3c0 items=0 ppid=3461560 pid=3462381 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=rhsmcertd-worke exe=/usr/libexec/platform-python3.6 subj=system_u:system_r:rhsmcertd_t:s0 key=(null)
type=AVC msg=audit(07/10/2023 16:16:25.141:28612) : avc:  denied  { sys_admin } for  pid=3462381 comm=rhsmcertd-worke capability=sys_admin  scontext=system_u:system_r:rhsmcertd_t:s0 tcontext=system_u:system_r:rhsmcertd_t:s0 tclass=capability permissive=0
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This happens everytime the worker tries to list the extended attributes of a file it generated itself just before (flistxattr() syscall):
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
3462381 16:16:25.046125 mkdir("/tmp/tmpdir.PoRnyf", 0700) = 0 <0.000078>
3462381 16:16:25.046368 mkdir("/tmp/tmpdir.PoRnyf/repodata", 0775) = 0 <0.000016>
3462381 16:16:25.046411 openat(AT_FDCWD</>, "/tmp/tmpdir.PoRnyf/repodata/repomd.xml", O_RDWR|O_CREAT|O_TRUNC, 0666) = 10</tmp/tmpdir.PoRnyf/repodata/repomd.xml> <0.000044>
 :
3462381 16:16:25.046907 fsetxattr(11</tmp/tmpdir.PoRnyf/repodata/repomd.xml>, "user.Librepo.DownloadInProgress", "1", 1, 0) = -1 EOPNOTSUPP (Operation not supported) <0.000010>
 :
3462381 16:16:25.141675 flistxattr(11</tmp/tmpdir.PoRnyf/repodata/repomd.xml>, NULL, 0) = 17 <0.000050>
3462381 16:16:25.142737 flistxattr(11</tmp/tmpdir.PoRnyf/repodata/repomd.xml>, "security.selinux\0", 17) = 17 <0.000047>
 :
3462381 16:16:25.143532 fremovexattr(10</tmp/tmpdir.PoRnyf/repodata/repomd.xml>, "user.Librepo.DownloadInProgress") = -1 EOPNOTSUPP (Operation not supported) <0.000013>
 :
3462381 16:16:25.146973 unlink("/tmp/tmpdir.PoRnyf/repodata/repomd.xml") = 0 <0.000025>
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This AVC pollutes the audit log because it happens every few seconds.

Digging further, it appears that the AVC happens because the process doesn't have the CAP_SYS_ADMIN capability.
This is usually not an issue unless `/tmp` is a tmpfs file system, in such case the kernel verifies the capability is enabled (fs/xattr.c):
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
1041 /*
1042  * xattr LIST operation for in-memory/pseudo filesystems
1043  */
1044 ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
1045                           char *buffer, size_t size)
1046 {
1047         bool trusted = capable(CAP_SYS_ADMIN);
 :
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Line 1047 above generates the AVC.

I think the AVC can be safely hidden, but this would be necessary only if the code really needed to implement flistxattr() function calls.
I'm not that sure that this is needed, because I can see, from above strace, that the code blindly creates the extended attribute then deletes it (both operations fail here because tmpfs doesn't support extended attributes) so probably querying the extended attributes is not that useful. But that's just my guess I didn't went up to digging into the sources at all.

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

subscription-manager-1.28.36-2.el8.x86_64

How reproducible:

Always

Steps to Reproduce:
1. Enable `tmp.mount` unit then reboot

   # systemctl enable tmp.mount
   # reboot

2. Wait for rhsmcertd-worker to execute

Actual results:

AVCs popping up

Expected results:

No AVC

Comment 1 Pino Toscano 2023-08-29 11:21:55 UTC
Moving to librepo, as it seems to be something done internally by librepo itself.

Comment 2 Jaroslav Rohel 2023-09-04 12:29:48 UTC
> so probably querying the extended attributes is not that useful.

The "user.Librepo.DownloadInProgress" attribute indicates that the file is being downloaded by librepo. This xattr is removed once the file is completely downloaded. If librepo tries to resume the download, it checks if xattr is present. If not, the download will not resume, but the entire file will be downloaded again.
Strace shows that "fgetxattr" is called for this attribute. But I assume that the "fgetxattr" call will not be executed if the "resume" option is disabled.

Librepo also uses extended tributes to store the file hash. In this case, the extended attribute serves as a cache for the hash.

Comment 3 Renaud Métrich 2023-09-04 12:50:42 UTC
Sorry but there is a bug: an AVC pops up, which is not acceptable.
Something has to be done to avoid it, maybe through hiding.

Comment 5 RHEL Program Management 2023-09-21 17:22:19 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 6 RHEL Program Management 2023-09-21 17:23:50 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.


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