Commit 7c686af0 authored by William Roberts's avatar William Roberts Committed by Paul Moore

selinux: fix overflow and 0 length allocations

Throughout the SELinux LSM, values taken from sepolicy are
used in places where length == 0 or length == <saturated>
matter, find and fix these.
Signed-off-by: default avatarWilliam Roberts <william.c.roberts@intel.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 3bc7bcf6
...@@ -242,6 +242,8 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp) ...@@ -242,6 +242,8 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
goto err; goto err;
len = le32_to_cpu(buf[2]); len = le32_to_cpu(buf[2]);
if (((len == 0) || (len == (u32)-1)))
goto err;
rc = -ENOMEM; rc = -ENOMEM;
key = kmalloc(len + 1, GFP_KERNEL); key = kmalloc(len + 1, GFP_KERNEL);
......
...@@ -1094,6 +1094,9 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len) ...@@ -1094,6 +1094,9 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len)
int rc; int rc;
char *str; char *str;
if ((len == 0) || (len == (u32)-1))
return -EINVAL;
str = kmalloc(len + 1, flags); str = kmalloc(len + 1, flags);
if (!str) if (!str)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment