mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian Göttsche" <cgzones@googlemail.com>
To: selinux@vger.kernel.org
Cc: Paul Moore <paul@paul-moore.com>,
	Stephen Smalley <stephen.smalley.work@gmail.com>,
	Eric Paris <eparis@parisplace.org>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 06/20] selinux: mls: avoid implicit conversions
Date: Thu,  6 Jul 2023 15:23:21 +0200	[thread overview]
Message-ID: <20230706132337.15924-6-cgzones@googlemail.com> (raw)
In-Reply-To: <20230706132337.15924-1-cgzones@googlemail.com>

Use u32 for ebitmap bits.

Use char for the default range of a class.

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

diff --git a/security/selinux/ss/mls.c b/security/selinux/ss/mls.c
index 99571b19d4a9..1976f6b857e9 100644
--- a/security/selinux/ss/mls.c
+++ b/security/selinux/ss/mls.c
@@ -45,7 +45,7 @@ int mls_compute_context_len(struct policydb *p, struct context *context)
 
 	len = 1; /* for the beginning ":" */
 	for (l = 0; l < 2; l++) {
-		int index_sens = context->range.level[l].sens;
+		u32 index_sens = context->range.level[l].sens;
 		len += strlen(sym_name(p, SYM_LEVELS, index_sens - 1));
 
 		/* categories */
@@ -240,7 +240,7 @@ int mls_context_to_sid(struct policydb *pol,
 	char *sensitivity, *cur_cat, *next_cat, *rngptr;
 	struct level_datum *levdatum;
 	struct cat_datum *catdatum, *rngdatum;
-	int l, rc, i;
+	int l, rc;
 	char *rangep[2];
 
 	if (!pol->mls_enabled) {
@@ -331,7 +331,7 @@ int mls_context_to_sid(struct policydb *pol,
 			if (catdatum->value >= rngdatum->value)
 				return -EINVAL;
 
-			for (i = catdatum->value; i < rngdatum->value; i++) {
+			for (u32 i = catdatum->value; i < rngdatum->value; i++) {
 				rc = ebitmap_set_bit(&context->range.level[l].cat, i, 1);
 				if (rc)
 					return rc;
@@ -451,7 +451,8 @@ int mls_convert_context(struct policydb *oldp,
 	struct level_datum *levdatum;
 	struct cat_datum *catdatum;
 	struct ebitmap_node *node;
-	int l, i;
+	u32 i;
+	int l;
 
 	if (!oldp->mls_enabled || !newp->mls_enabled)
 		return 0;
@@ -495,7 +496,7 @@ int mls_compute_sid(struct policydb *p,
 	struct range_trans rtr;
 	struct mls_range *r;
 	struct class_datum *cladatum;
-	int default_range = 0;
+	char default_range = 0;
 
 	if (!p->mls_enabled)
 		return 0;
-- 
2.40.1


  parent reply	other threads:[~2023-07-06 13:24 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 13:23 [RFC PATCH 01/20] selinux: check for multiplication overflow in put_entry() Christian Göttsche
2023-07-06 13:23 ` [RFC PATCH 02/20] selinux: avtab: avoid implicit conversions Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC 2/20] " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 03/20] selinux: avoid avtab overflows Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC 3/20] " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 04/20] selinux: ebitmap: use u32 as bit type Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC 4/20] " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 05/20] selinux: hashtab: use identical iterator type Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC 5/20] " Paul Moore
2023-07-06 13:23 ` Christian Göttsche [this message]
2023-07-18 22:01   ` [PATCH RFC 6/20] selinux: mls: avoid implicit conversions Paul Moore
2023-07-06 13:23 ` [RFC PATCH 07/20] selinux: services: update type for umber of class permissions Christian Göttsche
2023-07-07  2:27   ` Gong Ruiqi
2023-07-18 22:01   ` [PATCH RFC 7/20] " Paul Moore
2023-07-19  1:45     ` Gong Ruiqi
2023-07-06 13:23 ` [RFC PATCH 08/20] selinux: services: avoid implicit conversions Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC 8/20] " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 09/20] selinux: status: consistently use u32 as sequence number type Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC 9/20] " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 10/20] selinux: netif: avoid implicit conversions Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 11/20] selinux: avc: " Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 12/20] selinux: hooks: " Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 13/20] selinux: selinuxfs: " Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 14/20] selinux: use consistent type for AV rule specifier Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 15/20] selinux: policydb: implicit conversions Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 16/20] selinux: symtab: implicit conversion Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 17/20] selinux: services: implicit conversions Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 18/20] selinux: nlmsgtab: implicit conversion Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 19/20] selinux: status: avoid implicit conversions regarding enforcing status Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-06 13:23 ` [RFC PATCH 20/20] selinux: selinuxfs: avoid implicit conversions Christian Göttsche
2023-07-18 22:01   ` [PATCH RFC " Paul Moore
2023-07-18 22:01 ` [PATCH RFC 1/20] selinux: check for multiplication overflow in put_entry() Paul Moore

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=20230706132337.15924-6-cgzones@googlemail.com \
    --to=cgzones@googlemail.com \
    --cc=eparis@parisplace.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@paul-moore.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

all inboxes | Powered by JetHome®