Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Christian Göttsche" <cgzones@googlemail.com>,
	"Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 6.18.y 1/3] selinux: use u16 for security classes
Date: Mon, 24 Aug 2026 18:00:20 -0400	[thread overview]
Message-ID: <20260824220022.435960-1-sashal@kernel.org> (raw)
In-Reply-To: <2026082020-deputize-mosaic-579e@gregkh>

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

[ Upstream commit fa79a596848fe38c55ccab8832ac35dac07fb00c ]

Security class identifiers are limited to 2^16, thus use the appropriate
type u16 consistently.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Stable-dep-of: b98a8ac50775 ("selinux: require a class's permission values to cover its permission count")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 security/selinux/ss/policydb.c |  5 +++--
 security/selinux/ss/policydb.h | 10 +++++-----
 security/selinux/ss/services.c |  2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index fdb8a62da04ad..37e0735b0dc8d 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -951,7 +951,7 @@ int policydb_load_isids(struct policydb *p, struct sidtab *s)
 	return 0;
 }
 
-int policydb_class_isvalid(struct policydb *p, unsigned int class)
+int policydb_class_isvalid(struct policydb *p, u16 class)
 {
 	if (!class || class > p->p_classes.nprim)
 		return 0;
@@ -2042,7 +2042,8 @@ static int filename_trans_read_helper(struct policydb *p, struct policy_file *fp
 	struct filename_trans_key *ft = NULL;
 	struct filename_trans_datum **dst, *datum, *first = NULL;
 	char *name = NULL;
-	u32 len, ttype, tclass, ndatum, i;
+	u32 len, ttype, ndatum, i;
+	u16 tclass;
 	__le32 buf[3];
 	int rc;
 
diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h
index 89a180b1742fb..a49275d1168d8 100644
--- a/security/selinux/ss/policydb.h
+++ b/security/selinux/ss/policydb.h
@@ -48,7 +48,7 @@ struct common_datum {
 
 /* Class attributes */
 struct class_datum {
-	u32 value; /* class value */
+	u16 value; /* class value */
 	char *comkey; /* common name */
 	struct common_datum *comdatum; /* common datum */
 	struct symtab permissions; /* class-specific permission symbol table */
@@ -82,7 +82,7 @@ struct role_datum {
 struct role_trans_key {
 	u32 role; /* current role */
 	u32 type; /* program executable type, or new object type */
-	u32 tclass; /* process class, or new object class */
+	u16 tclass; /* process class, or new object class */
 };
 
 struct role_trans_datum {
@@ -139,7 +139,7 @@ struct cat_datum {
 struct range_trans {
 	u32 source_type;
 	u32 target_type;
-	u32 target_class;
+	u16 target_class;
 };
 
 /* Boolean data type */
@@ -195,7 +195,7 @@ struct ocontext {
 		} ibendport;
 	} u;
 	union {
-		u32 sclass; /* security class for genfs */
+		u16 sclass; /* security class for genfs */
 		u32 behavior; /* labeling behavior for fs_use */
 	} v;
 	struct context context[2]; /* security context(s) */
@@ -322,7 +322,7 @@ struct policy_file {
 extern void policydb_destroy(struct policydb *p);
 extern int policydb_load_isids(struct policydb *p, struct sidtab *s);
 extern int policydb_context_isvalid(struct policydb *p, struct context *c);
-extern int policydb_class_isvalid(struct policydb *p, unsigned int class);
+extern int policydb_class_isvalid(struct policydb *p, u16 class);
 extern int policydb_type_isvalid(struct policydb *p, unsigned int type);
 extern int policydb_role_isvalid(struct policydb *p, unsigned int role);
 extern int policydb_read(struct policydb *p, struct policy_file *fp);
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 82608b34260fd..cbc101b095a30 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -3290,7 +3290,7 @@ static int get_classes_callback(void *k, void *d, void *args)
 {
 	struct class_datum *datum = d;
 	char *name = k, **classes = args;
-	u32 value = datum->value - 1;
+	u16 value = datum->value - 1;
 
 	classes[value] = kstrdup(name, GFP_ATOMIC);
 	if (!classes[value])
-- 
2.53.0


  reply	other threads:[~2026-08-24 22:00 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 10:41 FAILED: patch "[PATCH] selinux: require a class's permission values to cover its" failed to apply to 6.18-stable tree gregkh
2026-08-24 22:00 ` Sasha Levin [this message]
2026-08-24 22:00   ` [PATCH 6.18.y 2/3] selinux: more strict policy parsing Sasha Levin
2026-08-24 22:00   ` [PATCH 6.18.y 3/3] selinux: require a class's permission values to cover its permission count Sasha Levin
2026-08-25 10:02     ` Wentao Guan
2026-08-25 10:03     ` [PATCH 6.18.y 1/7] Revert "selinux: reject a permission value exceeding the class permission count" Wentao Guan
2026-08-27  5:17       ` Sasha Levin
2026-08-27  5:47         ` [PATCH 7.1.y 1/5] selinux: use u16 for security classes Wentao Guan
2026-08-27  5:47         ` [PATCH 7.1.y 2/5] selinux: more strict policy parsing Wentao Guan
2026-08-27  5:47         ` [PATCH 7.1.y 3/5] selinux: reject a permission value exceeding the class permission count Wentao Guan
2026-08-27  5:47         ` [PATCH 7.1.y 4/5] selinux: reject a class permission count below its inherited common Wentao Guan
2026-08-27  5:47         ` [PATCH 7.1.y 5/5] selinux: require a class's permission values to cover its permission count Wentao Guan
2026-08-27  8:37         ` [PATCH 6.18.47-rc1 01/10] Revert "selinux: require a class's permission values to cover its permission count" Wentao Guan
2026-08-27  8:59           ` Greg KH
2026-08-27  9:06             ` [PATCH 6.6 00/87] 6.6.154-rc1 review Wentao Guan
2026-08-27  9:07             ` [PATCH 6.18.47-rc1 01/10] Revert "selinux: require a class's permission values to cover its permission count" Wentao Guan
2026-08-27  9:23               ` Greg KH
2026-08-27  9:32                 ` Wentao Guan
2026-08-27 10:32                   ` Greg KH
2026-08-27 10:37                     ` Wentao Guan
2026-08-27  8:37         ` [PATCH 6.18.47-rc1 02/10] Revert "selinux: more strict policy parsing" Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.47-rc1 03/10] Revert "selinux: use u16 for security classes" Wentao Guan
2026-08-27  8:58           ` Greg KH
2026-08-27  9:17             ` Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.y 04/10] Revert "selinux: reject a permission value exceeding the class permission count" Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.y 05/10] Revert "selinux: reject a class permission count below its inherited common" Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.y 06/10] selinux: use u16 for security classes Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.y 07/10] selinux: more strict policy parsing Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.y 08/10] selinux: reject a permission value exceeding the class permission count Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.y 09/10] selinux: reject a class permission count below its inherited common Wentao Guan
2026-08-27  8:38         ` [PATCH 6.18.y 10/10] selinux: require a class's permission values to cover its permission count Wentao Guan
2026-08-25 10:03     ` [PATCH 6.18.y 2/7] Revert "selinux: reject a class permission count below its inherited common" Wentao Guan
2026-08-25 10:03     ` [PATCH 6.18.y 3/7] selinux: use u16 for security classes Wentao Guan
2026-08-25 10:03     ` [PATCH 6.18.y 4/7] selinux: more strict policy parsing Wentao Guan
2026-08-25 10:03     ` [PATCH 6.18.y 5/7] selinux: reject a permission value exceeding the class permission count Wentao Guan
2026-08-25 10:03     ` [PATCH 6.18.y 6/7] selinux: reject a class permission count below its inherited common Wentao Guan
2026-08-25 10:03     ` [PATCH 6.18.y 7/7] selinux: require a class's permission values to cover its permission count Wentao Guan

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=20260824220022.435960-1-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=cgzones@googlemail.com \
    --cc=paul@paul-moore.com \
    --cc=stable@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