Skip to contentSkip to conversation

libsepol: Check that a module does not have any commons when validating

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsepol: Check that a module does not have any commons when validating

Since a common cannot be declared in a module and cannot be required, there should not be any commons in a policy module. But a maliciously crafted policy could add one which could cause problems when processing the module.

Check that a module does not contain any commons when validating the module after reading it in and quit with an error if it does.

---
 libsepol/src/policydb_validate.c | 2 ++
 1 file changed, 2 insertions(+)
libsepol/src/policydb_validate.c +2 -0
index 0469b0c1..fe8bf1cf 100644
@@ -2092,6 +2092,8 @@ int policydb_validate(sepol_handle_t *handle, const policydb_t *p)
 			if (validate_filename_trans_hashtab(handle, p, flavors))
 				goto bad;
 	} else {
+		if ((p->policy_type == POLICY_MOD) && (p->p_commons.nprim > 0))
+			goto bad;
 		if (validate_avrule_blocks(handle, p->global, p, flavors))
 			goto bad;
 	}
Signature · 1 line
2.55.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · James Carter

Since a common cannot be declared in a module and cannot be required, there should not be any commons in a policy module. But a maliciously crafted policy could add one which could cause problems when processing the module.

Check that a module does not contain any commons when validating the module after reading it in and quit with an error if it does.

and merged.