All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libsepol: Check that a module does not have any commons when validating
@ 2026-08-12 20:03 James Carter
  2026-08-12 20:11 ` Stephen Smalley
  0 siblings, 1 reply; 2+ messages in thread
From: James Carter @ 2026-08-12 20:03 UTC (permalink / raw)
  To: selinux; +Cc: stephen.smalley.work, 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.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/src/policydb_validate.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c
index 0469b0c1..fe8bf1cf 100644
--- a/libsepol/src/policydb_validate.c
+++ b/libsepol/src/policydb_validate.c
@@ -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;
 	}
-- 
2.55.0


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

end of thread, other threads:[~2026-08-12 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 20:03 [PATCH] libsepol: Check that a module does not have any commons when validating James Carter
2026-08-12 20:11 ` Stephen Smalley

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.