Summary: | "No SELinux security context" and "FAILED (loading cron table)" on crond start, and jobs don't run, after updating to container-selinux-2:2.142 | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Russell Odom <russ+bugzilla-redhat> |
Component: | libselinux | Assignee: | Petr Lautrbach <plautrba> |
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | urgent | Docs Contact: | |
Priority: | high | ||
Version: | 31 | CC: | amurdaca, dwalsh, dweomer5, edgar.hoch, grepl.miroslav, jchaloup, jorge.fabregas, lsm5, majdi.razick, mmalik, mmaslano, mplch, omosnace, plautrba, randy, rh.container.bot, tmraz, vmojzis, vywunm0jfimu |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | libselinux-2.9-6.fc31 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2020-09-30 02:00:31 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: |
Description
Russell Odom
2020-08-02 21:27:05 UTC
I'm facing the same issue with my F31 installation starting with updates applied on 2020-08-02. In addition to the measures listed in the bug description I've triggered the relabeling of the whole file system. But the problem remains. Hi, I have the same issue. Has anyone found a solution besides setting enforcement to permissive? Hi. Same issue here in F31. I've just realized now that many jobs were not running and it all started with the updates at the beginning of August. I did a whole filesystem relabel but didn't work. None of my jobs in /etc/cron.daily are running due to "crond[3749]: ((null)) No SELinux security context (/etc/cron.d/0hourly)". The problem doesn't occur on Fedora 32. Is the problem still visible if you remove the container-selinux package? Recently, we had similar SELinux problems with crond and they were caused by container-selinux package. On Fedora 32 crond runs correctly with container-selinux package installed. On Fedora 31 crond still has error even with container-selinux package removed. Started Command Scheduler. (CRON) STARTUP (1.5.4) (CRON) INFO (RANDOM_DELAY will be scaled with factor 67% if used.) ((null)) No SELinux security context (/etc/crontab) (root) FAILED (loading cron table) ((null)) No SELinux security context (/etc/cron.d/0hourly) (root) FAILED (loading cron table) ((null)) No SELinux security context (/etc/cron.d/atop) (root) FAILED (loading cron table) (CRON) INFO (running with inotify support) (CRON) INFO (@reboot jobs will be run at computer's startup.) On F31 I removed container-selinux, did `setenforce 1` and restarted crond, and it now appears to work - I don't get the "No SELinux security context" errors (contrary to comment 6). However, running without that package breaks my containers, so that's not sustainable for me - I've put it back how I was before. Hi. Same behavior as Russell. F31 here; removed container-selinux, setenforce 1 and restarted crond: no SELinux errors in journal for cron. Installed container-selinux back again and SELinux errors returned after restarting crond. Can't remove container-selinux as well so back to permissive mode... Still an issue with container-selinux-2.145.0-1.fc31 Since we've now determined container-selinux is likely at fault, I'll just call out from the original report that this broke between version 2.138.0-1 and 2.142.0-1. Changes: https://github.com/containers/container-selinux/compare/v2.138.0...v2.142.0 This one entitled "Allow cron jobs to run podman" sounds suspect: https://github.com/containers/container-selinux/commit/965c7fb488ccec2c623d1b71e665f70c8ef3db11 (fixes https://github.com/containers/container-selinux/issues/100). I've logged https://github.com/containers/container-selinux/issues/106 in the hope it can be addressed upstream. This seems to be in fact a bug in libselinux, which is fixed by the following upstream patch: https://github.com/SELinuxProject/selinux/commit/1f89c4e7879fcf6da5d8d1b025dcc03371f30fc9 (Well, the bug is actually in the kernel, but in a deprecated API element, which the above patch move libselinux away from.) The problematic libselinux call that crond is choking at can be simulated using this command: python3 -c "import selinux; print(selinux.get_default_context_with_rolelevel('system_u', 'system_r', None, 'system_u:system_r:crond_t:s0-s0:c0.c1023'))" Normally, that should print "[0, 'system_u:system_r:system_cronjob_t:s0-s0:c0.c1023']", but if there are too many transitions in the policy of a certain pattern (probably happened after the container-selinux update) + old libselinux used, the underlying kernel operation overflows the available buffer and errors out, leading to the command printing "[-1, None]". This can be reproduced on F32 by installing container-selinux, downgrading libselinux to libselinux-3.0-3, and running the above command. Between libselinux-3.0-3 and -4, the aforementioned patch was backported, so the latest libselinux on F32 works correctly. To fix the issue on F31, the same patch needs to be backported to F31's libselinux. I'd like to add more details about this issue. F31 version of selinux.get_default_context_with_rolelevel() uses selinux.security_compute_user() which uses /sys/fs/selinux/user API to get the set of user contexts that can be reached from a source context. You can use python in order to get some results: ~~~ import selinux selinux.security_compute_user('system_u:system_r:crond_t:s0-s0:c0.c1023', 'system_u') ~~~ returns 83 records - 3690 bytes - when used with container-selinux-2.138.0, but the same command fails with container-selinux-2.144.0 as the size of result is bigger than a kernel page size - 4k To lower the size of the expected result, you can drop MCS/MLS part from source context: ~~~ import selinux selinux.security_compute_user('system_u:system_r:crond_t:s0', 'system_u') ~~~ Using this code with old and new container policy, you can get a list of added contexts: + 'system_u:system_r:container_runtime_t:s0' + 'system_u:system_r:spc_t:s0' + 'system_u:system_r:container_userns_t:s0' + 'system_u:system_r:container_logreader_t:s0' + 'system_u:system_r:container_kvm_t:s0' + 'system_u:system_r:container_init_t:s0' + 'system_u:system_r:container_engine_t:s0' + 'system_u:system_r:container_t:s0' + 'system_u:unconfined_r:container_runtime_t:s0' + 'system_u:unconfined_r:unconfined_t:s0' + 'system_u:unconfined_r:container_t:s0' 'system_u:system_r:container_runtime_t:s0' is related to the commit found Russel - https://github.com/containers/container-selinux/commit/965c7fb488ccec2c623d1b71e665f70c8ef3db11, but this commit itself would not overflow the kernel size. Other contexts are related to https://github.com/containers/container-selinux/commit/2750e78542a36bfffc97701183b839c8417e77aa as crond_t is assigned to unconfined_domain_type attribute and container_* types are assigned to container_domain attribute. It's definitely libselinux problem (already fixed upstream and in F32), which was uncovered by raising number of reachable domains. FEDORA-2020-ad7446b3fc has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-ad7446b3fc FEDORA-2020-ad7446b3fc has been pushed to the Fedora 31 testing repository. In short time you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-ad7446b3fc` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-ad7446b3fc See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates. Grabbed upates from updates-testing repo and and now everything went back to normal here in F31. No more SELinux messages in the log and crond running its jobs correctly. Thanks. Also confirming this now looks good on F31. Thanks! FEDORA-2020-ad7446b3fc has been pushed to the Fedora 31 stable repository. If problem still persists, please make note of it in this bug report. |