Skip to contentSkip to conversation

file_contexts

DISCUSSION Russell Coker 2 participants 6 messages Mar 18, 2002 – Mar 20, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

Currently with the sample policy the type definition for all exec_t domains is in the files that define all policy for the program in question.

The setfiles program will abort if any type specified in file_contexts is not defined.

I think that the reasonable use of the sample domains/programs/*.te files is to remove the ones that don't apply to your system.

After removing unwanted *.te files and loading the policy I then can't run setfiles.

To solve this problem I am thinking of modifying the setfiles program to make it silently (unless in verbose mode) ignore any lines that refer to a type that's not in policy. So for example if I remove the policy file for ppp then after running setfiles /usr/sbin/pppd will have sbin_t instead of pppd_exec_t.

What do you think?

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw
Quoted 5 lines · Russell Coker

I think that the reasonable use of the sample domains/programs/*.te files is to remove the ones that don't apply to your system.

After removing unwanted *.te files and loading the policy I then can't run setfiles.

Even ignoring the setfiles problem, you are still likely to encounter problems with removing unwanted domain .te files due to interactions among domains. To some degree, we can reduce this problem by relocating some of the rules and by using type attributes in some cases to better encapsulate each domain. But we can't completely eliminate such inter-domain dependencies.

Quoted 7 lines

To solve this problem I am thinking of modifying the setfiles program to make it silently (unless in verbose mode) ignore any lines that refer to a type that's not in policy. So for example if I remove the policy file for ppp then after running setfiles /usr/sbin/pppd will have sbin_t instead of pppd_exec_t.

What do you think?

I'm uneasy about the lack of any error checking in that case (e.g. someone makes a typo in file_contexts). David Wheeler suggested a while back that we partition file_contexts into a collection of files, like the policy, that are merged together during the build, with each file corresponding to one of the domain .te files. He suggested the convention of a foo.fc file (fc == file context) for each foo.te file. The challenge in that case is ensuring that the ordering dependencies of file_contexts are preserved.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw
Quoted 7 lines · Stephen Smalley

I'm uneasy about the lack of any error checking in that case (e.g. someone makes a typo in file_contexts). David Wheeler suggested a while back that we partition file_contexts into a collection of files, like the policy, that are merged together during the build, with each file corresponding to one of the domain .te files. He suggested the convention of a foo.fc file (fc == file context) for each foo.te file. The challenge in that case is ensuring that the ordering dependencies of file_contexts are preserved.

Try expanding the attached archive relative to your selinux directory. This is a rough cut at partitioning file_contexts.

--
Stephen D. Smalley, NAI Labs
[email protected]

#3 lore raw
In reply to Stephen Smalley
Quoted 9 lines · Stephen Smalley
Quoted 5 lines

I think that the reasonable use of the sample domains/programs/*.te files is to remove the ones that don't apply to your system.

After removing unwanted *.te files and loading the policy I then can't run setfiles.

Even ignoring the setfiles problem, you are still likely to encounter problems with removing unwanted domain .te files due to interactions among domains.

True. However the reduction of auditing work given by removing unwanted policy files should more than make up for the amount of work involved in editing a few of the policy files to remove references to those removed files.

Quoted 4 lines

To some degree, we can reduce this problem by relocating some of the rules and by using type attributes in some cases to better encapsulate each domain. But we can't completely eliminate such inter-domain dependencies.

Yes, that's not a big deal IMHO. Someone who doesn't want to edit any policy files can install the complete example policy. But I think that someone who doesn't want to edit policy files would be best advised to either pay someone else to do it for them or to not use SE Linux. If someone wants a small increase in security with little work then GR Security or one of the other patches to add security features to the kernel will probably better suit their needs.

Quoted 10 lines
Quoted 7 lines

To solve this problem I am thinking of modifying the setfiles program to make it silently (unless in verbose mode) ignore any lines that refer to a type that's not in policy. So for example if I remove the policy file for ppp then after running setfiles /usr/sbin/pppd will have sbin_t instead of pppd_exec_t.

What do you think?

I'm uneasy about the lack of any error checking in that case (e.g. someone makes a typo in file_contexts).

That's something I was concerned about too, but an option to check the file_contexts file should make it easy enough to catch them.

Quoted 6 lines

David Wheeler suggested a while back that
we partition file_contexts into a collection of files, like the policy, that are merged together during the build, with each file corresponding to one of the domain .te files. He suggested the convention of a foo.fc file (fc == file context) for each foo.te file. The challenge in that case is ensuring that the ordering dependencies of file_contexts are preserved.

I think that the solution is to remove the need for ordering dependencies!

If you change the definition of the format to not have the regex's automatically be right-anchored (which requires inserting '$' at appropriate places in the current fc file) then you can check for the regular expression which gives the largest rm_eo value!

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
Quoted 6 lines · Russell Coker

I think that the solution is to remove the need for ordering dependencies!

If you change the definition of the format to not have the regex's automatically be right-anchored (which requires inserting '$' at appropriate places in the current fc file) then you can check for the regular expression which gives the largest rm_eo value!

I haven't looked into this closely, but it isn't clear to me how that would solve the problem. I would expect the /.* entry to then take precedence over all other entries. Even without that entry, you would have the same problem with other entries that provide a default for a given directory tree, e.g. /var(|/.*), that are overridden by more specific entries that occur later. I'm also not sure how that would address the multiple hard link problem.

In any event, it appears that we only need to set up ordering properly in the types.fc file and within each individual domain .fc file, and that the ordering among the domain .fc files is irrelevant.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
Quoted 10 lines · Stephen Smalley
Quoted 7 lines

I think that the solution is to remove the need for ordering dependencies!

If you change the definition of the format to not have the regex's automatically be right-anchored (which requires inserting '$' at appropriate places in the current fc file) then you can check for the regular expression which gives the largest rm_eo value!

I haven't looked into this closely, but it isn't clear to me how that would solve the problem. I would expect the /.* entry to then take

First you replace "/.*" with "/", as without right anchoring "/" would match everything, but with a length of 1. Anything else that matches would be a better match.

Quoted 3 lines

precedence over all other entries. Even without that entry, you would have the same problem with other entries that provide a default for a given directory tree, e.g. /var(|/.*), that are overridden by more

You replace "/var(|/.*)" with "/var".

Quoted 2 lines

specific entries that occur later. I'm also not sure how that would address the multiple hard link problem.

You are right it would not solve the problem apart from in a few specific cases.

Quoted 3 lines

In any event, it appears that we only need to set up ordering properly in the types.fc file and within each individual domain .fc file, and that the ordering among the domain .fc files is irrelevant.

With the current sample policy the ordering among the .fc files is not relevant, with the next version who knows...

Signature · 9 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

--
You have received this message because you are subscribed to the selinux list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.