SELinux Security Module development
 help / color / mirror / Atom feed
* [PATCH v2 2/3] selinux: validate user MLS range and default level at load
@ 2026-09-28 16:52 Christian Göttsche
  2026-09-28 16:52 ` [PATCH v2 3/3] selinux: validate permissive and neveraudit map types " Christian Göttsche
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Christian Göttsche @ 2026-09-28 16:52 UTC (permalink / raw)
  To: selinux
  Cc: Paul Moore, Stephen Smalley, Ondrej Mosnacek,
	Christian Göttsche

From: Christian Göttsche <cgzones@googlemail.com>

user_read() reads each user's MLS range and default level but, unlike
range transitions and security contexts, never validates them.
Validate usr->range and usr->dfltlevel in user_index_check() when MLS is
enabled, once the level and category symbol tables are populated.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 security/selinux/ss/policydb.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index e0304297def4..e51293e3ca8c 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -748,6 +748,20 @@ static int user_index_check(void *key, void *datum, void *datap)
 		}
 	}
 
+	if (p->mls_enabled) {
+		if (!mls_range_isvalid(p, &usr->range)) {
+			pr_err("SELinux:  user %s has an invalid MLS range\n",
+			       (const char *)key);
+			return -EINVAL;
+		}
+
+		if (!mls_level_isvalid(p, &usr->dfltlevel)) {
+			pr_err("SELinux:  user %s has an invalid MLS default level\n",
+			       (const char *)key);
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.55.0


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

end of thread, other threads:[~2026-09-30 20:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-28 16:52 [PATCH v2 2/3] selinux: validate user MLS range and default level at load Christian Göttsche
2026-09-28 16:52 ` [PATCH v2 3/3] selinux: validate permissive and neveraudit map types " Christian Göttsche
2026-09-28 17:07   ` sashiko-bot
2026-09-29 13:11   ` Stephen Smalley
2026-09-30 20:59   ` Paul Moore
2026-09-28 16:52 ` [PATCH v2 1/3] selinux: bounds-check role and user membership bitmaps " Christian Göttsche
2026-09-28 17:03   ` sashiko-bot
2026-09-28 17:49   ` Stephen Smalley
2026-09-28 17:54     ` Stephen Smalley
2026-09-28 18:20       ` Stephen Smalley
2026-09-30 20:59   ` Paul Moore
2026-09-28 17:01 ` [PATCH v2 2/3] selinux: validate user MLS range and default level " sashiko-bot
2026-09-28 19:48 ` [RFC PATCH 15/32] selinux: make mls_level_isvalid() static Stephen Smalley
2026-09-29 13:11 ` [PATCH v2 2/3] selinux: validate user MLS range and default level at load Stephen Smalley
2026-09-30 20:59 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox