diff --git a/libsepol/src/policydb_validate.c b/libsepol/src/policydb_validate.c index d04f6bcd..016ab655 100644 --- a/libsepol/src/policydb_validate.c +++ b/libsepol/src/policydb_validate.c @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -1552,6 +1553,23 @@ bad: return -1; } +static int validate_policycaps(sepol_handle_t *handle, const policydb_t *p) +{ + ebitmap_node_t *node; + uint32_t i; + + ebitmap_for_each_positive_bit(&p->policycaps, node, i) { + if (!sepol_polcap_getname(i)) + goto bad; + } + + return 0; + +bad: + ERR(handle, "Invalid policy capability"); + return -1; +} + static void validate_array_destroy(validate_t flavors[]) { unsigned int i; @@ -1574,6 +1592,9 @@ int policydb_validate(sepol_handle_t *handle, const policydb_t *p) if (validate_properties(handle, p)) goto bad; + if (validate_policycaps(handle, p)) + goto bad; + if (p->policy_type == POLICY_KERN) { if (validate_avtab(handle, &p->te_avtab, p, flavors)) goto bad;