From: Christian Göttsche Date: Thu, 6 Jul 2023 13:23:18 +0000 (+0200) Subject: selinux: avoid avtab overflows X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f785c54101e01f8e5f84464f8755671246b13794;p=linux.git selinux: avoid avtab overflows Prevent inserting more than the supported U32_MAX number of entries. Signed-off-by: Christian Göttsche Signed-off-by: Paul Moore --- diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c index 6766edc0fe68..7d21de48c28d 100644 --- a/security/selinux/ss/avtab.c +++ b/security/selinux/ss/avtab.c @@ -110,7 +110,7 @@ static int avtab_insert(struct avtab *h, const struct avtab_key *key, struct avtab_node *prev, *cur, *newnode; u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD); - if (!h || !h->nslot) + if (!h || !h->nslot || h->nel == U32_MAX) return -EINVAL; hvalue = avtab_hash(key, h->mask); @@ -156,7 +156,7 @@ struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_node *prev, *cur; u16 specified = key->specified & ~(AVTAB_ENABLED|AVTAB_ENABLED_OLD); - if (!h || !h->nslot) + if (!h || !h->nslot || h->nel == U32_MAX) return NULL; hvalue = avtab_hash(key, h->mask); for (prev = NULL, cur = h->htable[hvalue];