fix checkpolicy segfaults when using role dominance statements
PATCH 1/1 fix checkpolicy segfaults when using role dominance statements
This patch fixes two segfaults in the code path handling a role dominance statement such as:
dominance { role big_r { role little_r; } }
Look correct?
Signature · 1 line
Darrel
Index: policy_parse.y
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/checkpolicy/policy_parse.y,v retrieving revision 1.37
policy_parse.y +14 -6
@@ -2478,7 +2478,6 @@ static int dominate_role_recheck(hashtab { role_datum_t *rdp = (role_datum_t *) arg; role_datum_t *rdatum = (role_datum_t *) datum; - ebitmap_t *types = NULL; ebitmap_node_t *node; int i;
@@ -2489,17 +2488,22 @@ static int dominate_role_recheck(hashtab /* If a dominating role found */ if (ebitmap_get_bit(&(rdatum->dominates), rdp->value - 1)) { - if (type_set_expand(&rdp->types, types, policydbp, 1)) + ebitmap_t types; + ebitmap_init(&types); + if (type_set_expand(&rdp->types, &types, policydbp, 1)) { + ebitmap_destroy(&types); return -1; + } /* raise types and dominates from dominated role */ ebitmap_for_each_bit(&rdp->dominates, node, i) { if (ebitmap_node_get_bit(node, i)) ebitmap_set_bit(&rdatum->dominates, i, TRUE); } - ebitmap_for_each_bit(types, node, i) { + ebitmap_for_each_bit(&types, node, i) { if (ebitmap_node_get_bit(node, i)) ebitmap_set_bit(&rdatum->types.types, i, TRUE); } + ebitmap_destroy(&types); } /* go through all the roles */
@@ -2511,7 +2515,6 @@ static role_datum_t * { role_datum_t *role; char *role_id; - ebitmap_t *types = NULL; ebitmap_node_t *node; unsigned int i; int ret;
@@ -2563,16 +2566,21 @@ static role_datum_t * } } if (r) { + ebitmap_t types; + ebitmap_init(&types); ebitmap_for_each_bit(&r->dominates, node, i) { if (ebitmap_node_get_bit(node, i)) ebitmap_set_bit(&role->dominates, i, TRUE); } - if (type_set_expand(&r->types, types, policydbp, 1)) + if (type_set_expand(&r->types, &types, policydbp, 1)) { + ebitmap_destroy(&types); return NULL; - ebitmap_for_each_bit(types, node, i) { + } + ebitmap_for_each_bit(&types, node, i) { if (ebitmap_node_get_bit(node, i)) ebitmap_set_bit(&role->types.types, i, TRUE); } + ebitmap_destroy(&types); if (!r->value) { /* free intermediate result */ type_set_destroy(&r->types);
Quoted 6 lines · Darrel Goeddel
This patch fixes two segfaults in the code path handling a role dominance statement such as:
dominance { role
big_r{ rolelittle_r; } }Look correct?
Thanks, merged. It would likely help if there was a real user of role dominance in the example policy (and reference policy) so that this code path is exercised on a regular basis.
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.
RE: [PATCH] fix checkpolicy segfaults when using role dominancestatements
Quoted 13 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Stephen Smalley
Sent: Friday, September 16, 2005 1:37 PM
To: Darrel Goeddel
Cc: Joshua Brindle; [email protected]
Subject: Re: [PATCH] fix checkpolicy segfaults when using role dominancestatementsQuoted 3 lines · Darrel Goeddel
This patch fixes two segfaults in the code path handling a role dominance statement such as:
Quoted 8 lines
Quoted 3 lines
dominance { role
big_r{ rolelittle_r; } }Look correct?
Thanks, merged. It would likely help if there was a real user of role dominance in the example policy (and reference policy) so that this code path is exercised on a regular basis.
We have discussed using role dominance in reference policy but so far have not made a large effort in that direction. The idea was that you could create a large number of fine grained roles - down to the level of a role for an individual module - and then use dominance to create the higher level roles. This would make it much simpler to create new roles without having to add a large number of role statements throughout the policy. Any thoughts on whether this would work (other than not working because of broken code that is)?
Karl
------
Karl MacMillan
Tresys Technology
http://www.tresys.com
Quoted 10 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.
--
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.