All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: selinux@vger.kernel.org
Cc: stephen.smalley.work@gmail.com, James Carter <jwcart2@gmail.com>
Subject: [PATCH 2/2] libsepol: Remove assertion and comment from discard_tunables()
Date: Thu, 20 Aug 2026 11:41:43 -0400	[thread overview]
Message-ID: <20260820154143.12706-2-jwcart2@gmail.com> (raw)
In-Reply-To: <20260820154143.12706-1-jwcart2@gmail.com>

Policy validation ensures that there is never a mixture of tunables
and booleans in one expression, this means that the assertion in
discard_tunables() is not needed.

Remove the assertion and the comment (which is incorrect) above
the assertion. Since the variable "tunables" was only used in the
assertion, remove it as well.

Signed-off-by: James Carter <jwcart2@gmail.com>
---
 libsepol/src/expand.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c
index 18718973..f7ff61cd 100644
--- a/libsepol/src/expand.c
+++ b/libsepol/src/expand.c
@@ -3194,7 +3194,7 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol)
 
 		for (cur_node = decl->cond_list; cur_node != NULL;
 		     cur_node = cur_node->next) {
-			int booleans = 0, tunables = 0;
+			int booleans = 0;
 			cond_bool_datum_t *booldatum;
 
 			for (cur_expr = cur_node->expr; cur_expr != NULL;
@@ -3205,7 +3205,6 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol)
 						    [cur_expr->boolean - 1];
 				if (booldatum->flags &
 				    COND_BOOL_FLAGS_TUNABLE) {
-					tunables++;
 					if (preserve_tunables)
 						booldatum->flags &=
 							~COND_BOOL_FLAGS_TUNABLE;
@@ -3214,13 +3213,6 @@ static void discard_tunables(sepol_handle_t *sh, policydb_t *pol)
 				}
 			}
 
-			/* bool_copy_callback() at link phase has ensured
-			 * that no mixture of tunables and booleans in one
-			 * expression. However, this would be broken by the
-			 * request to preserve tunables */
-			if (!preserve_tunables)
-				assert(!(booleans && tunables));
-
 			if (booleans || preserve_tunables) {
 				cur_node->flags &= ~COND_NODE_FLAGS_TUNABLE;
 			} else {
-- 
2.55.0


  reply	other threads:[~2026-08-20 15:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 15:41 [PATCH 1/2] libsepol: Validate expressions do not mix tunables and booleans James Carter
2026-08-20 15:41 ` James Carter [this message]
2026-08-20 17:05   ` [PATCH 2/2] libsepol: Remove assertion and comment from discard_tunables() Stephen Smalley
2026-08-20 17:04 ` [PATCH 1/2] libsepol: Validate expressions do not mix tunables and booleans Stephen Smalley
2026-08-20 20:09   ` 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=20260820154143.12706-2-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 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.