]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selinux: avoid avtab overflows
authorChristian Göttsche <cgzones@googlemail.com>
Thu, 6 Jul 2023 13:23:18 +0000 (15:23 +0200)
committerPaul Moore <paul@paul-moore.com>
Tue, 18 Jul 2023 22:29:47 +0000 (18:29 -0400)
Prevent inserting more than the supported U32_MAX number of entries.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/avtab.c

index 6766edc0fe687cc97e64f77fb8eb1278369c0355..7d21de48c28d7f0ce49e82b5233df2f18f12ddc8 100644 (file)
@@ -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];