Closed pcmoore closed 3 months ago
It appears that Fedora is now labeling the memory.pressure pseudo file with its own type, and not allowing even unconfined domains to relabel that type. While we could allow this in the test policy, I'm not sure there is a precedent for this since this is NOT between any test domain or any test type. Historically there was an assumption that commands run from the test scripts can do anything since they are in unconfined_t.
sesearch -A -t memory_pressure_t only shows this rule in the Fedora policy: allow init_t memory_pressure_t:file { create getattr open }; So unconfined_t has no permissions to it.
The only current references to unconfined_t in the test policy are in policy/test_global.te, and those are just to allow unconfined_t to transition into all of the testsuite domains and allow the testsuite domains to inherit and use a pipe from the caller. Nothing that would allow interactions between unconfined_t and some other type in the base policy like this.
Easiest fix would be just to suppress the error output from the chcon command in the cgroupfs_label/test script ala 2>/dev/null or similar. We do this in other places in other test scripts.
It appears that Fedora is now labeling the memory.pressure pseudo file with its own type, and not allowing even unconfined domains to relabel that type. While we could allow this in the test policy, I'm not sure there is a precedent for this since this is NOT between any test domain or any test type. Historically there was an assumption that commands run from the test scripts can do anything since they are in unconfined_t.
That was my takeaway based on the AVC record. As this wasn't actually preventing a successful run of the test suite I wanted to simply document it here in hopes someone else would have the time to chase it down and get it fixed, either in the Fedora policy or in the test suite.
@zpytela is this something that you can fix in the Fedora SELinux policy?
In Fedora, we don't use memory_pressure_t but rather cgroup_memory_pressure_t. Still, the permission seems to be missing.
# sesearch -A -s unconfined_t -t cgroup_memory_pressure_t -c file
allow crontab_domain cgroup_type:file { append create link rename setattr unlink watch watch_reads write };
allow login_userdomain cgroup_type:file { create getattr open watch };
allow nsswitch_domain cgroup_type:file { getattr ioctl lock open read };
allow unconfined_domain_type cgroup_type:file { getattr ioctl lock open read };
# sesearch -A -t memory_pressure_t
memory_pressure_t is not a valid type attribute
Perhaps the problem is that upstream refpolicy does define memory_pressure_t so upstream has this type hard coded somewhere?
Yes, refpolicy uses a different type (and I suppose it does not completely work as expected either), anyway it is now fixed in rawhide, thanks for reporting.
Thanks @zpytela, what policy package version has the fix?
Ok, apologies for confusing the matter - I had an old local policy module installed which defined a memory_pressure_t type and assigned it to those files back when I was trying to reproduce a problem with labeling those files identified in an earlier thread on the selinux list.
what policy package version has the fix?
selinux-policy-41.11-1.fc41 https://bodhi.fedoraproject.org/updates/FEDORA-2024-fa03406b81 it will probably need a few more hours to get to all mirrors
I can confirm that selinux-policy-41.11-1.fc41 fixes the problem on my test system, closing this as resolved. Thanks for the help everyone!
When running the test suite I see the following noise from the "cgroupfs_label" test:
I see the following related AVCs in the audit log:
This is on a current Fedora Rawhide system with the following: