All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian Göttsche" <cgzones@googlemail.com>
To: selinux@vger.kernel.org
Subject: [PATCH 5/5] libsepol: expand: skip invalid cat
Date: Fri, 12 May 2023 11:30:01 +0200	[thread overview]
Message-ID: <20230512093001.49208-5-cgzones@googlemail.com> (raw)
In-Reply-To: <20230512093001.49208-1-cgzones@googlemail.com>

Bail out on expanding levels with invalid low category.

UBSAN report:

    expand.c:952:21: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'uint32_t' (aka 'unsigned int')

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/expand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
index c08d3a35..8795229a 100644
--- a/libsepol/src/expand.c
+++ b/libsepol/src/expand.c
@@ -943,7 +943,7 @@ int mls_semantic_level_expand(mls_semantic_level_t * sl, mls_level_t * l,
 		return -1;
 	}
 	for (cat = sl->cat; cat; cat = cat->next) {
-		if (cat->low > cat->high) {
+		if (!cat->low || cat->low > cat->high) {
 			ERR(h, "Category range is not valid %s.%s",
 			    p->p_cat_val_to_name[cat->low - 1],
 			    p->p_cat_val_to_name[cat->high - 1]);
-- 
2.40.1


  parent reply	other threads:[~2023-05-12  9:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-12  9:29 [PATCH 1/5] libsepol: validate some object contexts Christian Göttsche
2023-05-12  9:29 ` [PATCH 2/5] libsepol: validate old style range trans classes Christian Göttsche
2023-05-12  9:29 ` [PATCH 3/5] libsepol: validate: check low category is not bigger than high Christian Göttsche
2023-05-12  9:30 ` [PATCH 4/5] libsepol: validate: reject XEN policy with xperm rules Christian Göttsche
2023-05-12  9:30 ` Christian Göttsche [this message]
2023-05-25 20:36 ` [PATCH 1/5] libsepol: validate some object contexts James Carter
2023-06-05 20:09   ` James Carter

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=20230512093001.49208-5-cgzones@googlemail.com \
    --to=cgzones@googlemail.com \
    --cc=selinux@vger.kernel.org \
    /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.