Skip to contentSkip to conversation

RFC Kernel interface to conditional policy

DISCUSSION Karl MacMillan 3 participants 9 messages Dec 3, 2003 – Dec 5, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

This email is to get some feedback about the kernel interface to the booleans in the conditional policy work that we have been doing. This has been discussed off-list some, but I'd like to bring it up here to get some public discussion of the issue.

Background

We have added conditional expressions to the selinux policy language. This allows you to place TE rules in if/else blocks with conditional expressions. The booleans in the conditional expressions can be controlled at runtime to allow the addition or removal of rules based on the value of the booleans/expressions.

Problem

Our initial prototype exports the booleans as files under /proc/sys/selinux/booleans using the sysctl interface ([un]register_sysctl_table). On each policy reload we call unregister_sysctl_table and then re-register all of the booleans. The problem is that if one of the boolean files is in use the file is not removed and unregister_sysctl_table gives no indication that unregister was not successful. The solutions to this problem that we see are:

1) Manipulate proc files directly. This allows fine-grained labeling of the boolean files, but kernel developers seem to be frowning on new uses of proc.

2) Extend the selinux filesystem. This wouldn't allow fine-grained labeling and would pollute the policy-neutral security server interface with type enforcement policy specific functionality.

3) Create a new filesystem. This would be the most work, but otherwise meet our needs.

Any comments or suggestions are welcome.

Thanks,

Karl

Signature · 11 lines
Karl MacMillan
Tresys Technology
[email protected]
http://www.tresys.com
(410) 290-1411 x134


--
This message was distributed to subscribers of the selinux mailing 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 8 lines · Karl MacMillan

We have added conditional expressions to the selinux policy language. This allows you to place TE rules in if/else blocks with conditional expressions. The booleans in the conditional expressions can be controlled at runtime to allow the addition or removal of rules based on the value of the booleans/expressions.

Problem

Quoted 7 lines

Our initial prototype exports the booleans as files under /proc/sys/selinux/booleans using the sysctl interface ([un]register_sysctl_table). On each policy reload we call unregister_sysctl_table and then re-register all of the booleans. The problem is that if one of the boolean files is in use the file is not removed and unregister_sysctl_table gives no indication that unregister was not successful. The solutions to this problem that we see are:

Firstly, why does this need to be done in kernel space at all? Why not recompile the policy in userspace and reload it via the already simple and well defined user/kernel policy interface?

If it doesn't need to be done in the kernel, then it shouldn't be.

Quoted 3 lines

1) Manipulate proc files directly. This allows fine-grained labeling of the boolean files, but kernel developers seem to be frowning on new uses of proc.

Yes, extending proc is deprecated.

Quoted 4 lines

2) Extend the selinux filesystem. This wouldn't allow fine-grained labeling and would pollute the policy-neutral security server interface with type enforcement policy specific functionality.

I'm not clear on why you need fine-grained labeling to update security
policy: would you not allow just one domain to do this?

Quoted 2 lines

3) Create a new filesystem. This would be the most work, but otherwise meet our needs.

This sounds like the best approach, if you have to manipulate policy in the kernel. You might also consider netlink messaging (as an example, this is how the in-kernel routing table is manipulated).

- James

Signature · 9 lines
James Morris
<[email protected]>



--
This message was distributed to subscribers of the selinux mailing 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 · James Morris

On Wed, 3 Dec 2003, Karl MacMillan wrote:
Firstly, why does this need to be done in kernel space at all? Why not recompile the policy in userspace and reload it via the already simple and well defined user/kernel policy interface?

If it doesn't need to be done in the kernel, then it shouldn't be.

I think that it needs to be done in kernel so that the loaded kernel policy can control the changes made to itself. Changing a boolean (in the current version) is a well-defined change to the policy that is controlled by the policy; reloading the policy is potentially not well defined.

Additionally, because the files for changing the booleans can be individually labeled, there is fine-grained control over what domains can change which aspects of the policy. If this was done in userspace permission to change a boolean becomes permission to change any aspect of the policy, which is not ideal.

Quoted 6 lines
Quoted 3 lines

1) Manipulate proc files directly. This allows fine-grained labeling of the boolean files, but kernel developers seem to be frowning on new uses of proc.

Yes, extending proc is deprecated.

OK.

Quoted 8 lines
Quoted 4 lines

2) Extend the selinux filesystem. This wouldn't allow fine-grained labeling and would pollute the policy-neutral security server interface with type enforcement policy specific functionality.

I'm not clear on why you need fine-grained labeling to update security
policy: would you not allow just one domain to do this?

See above - fine-grained control over which domains can change which portions of the policy is a useful feature in my mind.

