libsepol: drop support for policy versions before xperms_ioctl/xen_devicetree
Stephen Smalley
maintainerRFC PATCH v2 1/1 libsepol: drop support for policy versions before xperms_ioctl/xen_devicetree
RFC-only at this time since this would also increase our minimum supported kernel version from v3.0 to v4.3 and might break very old long term support distro releases that predate the kernel or libsepol versions that support policy 30. That said, I doubt those distro releases would ever update to latest libsepol.
Drop support for kernel and module policy versions before the xperms_ioctl support (SELinux kernel policy version 30, modular policy version 18) and xen_devicetree support (Xen policy version 30). Kernel policy version 30 was first supported in Linux v4.3, Xen 4.6, and libsepol 2.5 (20160223). Modular policy version 18 was first supported in libsepol 2.7 aka selinux userspace release (20170804).
---
v2 reverts the incorrect removal of a check on POLICYDB_VERSION_COND_XPERMS from cil_binary.c (that policy version is still > the minimum) and reflows a paragraph in the README.md.
README.md | 27 ++- libsepol/cil/src/cil_binary.c | 31 ++- libsepol/include/sepol/policydb/policydb.h | 18 +- libsepol/src/conditional.c | 6 +- libsepol/src/policydb.c | 229 ++------------------- libsepol/src/policydb_validate.c | 10 +- libsepol/src/services.c | 10 +- libsepol/src/write.c | 126 +++--------- 8 files changed, 78 insertions(+), 379 deletions(-)
README.md +13 -14
@@ -25,9 +25,8 @@ for more information. Minimum Supported Kernel Version -------------------------------- -The minimum supported kernel version is Linux v3.0 (for the -/sys/fs/selinux mount point directory) for libselinux and anything -that uses libselinux to access selinuxfs. +The minimum supported kernel version is Linux v4.3 to match the +minimum supported kernel policy version by libsepol. Note that the policy build toolchain (e.g. libsepol, checkpolicy, checkmodule, secilc, semodule_package/expand/link) does not link with
@@ -38,16 +37,16 @@ successfully been built and run on non-Linux platforms as well Minimum Supported Policy Versions --------------------------------- -The minimum kernel policy version is 24 (boundary) for the SELinux and -Xen targets. Support for this policy version first shipped in libsepol -2.0.34 (userspace release 20090403), Linux v2.6.28, and Xen -4.0.0. libsepol dropped support for kernel policy versions older than -24 starting with libsepol 3.12. +The minimum kernel policy version is 30 (xperms_ioctl for SELinux, +xen_devicetree for Xen). Support for this policy version first shipped +in libsepol 2.5 (userspace release 20160223), Linux v4.3, and Xen +4.6. libsepol dropped support for kernel policy versions older than 30 +starting with libsepol 3.12. -The minimum modular policy version is 10 (boundary alias). Support for -this modular policy version first shipped in libsepol 2.0.35 -(userspace release 20090403). libsepol dropped support for modular -policies older than 10 starting with libsepol 3.12 +The minimum modular policy version is 18 (xperms_ioctl). Support for +this modular policy version first shipped in libsepol 2.7 (userspace +release 20170804). libsepol dropped support for modular policies older +than 18 starting with libsepol 3.12. These minimum policy versions in libsepol affect: 1. The policy build toolchain. For example, checkpolicy, checkmodule,
@@ -60,8 +59,8 @@ the minimum. 3. SELinux policy analysis tools. For example, setools cannot read a policy with a version less the minimum. 4. The Xen hypervisor, which compiles its XSM/Flask policies using -checkpolicy, and only currently supports kernel policy versions 24 and -30 for the Xen target. Xen does not use binary policy modules so it is +checkpolicy, and only currently supports kernel policy version 30 for +the Xen target. Xen does not use binary policy modules so it is unaffected by changes to the minimum modular policy version. 5. Android, which is on kernel policy version 30. There has not been any need for newer policy version features yet. Android does not use
libsepol/cil/src/cil_binary.c +13 -18
@@ -3189,28 +3189,23 @@ static int __cil_constrain_expr_datum_to_sepol_expr(policydb_t *pdb,ebitmap_node_t *tnode;unsigned int i; -if (pdb->policyvers >=POLICYDB_VERSION_CONSTRAINT_NAMES ) { - rc =__cil_get_sepol_type_datum (pdb, item->data, - &sepol_type); -if (rc !=SEPOL_OK ) { -if (FLAVOR (item->data) ==CIL_TYPEATTRIBUTE ) { -struct cil_typeattribute *attr = - item->data; -if (!attr->keep) { - rc =0 ; - } + rc =__cil_get_sepol_type_datum (pdb, item->data, &sepol_type); +if (rc !=SEPOL_OK ) { +if (FLAVOR (item->data) ==CIL_TYPEATTRIBUTE ) { +struct cil_typeattribute *attr = item->data; +if (!attr->keep) { + rc =0 ; } } + } -if (sepol_type) { - rc =ebitmap_set_bit (&expr->type_names->types, - sepol_type->s.value -1 , -1 ); - } +if (sepol_type) { + rc =ebitmap_set_bit (&expr->type_names->types, + sepol_type->s.value -1 ,1 ); + } -if (rc !=SEPOL_OK ) { - goto exit; - } +if (rc !=SEPOL_OK ) { + goto exit; } rc =__cil_expand_type (item->data, &type_bitmap);
libsepol/include/sepol/policydb/policydb.h +2 -16
@@ -752,12 +752,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_BOUNDARY 24 -#define POLICYDB_VERSION_FILENAME_TRANS 25 -#define POLICYDB_VERSION_ROLETRANS 26 -#define POLICYDB_VERSION_NEW_OBJECT_DEFAULTS 27 -#define POLICYDB_VERSION_DEFAULT_TYPE 28 -#define POLICYDB_VERSION_CONSTRAINT_NAMES 29#define POLICYDB_VERSION_XEN_DEVICETREE 30/* Xen-specific */ #define POLICYDB_VERSION_XPERMS_IOCTL 30/* Linux-specific */ #define POLICYDB_VERSION_INFINIBAND 31/* Linux-specific */
@@ -768,18 +762,10 @@ 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_BOUNDARY +#define POLICYDB_VERSION_MIN POLICYDB_VERSION_XPERMS_IOCTL#define POLICYDB_VERSION_MAX POLICYDB_VERSION_NEVERAUDIT/* Module versions and specific changes*/ -#define MOD_POLICYDB_VERSION_BOUNDARY_ALIAS 10 -#define MOD_POLICYDB_VERSION_FILENAME_TRANS 11 -#define MOD_POLICYDB_VERSION_ROLETRANS 12 -#define MOD_POLICYDB_VERSION_ROLEATTRIB 13 -#define MOD_POLICYDB_VERSION_TUNABLE_SEP 14 -#define MOD_POLICYDB_VERSION_NEW_OBJECT_DEFAULTS 15 -#define MOD_POLICYDB_VERSION_DEFAULT_TYPE 16 -#define MOD_POLICYDB_VERSION_CONSTRAINT_NAMES 17#define MOD_POLICYDB_VERSION_XPERMS_IOCTL 18#define MOD_POLICYDB_VERSION_INFINIBAND 19#define MOD_POLICYDB_VERSION_GLBLUB 20
@@ -788,7 +774,7 @@ extern int policydb_set_target_platform(policydb_t *p, int platform);#define MOD_POLICYDB_VERSION_NEVERAUDIT 23#define MOD_POLICYDB_VERSION_TYPE_ATTR_ATTRS 24 -#define MOD_POLICYDB_VERSION_MIN MOD_POLICYDB_VERSION_BOUNDARY_ALIAS +#define MOD_POLICYDB_VERSION_MIN MOD_POLICYDB_VERSION_XPERMS_IOCTL#define MOD_POLICYDB_VERSION_MAX MOD_POLICYDB_VERSION_TYPE_ATTR_ATTRS#define POLICYDB_CONFIG_MLS 1
libsepol/src/conditional.c +2 -4
@@ -592,8 +592,7 @@ int cond_read_bool(policydb_t *p, hashtab_t h, struct policy_file *fp)if (str_read (&key, fp, len)) goto err; -if (p->policy_type !=POLICY_KERN && - p->policyvers >=MOD_POLICYDB_VERSION_TUNABLE_SEP ) { +if (p->policy_type !=POLICY_KERN ) { rc =next_entry (buf, fp,sizeof (uint32_t ));if (rc <0 ) goto err;
@@ -808,8 +807,7 @@ static int cond_read_node(policydb_t *p, cond_node_t *node, void *fp) goto err; } -if (p->policy_type !=POLICY_KERN && - p->policyvers >=MOD_POLICYDB_VERSION_TUNABLE_SEP ) { +if (p->policy_type !=POLICY_KERN ) { rc =next_entry (buf, fp,sizeof (uint32_t ));if (rc <0 ) goto err;
libsepol/src/policydb.c +18 -211
332 lines not on this page · raw message
libsepol/src/policydb_validate.c +2 -8
@@ -1586,11 +1586,6 @@ static int validate_ocontexts(sepol_handle_t *handle, const policydb_t *p,if (octx->u.iomem.low_iomem > octx->u.iomem.high_iomem) goto bad; -if (p->policyvers < -POLICYDB_VERSION_XEN_DEVICETREE && - octx->u.iomem.high_iomem > -0xFFFFFFFFULL ) - goto bad;break ;case OCON_XEN_DEVICETREE :if (validate_string_field (octx->u.name))
@@ -2088,9 +2083,8 @@ int policydb_validate(sepol_handle_t *handle, const policydb_t *p) goto bad;if (validate_role_allows (handle, p->role_allow, flavors)) goto bad; -if (p->policyvers >=POLICYDB_VERSION_FILENAME_TRANS ) -if (validate_filename_trans_hashtab (handle, p, flavors)) - goto bad; +if (validate_filename_trans_hashtab (handle, p, flavors)) + goto bad; }else {if ((p->policy_type ==POLICY_MOD ) && (p->p_commons.nprim >0 )) goto bad;
libsepol/src/services.c +3 -7
@@ -202,12 +202,10 @@ static void cat_expr_buf(char *e_buf, const char *string) }/* -* If the POLICY_KERN version is >= POLICYDB_VERSION_CONSTRAINT_NAMES, -* then for 'types' only, read the types_names->types list as it will +* For 'types' only, read the types_names->types list as it will * contain a list of types and attributes that were defined in the * policy source. -* For user and role plus types (for policy vers < -* POLICYDB_VERSION_CONSTRAINT_NAMES) just read the e->names list. +* For user and role just read the e->names list. */ static void get_name_list (constraint_expr_t *e,int type,const char *src,const char *op,int failed)
@@ -218,9 +216,7 @@ static void get_name_list(constraint_expr_t *e, int type, const char *src,char tmp_buf[128 ];int counter =0 ; -if (policydb->policy_type ==POLICY_KERN && - policydb->policyvers >=POLICYDB_VERSION_CONSTRAINT_NAMES && - type ==CEXPR_TYPE ) +if (policydb->policy_type ==POLICY_KERN && type ==CEXPR_TYPE ) types = &e->type_names->types;else types = &e->names;
libsepol/src/write.c +25 -101
255 lines not on this page · raw message
Signature · 1 line
2.55.0