libsepol enforcement hooks for policy server
cover libsepol enforcement hooks for policy server
This is an RFC for libsepol enforcement hooks. These patches are to show the concept and will in no way compile, I've intentionally left out utility functions so that just the important parts are here to discuss.
The enforcement model has changed quite a bit. Rather than looping over the policydb inside the policy server as before these hooks will make calls back into the policy server if a decision is needed. To decide whether a decision is needed we are essentially doing a semantic diff of the policies. The enforcer provides the 'other' or previous linked policy when initializing its hooks. When a callback is encountered hooks.c will determine if an equivalent rule or symbol is present in the other policy and if not call the callback. Only strings are passed into the callbacks.
To accomplish the semantic diff there were significant changes to the compiler to 1) expand the 'other' policy fully including disabled rules and symbols (including conflicting rules) and 2) to expand the new policy fully to do checks but then not add the disabled rules. The disabled symbols must be added for value mapping but I push the disabled symbols on to the end of the values so that they can be removed without holes in the hashtable forming.
A main concern I have about the current patches is that the security_ops struct is publically accessible by shared users of this library. This is obviously non-ideal because of abi compatibility. Anyone with better ideas of how to implement the callback system please speak up :)
This is still very rough around the edges so please look at the concepts without picking on the style/plain bugs too much :)
--
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.
Quoted 4 lines · Josh Brindle
This is an RFC for libsepol enforcement hooks. These patches are to show the concept and will in no way compile, I've intentionally left out utility functions so that just the important parts are here to discuss.
Thanks for sending this out for comment.
Quoted 3 lines
The enforcement model has changed quite a bit. Rather than looping over the policydb inside the policy server as before these hooks will make calls back into the policy server if a decision is needed.
I think this is a good overall approach.
Quoted 8 lines
To decide
whether a decision is needed we are essentially doing a semantic diff of the policies. The enforcer provides the 'other' or previous linked policy when initializing its hooks. When a callback is encounteredhooks.cwill determine if an equivalent rule or symbol is present in the other policy and if not call the callback. Only strings are passed into the callbacks.
I assume that this approach stems from the desire to enforce the results of the policy (the semantics) rather than the syntax. For example, you want to enforce _both_ the adding of an attribute to a type and the additional access that this generates.
Additionally the process adding the module does not have to have sufficient access to add everything in the policy - only the added elements.
These two decisions produce the bulk of your complexity: they require the extra expansion and diffing of the policies. Otherwise you could do a simple syntactic check of the module and only refer to the other policy to enforce symbol removal. I also think that the access removal checks are of questionable value (unlike the symbol removal checks) - who cares about DOS anyway?
So, I think that the syntactic check would be sufficient because the semantics of the syntax are clearly defined and can be taken into account by the meta-policy author. It would also _greatly_ reduce the complexity of enforcement.
My question: do you have examples where a well-crafted meta-policy could not successfully enforce policy access control doing only the checks that I am suggesting? My guess is that you are only going to get a reduction in granularity that is acceptable.
Quoted 8 lines
To accomplish the semantic diff there were significant changes to the compiler to 1) expand the 'other' policy fully including disabled rules and symbols (including conflicting rules) and 2) to expand the new policy fully to do checks but then not add the disabled rules. The disabled symbols must be added for value mapping but I push the disabled symbols on to the end of the values so that they can be removed without holes in the hashtable forming.
If you decide that you must do the semantic checks, I think that it may be possible to reduce some of the data structure changes you are making for the expand. I'll put the suggestion in the relevant patch emails.
Quoted 5 lines
A main concern I have about the current patches is that the
security_opsstruct is publically accessible by shared users of this library. This is obviously non-ideal because of abi compatibility. Anyone with better ideas of how to implement the callback system please speak up :)
Are you certain that you don't want to restrict these to static users?
You can pad the struct so that you can add additional members in the future, though this sucks.
I'll comment on some of the specifics of the other patches.
Karl
--
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.
Quoted 9 lines
From: Karl MacMillan [mailto:[email protected]]
Quoted 1 line
I assume that this approach stems from the desire to enforce the results of the policy (the semantics) rather than the syntax. For example, you want to enforce _both_ the adding of an attribute to a type and the additional access that this generates.
As is the style in SELinux we'd like to do as many checks as possible, in this case we check both the syntactic (eg., adding an attribute to a type) and the semantic (an allow rule after expansion)
Quoted 4 lines
Additionally the process adding the module does not have to have sufficient access to add everything in the policy - only the added elements.
Quoted 8 lines
These two decisions produce the bulk of your complexity: they require the extra expansion and diffing of the policies. Otherwise you could do a simple syntactic check of the module and only refer to the other policy to enforce symbol removal. I also think that the access removal checks are of questionable value (unlike the symbol removal checks) - who cares about DOS anyway?
Well, syntactic checking means walking each rule on the old policy avrule_decl list for each rule on the new policy, this is rediculously ineffecient, the purpose of the avtabs is for fast lookups, which is the reason we are using them.
Quoted 11 lines
So, I think that the syntactic check would be sufficient because the semantics of the syntax are clearly defined and can be taken into account by the meta-policy author. It would also _greatly_ reduce the complexity of enforcement.
My question: do you have examples where a well-crafted meta-policy could not successfully enforce policy access control doing only the checks that I am suggesting? My guess is that you are only going to get a reduction in granularity that is acceptable.
At this point I do not have well crafted examples, however I do not believe the object model will be complete and non-bypassable without semantic checking.
Quoted 10 lines
Quoted 2 lines
A main concern I have about the current patches is that the
security_opsstruct is publically accessible by sharedusers of this
Quoted 4 lines
library. This is obviously non-ideal because of abi compatibility. Anyone with better ideas of how to implement the callback system please speak up :)
Are you certain that you don't want to restrict these to static users?
I'd like it to be available to shared users.
Quoted 3 lines
You can pad the struct so that you can add additional members in the future, though this sucks.
Right, or add accessors for every field, which also sucks.
Quoted 2 lines
I'll comment on some of the specifics of the other patches.
Thanks
--
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.
Quoted 10 lines · Joshua Brindle
Quoted 9 lines
From: Karl MacMillan [mailto:[email protected]]
Quoted 1 line
I assume that this approach stems from the desire to enforce the results of the policy (the semantics) rather than the syntax. For example, you want to enforce _both_ the adding of an attribute to a type and the additional access that this generates.
Quoted 4 lines
As is the style in SELinux we'd like to do as many checks as possible, in this case we check both the syntactic (eg., adding an attribute to a type) and the semantic (an allow rule after expansion)
I don't feel strongly about this.
Quoted 13 lines
Quoted 4 lines
Additionally the process adding the module does not have to have sufficient access to add everything in the policy - only the added elements.
Quoted 8 lines
These two decisions produce the bulk of your complexity: they require the extra expansion and diffing of the policies. Otherwise you could do a simple syntactic check of the module and only refer to the other policy to enforce symbol removal. I also think that the access removal checks are of questionable value (unlike the symbol removal checks) - who cares about DOS anyway?
Quoted 5 lines
Well, syntactic checking means walking each rule on the old policy
avrule_decllist for each rule on the new policy, this is rediculously ineffecient, the purpose of the avtabs is for fast lookups, which is the reason we are using them.
Only if you want to detect changes to prevent the source type from having to have permission to add all rules in the policy module. I think that it is acceptable to simply require permission to add all rules.
Quoted 12 lines
Quoted 11 lines
So, I think that the syntactic check would be sufficient because the semantics of the syntax are clearly defined and can be taken into account by the meta-policy author. It would also _greatly_ reduce the complexity of enforcement.
My question: do you have examples where a well-crafted meta-policy could not successfully enforce policy access control doing only the checks that I am suggesting? My guess is that you are only going to get a reduction in granularity that is acceptable.
Quoted 4 lines
At this point I do not have well crafted examples, however I do not believe the object model will be complete and non-bypassable without semantic checking.
I can't think of any bypass from only performing syntactic checks - I'd be curious to hear a counter-example, but again I don't feel strongly.
Karl
--
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.