]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
selinux: detect invalid ebitmap
authorWilliam Roberts <william.c.roberts@intel.com>
Tue, 23 Aug 2016 20:49:23 +0000 (13:49 -0700)
committerPaul Moore <paul@paul-moore.com>
Mon, 29 Aug 2016 23:19:50 +0000 (19:19 -0400)
When count is 0 and the highbit is not zero, the ebitmap is not
valid and the internal node is not allocated. This causes issues
when routines, like mls_context_isvalid() attempt to use the
ebitmap_for_each_bit() and ebitmap_node_get_bit() as they assume
a highbit > 0 will have a node allocated.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/ebitmap.c

index 894b6cdc11c5410591aaf46a3170eeea13dc444a..7d10e5d418bb00978d7f30aadc6d86d3b2533bd7 100644 (file)
@@ -374,6 +374,9 @@ int ebitmap_read(struct ebitmap *e, void *fp)
                goto ok;
        }
 
+       if (e->highbit && !count)
+               goto bad;
+
        for (i = 0; i < count; i++) {
                rc = next_entry(&startbit, fp, sizeof(u32));
                if (rc < 0) {