Skip to contentSkip to conversation

Question on security_load_policy

DISCUSSION Nagendra Tomar 3 participants 4 messages Jun 25, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

In the security_load_policy() function, for the not-first-time policy load case (ss_initialized is true) what is the significance of cloning the existing sidtab and then updating the contexts of all the sidtab entries (sidtab_map_remove_on_error) ?

Why can't we just drop the table and then let the new table be populated dynamically as and when new contexts are looked up. As this is how the original sidtab was populated in the first place.

I can see that it might have some performance benefits in terms of not requiring to create SIDs for the security contexts that were already present in the current sidtab, but is that overhead really worth this effort.

If we remove the code that does the cloning and conversion of contexts (sidtab_map and sidtab_map_remove_on_error calls)
we will have uniform code for both the first-time and the not-first-time policy load case. IMHO, that will result in slightly cleaner security_load_policy function.
If we do that, we will have to call policydb_load_isids() also for the not-first-time poliy load case.

Thanx,
Tomar

---------------------------------
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your freeaccount today.

#1 lore raw

Nagendra Tomar <[email protected]> wrote: In the security_load_policy() function, for the not-first-time policy load case (ss_initialized is true) what is the significance of cloning the existing sidtab and then updating the contexts of all the sidtab entries (sidtab_map_remove_on_error) ?

Why can't we just drop the table and then let the new table be populated dynamically as and when new contexts are looked up. As this is how the original sidtab was populated in the first place.

Tomar>> I see the need for it to support existing processes
which already have the SID stored in their task_struct. If we re-create SIDs these existing SIDs will not be relevant.

I can see that it might have some performance benefits in terms of not requiring to create SIDs for the security contexts that were already present in the current sidtab, but is that overhead really worth this effort.

If we remove the code that does the cloning and conversion of contexts (sidtab_map and sidtab_map_remove_on_error calls)
we will have uniform code for both the first-time and the not-first-time policy load case. IMHO, that will result in slightly cleaner security_load_policy function.
If we do that, we will have to call policydb_load_isids() also for the not-first-time poliy load case.

Thanx,
Tomar

---------------------------------
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your free account today.

---------------------------------
Yahoo! Answers - Get better answers from someone who knows. Tryit now.

#2 lore raw
In reply to Nagendra Tomar
Quoted 9 lines · Nagendra Tomar

In the security_load_policy() function, for the not-first-time policy load case (ss_initialized is true) what is the significance of cloning the existing sidtab and then updating the contexts of all the sidtab entries (sidtab_map_remove_on_error) ?

Why can't we just drop the table and then let the new table be
populated dynamically as and when new contexts are looked up. As this is how the original sidtab was populated in the first place.

Many in-kernel data structures store only a sid (e.g., processes) - so if you dropped all of the sids there would be no way to recover the context of those objects.

The first policy load is expected to be early in the boot process, so it is reasonable to just create sids as objects are created (and objects created before policy load are handled by the initial sids).

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.

#3 lore raw
In reply to Nagendra Tomar
Quoted 14 lines · Nagendra Tomar

In the security_load_policy() function, for the not-first-time policy load case (ss_initialized is true) what is the significance of cloning the existing sidtab and then updating the contexts of all the sidtab entries (sidtab_map_remove_on_error) ?

Why can't we just drop the table and then let the new table be
populated dynamically as and when new contexts are looked up. As this is how the original sidtab was populated in the first place.

I can see that it might have some performance benefits in terms of not requiring to create SIDs for the security contexts that were already present in the current sidtab, but is that overhead really worth this effort.

Quoted 7 lines

If we remove the code that does the cloning and conversion of contexts (sidtab_map and sidtab_map_remove_on_error calls)
we will have uniform code for both the first-time and the not-first-time policy load case. IMHO, that will result in slightly cleaner security_load_policy function.
If we do that, we will have to call policydb_load_isids() also
for the not-first-time poliy load case.

In addition to the already noted fact that SIDs are pervasively cached outside of the security server (in the object security structs, in the AVC, even outside of the SELinux "module", e.g. in audit and ipsec/xfrm structures), I wanted to also note that this is not the only difference in behavior between first-time policy load and a policy reload, so removing this difference would not make them uniform. In particular, selinux_complete_init() is only called on first-time policy load.

Signature · 8 lines
Stephen Smalley
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.