Skip to contentSkip to conversation

checkpolicy: Check for mls constraint expression in non-mls policy

PATCH In review James Carter 2 participants 3 messages Aug 31 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpolicy: Check for mls constraint expression in non-mls policy

In a constraint expression l1, l2, h1, and h2 all refer to levels and should only appear in mls policies.

Return an error if a mls constraint expression is found in a non- mls policy.

---
v2: Fix typo in commit message.

 checkpolicy/policy_define.c | 6 ++++++
 1 file changed, 6 insertions(+)
checkpolicy/policy_define.c +6 -0
index 30157826..1984c52f 100644
@@ -4055,6 +4055,12 @@ uintptr_t define_cexpr(uint32_t expr_type, uintptr_t arg1, uintptr_t arg2)
 		e1->next = expr;
 		return arg1;
 	case CEXPR_ATTR:
+		if (!mlspol && (arg1 >= CEXPR_L1L2)) {
+			yyerror("MLS constraint expression "
+				"in non-MLS configuration");
+			constraint_expr_destroy(expr);
+			return 0;
+		}
 		expr->attr = arg1;
 		expr->op = arg2;
 		return (uintptr_t)expr;
Signature · 1 line
2.55.0