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: Do not convert mls rules to CIL for a non-mls policy
Date: Tue, 4 Aug 2026 14:48:26 -0400 [thread overview]
Message-ID: <20260804184826.36330-1-jwcart2@gmail.com> (raw)
When converting a module policydb to CIL mls rules for sensitivies
and categories are processed if they exist even for a non-mls
policy. This allows for a maliciously crafted policy to cause an
OOB access.
If the policy is not an mls policy, then skip sensitivity,
category, and the ordering rules for sensitivies and categories.
Signed-off-by: James Carter <jwcart2@gmail.com>
---
libsepol/src/module_to_cil.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
index 06fbdc30..6876bd76 100644
--- a/libsepol/src/module_to_cil.c
+++ b/libsepol/src/module_to_cil.c
@@ -2711,6 +2711,9 @@ static int sens_to_cil(int indent, struct policydb *pdb,
{
level_datum_t *level = datum;
+ if (!pdb->mls)
+ return 0;
+
if (scope == SCOPE_DECL) {
if (!level->isalias) {
cil_println(indent, "(sensitivity %s)", key);
@@ -2738,6 +2741,9 @@ static int sens_order_to_cil(int indent, struct policydb *pdb,
struct ebitmap_node *node;
uint32_t i;
+ if (!pdb->mls)
+ return 0;
+
if (ebitmap_is_empty(&order)) {
return 0;
}
@@ -2761,6 +2767,9 @@ static int cat_to_cil(int indent, struct policydb *pdb,
{
struct cat_datum *cat = datum;
+ if (!pdb->mls)
+ return 0;
+
if (scope == SCOPE_REQ) {
return 0;
}
@@ -2783,6 +2792,9 @@ static int cat_order_to_cil(int indent, struct policydb *pdb,
struct ebitmap_node *node;
uint32_t i;
+ if (!pdb->mls)
+ return 0;
+
if (ebitmap_is_empty(&order)) {
rc = 0;
goto exit;
--
2.55.0
next reply other threads:[~2026-08-04 18:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 18:48 James Carter [this message]
2026-08-04 19:24 ` [PATCH] libsepol: Do not convert mls rules to CIL for a non-mls policy Stephen Smalley
2026-08-04 20:35 ` 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=20260804184826.36330-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox