Skip to contentSkip to conversation

libsepol: fix pp module to cil nodecon statement

PATCH Applied Steve Lawrence 2 participants 2 messages Jan 25, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: fix pp module to cil nodecon statement

Policy modules do not have the concept of named IP addresses like CIL does. So when converting nodecode statements from pp policy modules to CIL, we need to wrap the IP address and mask parameters in parentheses so that the CIL compiler does not try to resolve them as named addresses, but instead treats them as anonymous.

---
 libsepol/src/module_to_cil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libsepol/src/module_to_cil.c +2 -2
index 51a4784..2acb600 100644
@@ -2721,7 +2721,7 @@ static int ocontext_selinux_node_to_cil(struct policydb *pdb, struct ocontext *n
 			goto exit;
 		}
 
-		cil_printf("(nodecon %s %s ", addr, mask);
+		cil_printf("(nodecon (%s) (%s) ", addr, mask);
 
 		context_to_cil(pdb, &node->context[0]);
 
@@ -2753,7 +2753,7 @@ static int ocontext_selinux_node6_to_cil(struct policydb *pdb, struct ocontext *
 			goto exit;
 		}
 
-		cil_printf("(nodecon %s %s ", addr, mask);
+		cil_printf("(nodecon (%s) (%s) ", addr, mask);
 
 		context_to_cil(pdb, &node->context[0]);
 
Signature · 1 line
2.7.4
Applied
#1 lore raw
Quoted 7 lines · Steve Lawrence

Policy modules do not have the concept of named IP addresses like CIL does. So when converting nodecode statements from pp policy modules to CIL, we need to wrap the IP address and mask parameters in parentheses so that the CIL compiler does not try to resolve them as named addresses, but instead treats them as anonymous.

Applied,

Thanks,
Jim

Quoted 27 lines
---
 libsepol/src/module_to_cil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libsepol/src/module_to_cil.c +2 -2
index 51a4784..2acb600 100644
@@ -2721,7 +2721,7 @@ static int ocontext_selinux_node_to_cil(struct policydb *pdb, struct ocontext *n
 			goto exit;
 		}
 
-		cil_printf("(nodecon %s %s ", addr, mask);
+		cil_printf("(nodecon (%s) (%s) ", addr, mask);
 
 		context_to_cil(pdb, &node->context[0]);
 
@@ -2753,7 +2753,7 @@ static int ocontext_selinux_node6_to_cil(struct policydb *pdb, struct ocontext *
 			goto exit;
 		}
 
-		cil_printf("(nodecon %s %s ", addr, mask);
+		cil_printf("(nodecon (%s) (%s) ", addr, mask);
 
 		context_to_cil(pdb, &node->context[0]);
 
Signature · 2 lines
James Carter <[email protected]>
National Security Agency