Reported by Dan Carpenter <dan.carpenter@oracle.com>
outsize = sizeof(*gfout) + gfin->gf_pathlen;
Where outsize is int and gf_pathlen is u32 from userspace
can lead to integer overflowwhere outsize is some small number
less than sizeof(*gfout)
Add a check for pathlen to be of sensical size.
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/11412
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5476
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
if (get_user(pathlen, &gfin->gf_pathlen))
return -EFAULT;
+ if (pathlen > PATH_MAX)
+ return -EINVAL;
+
outsize = sizeof(*gfout) + pathlen;
OBD_ALLOC(gfout, outsize);