Skip to contentSkip to conversation

libsepol,checkpolicy: drop support for kernel policy versions < 24

PATCH Superseded Stephen Smalley 1 participant 1 message Aug 5 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 libsepol,checkpolicy: drop support for kernel policy versions < 24

Given the recently reported bugs in libsepol's support for policy versions 20 through 23, let's drop support for kernel policy versions < 24. This also aligns the minimum SELinux kernel policy version with the minimum Xen policy version. This makes libsepol's minimum supported kernel version v2.6.28 which is older than the v3.0 minimum we already set for libselinux.

---
 checkpolicy/checkpolicy.c                  |  14 +-
 libsepol/include/sepol/policydb/policydb.h |  12 +-
 libsepol/src/avtab.c                       |  92 +------
 libsepol/src/kernel_to_common.c            |  13 -
 libsepol/src/optimize.c                    |  13 -
 libsepol/src/policydb.c                    | 129 ++-------
 libsepol/src/policydb_validate.c           |  47 +---
 libsepol/src/write.c                       | 290 ++-------------------
 libsepol/tests/test-downgrade.c            |   7 -
 9 files changed, 66 insertions(+), 551 deletions(-)
checkpolicy/checkpolicy.c +2 -12
index c1b33869..b5a6da3a 100644
@@ -605,18 +605,8 @@ int main(int argc, char **argv)
 			}
 		}
 
-		if (policydbp->policyvers <= POLICYDB_VERSION_PERMISSIVE) {
-			if (policyvers > policydbp->policyvers) {
-				fprintf(stderr,
-					"Binary policies with version <= %u cannot be upgraded\n",
-					POLICYDB_VERSION_PERMISSIVE);
-			} else if (policyvers) {
-				policydbp->policyvers = policyvers;
-			}
-		} else {
-			policydbp->policyvers =
-				policyvers ? policyvers : POLICYDB_VERSION_MAX;
-		}
+		policydbp->policyvers = policyvers ? policyvers :
+						     POLICYDB_VERSION_MAX;
 	} else {
 		if (conf) {
 			fprintf(stderr,
libsepol/include/sepol/policydb/policydb.h +1 -11
index a1b5e99b..985a496e 100644
@@ -750,16 +750,6 @@ extern int policydb_set_target_platform(policydb_t *p, int platform);
 #define PERM_SYMTAB_SIZE 32
 
 /* Identify specific policy version changes */
-#define POLICYDB_VERSION_BASE 15
-#define POLICYDB_VERSION_BOOL 16
-#define POLICYDB_VERSION_IPV6 17
-#define POLICYDB_VERSION_NLCLASS 18
-#define POLICYDB_VERSION_VALIDATETRANS 19
-#define POLICYDB_VERSION_MLS 19
-#define POLICYDB_VERSION_AVTAB 20
-#define POLICYDB_VERSION_RANGETRANS 21
-#define POLICYDB_VERSION_POLCAP 22
-#define POLICYDB_VERSION_PERMISSIVE 23
 #define POLICYDB_VERSION_BOUNDARY 24
 #define POLICYDB_VERSION_FILENAME_TRANS 25
 #define POLICYDB_VERSION_ROLETRANS 26
@@ -776,7 +766,7 @@ extern int policydb_set_target_platform(policydb_t *p, int platform);
 #define POLICYDB_VERSION_NEVERAUDIT 35 /* neveraudit domains */
 
 /* Range of policy versions we understand*/
-#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BASE
+#define POLICYDB_VERSION_MIN POLICYDB_VERSION_BOUNDARY
 #define POLICYDB_VERSION_MAX POLICYDB_VERSION_NEVERAUDIT
 
 /* Module versions and specific changes*/
libsepol/src/avtab.c +2 -90

110 lines not on this page · raw message

libsepol/src/kernel_to_common.c +0 -13
index c7b6d73a..338dcef6 100644
@@ -795,18 +795,5 @@ int check_for_supported_policy(struct policydb *pdb)
 		return -1;
 	}
 
-	if (pdb->policyvers >= POLICYDB_VERSION_AVTAB &&
-	    pdb->policyvers <= POLICYDB_VERSION_PERMISSIVE) {
-		/*
-		 * For policy versions between 20 and 23, attributes exist in the policy,
-		 * but only in the type_attr_map. This means that there are gaps in both
-		 * the type_val_to_struct and p_type_val_to_name arrays and policy rules
-		 * can refer to those gaps.
-		 */
-		ERR(NULL,
-		    "Writing out CIL or policy.conf from policy versions between 20 and 23 is not supported");
-		return -1;
-	}
-
 	return 0;
 }
libsepol/src/optimize.c +0 -13
index 7a961ca4..eeffee7d 100644
@@ -453,19 +453,6 @@ int policydb_optimize(policydb_t *p)
 	if (p->policy_type != POLICY_KERN)
 		return -1;
 
-	if (p->policyvers >= POLICYDB_VERSION_AVTAB &&
-	    p->policyvers <= POLICYDB_VERSION_PERMISSIVE) {
-		/*
-		 * For policy versions between 20 and 23, attributes exist in the policy,
-		 * but only in the type_attr_map. This means that there are gaps in both
-		 * the type_val_to_struct and p_type_val_to_name arrays and policy rules
-		 * can refer to those gaps.
-		 */
-		ERR(NULL,
-		    "Optimizing policy versions between 20 and 23 is not supported");
-		return -1;
-	}
-
 	type_map = build_type_map(p);
 	if (!type_map)
 		return -1;
libsepol/src/policydb.c +28 -101

192 lines not on this page · raw message

libsepol/src/policydb_validate.c +11 -36

83 lines not on this page · raw message

libsepol/src/write.c +22 -268

424 lines not on this page · raw message

libsepol/tests/test-downgrade.c +0 -7
index bf747780..5f879b39 100644
@@ -155,13 +155,6 @@ int do_downgrade_test(int mls)
 			/* Write out modified binary policy */
 			if (write_binary_policy(POLICY_BIN_LO, &policydb) !=
 			    0) {
-				/*
-				 * Error from MLS to pre-MLS is expected due
-				 * to MLS re-implementation in version 19.
-				 */
-				if (mls && lo < POLICYDB_VERSION_MLS)
-					continue;
-
 				fprintf(stderr,
 					"error writing %spolicy binary, version %d (downgraded from %d)\n",
 					mls ? "mls " : "", lo, hi);
Signature · 1 line
2.55.0