Bug 663193 - Cronie is having a hard time with SELinux in Rawhide.
Summary: Cronie is having a hard time with SELinux in Rawhide.
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: cronie
Version: rawhide
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
Assignee: Marcela Mašláňová
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 663331
TreeView+ depends on / blocked
 
Reported: 2010-12-14 22:25 UTC by Daniel Walsh
Modified: 2011-01-04 09:12 UTC (History)
5 users (show)

Fixed In Version: cronie-1.4.6-7.fc15
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 663331 663445 (view as bug list)
Environment:
Last Closed: 2011-01-04 09:12:48 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
This patch causes cronie to ask kernel for constant definition rather then using hard coded (2.00 KB, patch)
2010-12-14 22:26 UTC, Daniel Walsh
no flags Details | Diff
Updated patch to handle other calls (2.10 KB, patch)
2010-12-15 20:45 UTC, Daniel Walsh
no flags Details | Diff

Description Daniel Walsh 2010-12-14 22:25:39 UTC
Description of problem:

It is failing on all cron jobs.  SELinux patch that was written way back needs to be updated.

Comment 1 Daniel Walsh 2010-12-14 22:26:46 UTC
Created attachment 468720 [details]
This patch causes cronie to ask kernel for constant definition rather then using hard coded

Also add info to syslog message to help diagnose problems.

Comment 2 Marcela Mašláňová 2010-12-15 12:02:49 UTC
Thanks for patch, I'll add into upstream after little testing.

Comment 3 Daniel Walsh 2010-12-15 14:08:43 UTC
You might want to change the code to cache the value of "entrypoint" and "file", Since these are not likely to change during the run of cups and probing the kernel each time, is of little value.  (Hopefully we do not change the flask definition until a new release.  :^)

Comment 4 Tomas Mraz 2010-12-15 15:30:04 UTC
Dan, is the probing expensive?

Comment 5 Daniel Walsh 2010-12-15 15:34:05 UTC
I doubt it.  Eric?

Comment 6 Eric Paris 2010-12-15 16:00:02 UTC
Very cheap.  open() read() close() for each call.  And the kernel internals of the read() is just a bit of bitshifting and masking.  These values should be fixed for each kernel boot.  They should not change even if policy were changed.  But the overhead is very very low, so if it makes the code less complex feel free to look it up on every operation.

Comment 7 Tomas Mraz 2010-12-15 16:11:36 UTC
OK if the values are fixed for each boot it makes sense to cache them even if the lookup is cheap, i'll do that.

I'm curious whether other code doesn't contain the hardcoded values as well - f.e. pam_selinux or openssh.

Comment 8 Daniel Walsh 2010-12-15 17:53:01 UTC
Theoretically, although, this is only going to happen when an app is a policy enforcer.  openssh might do something around checking whether the range is "contained" within the system range.

Comment 9 Tomas Mraz 2010-12-15 20:19:59 UTC
I did not notice before but the same code as in pam_selinux is in cronie as well.

Comment 10 Daniel Walsh 2010-12-15 20:45:02 UTC
Created attachment 468967 [details]
Updated patch to handle other calls

This patch handles the two other times security_compute_av is called.

Comment 11 Tomas Mraz 2010-12-15 21:54:13 UTC
I've reworked the patch to cache the values for cron (not crontab, where it does not make sense). Pushed to cronie upstream git.

Comment 12 Fedora Update System 2010-12-16 14:20:41 UTC
cronie-1.4.5-4.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/cronie-1.4.5-4.fc14

Comment 13 Eric Paris 2010-12-16 15:16:16 UTC
I'm sorry I have to reopen because I told a lie.  The value can change on selinux policy update, so you really do need to recheck before every call and cannot just cache the value for the life of the system.....

Comment 14 Tomas Mraz 2010-12-16 15:39:30 UTC
Aargh, Eric :)

I'm just curious why this was changed from simple constants defined in headers to strings translated to random numbers that can change on SELinux policy updates.

Comment 15 Daniel Walsh 2010-12-16 16:21:04 UTC
They have always been random numbers, we just have had control over libselinux and selinux-policy, and have worked to make sure they do not change.  When they do change, either by accident or by design, then we have a problem.

Comment 16 Eric Paris 2010-12-16 16:45:51 UTC
Dan's right.  They have always been random.  Dan and I just discussed and changed SELinux policy so old cron will work with new policy, but the right thing to do is to always check the right values before the call.  We'll try not to have them change in a policy from us in the future, but there is no reason a user couldn't/shouldn't make a custom policy in which it is different...

Comment 17 Tomas Mraz 2010-12-17 14:17:03 UTC
In that case the constants should be deprecated and removed from libselinux headers at some time so callers of libselinux are not confused by them.

Comment 18 Daniel Walsh 2010-12-17 14:58:05 UTC
Well I have fixed the policy in Rawhide to not cause the problem.  I am not sure what the steps to tell a library that constants are no good.


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