All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix checkpolicy segfaults when using role dominance statements
@ 2005-09-15 21:52 Darrel Goeddel
  2005-09-16 17:36 ` Stephen Smalley
  0 siblings, 1 reply; 3+ messages in thread
From: Darrel Goeddel @ 2005-09-15 21:52 UTC (permalink / raw)
  To: Stephen Smalley, Joshua Brindle; +Cc: selinux@tycho.nsa.gov

[-- Attachment #1: Type: text/plain, Size: 166 bytes --]

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?

-- 

Darrel

[-- Attachment #2: role_dominance.patch --]
[-- Type: text/x-patch, Size: 2267 bytes --]

Index: policy_parse.y
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux-usr/checkpolicy/policy_parse.y,v
retrieving revision 1.37
diff -u -p -r1.37 policy_parse.y
--- policy_parse.y	22 Aug 2005 18:06:49 -0000	1.37
+++ policy_parse.y	15 Sep 2005 20:23:51 -0000
@@ -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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-16 18:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-15 21:52 [PATCH] fix checkpolicy segfaults when using role dominance statements Darrel Goeddel
2005-09-16 17:36 ` Stephen Smalley
2005-09-16 18:19   ` [PATCH] fix checkpolicy segfaults when using role dominancestatements Karl MacMillan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.