selinux: tighten type validation during policy load
Stephen Smalley
maintainerPATCH v2 1/1 selinux: tighten type validation during policy load
Tighten type validation during policy load to improve robustness in the face of ill-formed policies.
Signed-off-by Stephen Smalley <[email protected]>
---
v2 re-bases on top of selinux/dev and drops the checks covered by the merged patches from Christian.
security/selinux/ss/policydb.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
security/selinux/ss/policydb.c +9 -3
@@ -604,10 +604,15 @@ static int type_index(void *key, void *datum, void *datap) typdatum = datum; p = datap; +if (!typdatum->value || typdatum->value > p->p_types.nprim || + typdatum->bounds > p->p_types.nprim) { +pr_err ("SELinux: %s had value %u bounds %u nprim %u\n" , + (char *)key, typdatum->value, typdatum->bounds, + p->p_types.nprim); +return -EINVAL ; + } +if (typdatum->primary) { -if (!typdatum->value || typdatum->value > p->p_types.nprim || - typdatum->bounds > p->p_types.nprim) -return -EINVAL ; p->sym_val_to_name[SYM_TYPES ][typdatum->value -1 ] = key; p->type_val_to_struct[typdatum->value -1 ] = typdatum; }
@@ -1861,6 +1866,7 @@ static int role_bounds_sanity_check(void *key, void *datum, void *datap) } upper = p->role_val_to_struct[upper->bounds -1 ]; +ebitmap_for_each_positive_bit (&role->types, node, bit) {if (ebitmap_get_bit (&upper->types, bit))
Signature · 1 line
2.54.0