All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: selinux@vger.kernel.org
Cc: stephen.smalley.work@gmail.com, James Carter <jwcart2@gmail.com>
Subject: [PATCH] libsepol: Check that a module does not have any commons when validating
Date: Wed, 12 Aug 2026 16:03:01 -0400	[thread overview]
Message-ID: <20260812200301.15904-1-jwcart2@gmail.com> (raw)

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


             reply	other threads:[~2026-08-12 20:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 20:03 James Carter [this message]
2026-08-12 20:11 ` [PATCH] libsepol: Check that a module does not have any commons when validating Stephen Smalley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260812200301.15904-1-jwcart2@gmail.com \
    --to=jwcart2@gmail.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.