Quoted 8 lines
Quoted 3 lines

3) Create a new filesystem. This would be the most work, but otherwise meet our needs.

This sounds like the best approach, if you have to manipulate policy in the kernel. You might also consider netlink messaging (as an example, this is how the in-kernel routing table is manipulated).

Netlink messaging won't give us the fine-grained labeling, correct? I think I'll look into extending selinuxfs.

Karl

Quoted 2 lines

- James

Signature · 11 lines
Karl MacMillan
Tresys Technology
[email protected]
http://www.tresys.com
(410) 290-1411 x134


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 1 line · Karl MacMillan

Netlink messaging won't give us the fine-grained labeling, correct?

Not as-is.

- James

Signature · 9 lines
James Morris
<[email protected]>



--
This message was distributed to subscribers of the selinux mailing 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 5 lines · James Morris
Quoted 1 line · Karl MacMillan

Netlink messaging won't give us the fine-grained labeling, correct?

Not as-is.

To clarify, increasing the granularity of Netlink access is something that would be done within SELinux (i.e. the Netlink code would not need to be modified). It may be generally useful in any case as a fine grained user-kernel communication channel.

- James

Signature · 9 lines
James Morris
<[email protected]>



--
This message was distributed to subscribers of the selinux mailing 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 4 lines · James Morris
Quoted 2 lines · James Morris

On Thu, 4 Dec 2003, Karl MacMillan wrote:

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Netlink messaging won't give us the fine-grained labeling, correct?

Not as-is.

To clarify, increasing the granularity of Netlink access is something that would be done within SELinux (i.e. the Netlink code would not need to be modified). It may be generally useful in any case as a fine grained user-kernel communication channel.

I'll keep this as an option, but I think that it would be better for us to keep going with selinuxfs. It is nice to have an interface that doesn't require extra tools and I think that there is a better chance of completing the project in the limited time we have left.

Karl

Quoted 2 lines

- James

Signature · 11 lines
Karl MacMillan
Tresys Technology
[email protected]
http://www.tresys.com
(410) 290-1411 x134


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
In reply to Karl MacMillan
Quoted 11 lines · Karl MacMillan

Problem
1) Manipulate proc files directly. This allows fine-grained labeling of the boolean files, but kernel developers seem to be frowning on new uses of proc.

2) Extend the selinux filesystem. This wouldn't allow fine-grained labeling and would pollute the policy-neutral security server interface with type enforcement policy specific functionality.

3) Create a new filesystem. This would be the most work, but otherwise meet our needs.

I think that the problem with any of these solutions is the need to revoke access to any boolean files held open at the time of the policy reload. proc_kill_inodes appears to have an implementation of revoke-like functionality; something similar might be feasible for selinuxfs. I don't see any strong reason to make an entirely new filesystem; creating a subdirectory in selinuxfs and populating it with the booleans seems reasonable to me. In the past, James has suggested allowing extension of selinuxfs to export other security server state, and this seems in line with that idea.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw
Quoted 10 lines · Stephen Smalley
Quoted 9 lines · Karl MacMillan

Problem
1) Manipulate proc files directly. This allows fine-grained labeling of the boolean files, but kernel developers seem to be frowning on new uses of proc.

2) Extend the selinux filesystem. This wouldn't allow fine-grained labeling and would pollute the policy-neutral security server interface with type enforcement policy specific functionality.

Quoted 8 lines
Quoted 2 lines

3) Create a new filesystem. This would be the most work, but otherwise meet our needs.

I think that the problem with any of these solutions is the need to revoke access to any boolean files held open at the time of the policy reload. proc_kill_inodes appears to have an implementation of revoke-like functionality; something similar might be feasible for selinuxfs.

This doesn't look too bad and is basically what I was imagining had to be done anyway. Thanks for the pointer. As for whether the kernel maintainers will think this is acceptable, that is another matter entirely . . .

Quoted 5 lines

I don't see any strong reason to make an entirely new filesystem; creating a subdirectory in selinuxfs and populating it with the booleans seems reasonable to me. In the past, James has suggested allowing extension of selinuxfs to export other security server state, and this seems in line with that idea.

Great.

Karl

Signature · 11 lines
Karl MacMillan
Tresys Technology
[email protected]
http://www.tresys.com
(410) 290-1411 x134


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw
In reply to Karl MacMillan
Quoted 3 lines · Karl MacMillan

2) Extend the selinux filesystem. This wouldn't allow fine-grained labeling and would pollute the policy-neutral security server interface with type enforcement policy specific functionality.

BTW, I don't think it would be difficult to provide full genfs_contexts support for selinuxfs, so that isn't a major obstacle IMHO.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.