diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2019-05-15 01:47:03 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-06-20 20:11:26 +0300 |
commit | bfa8c73482dae6bafc0741cbfd63f84d11311b36 (patch) | |
tree | 45ba07006431180afc6e37eeba6502c875c1dd44 /drivers/virt/fsl_hypervisor.c | |
parent | b96659f18c61120dbf8b4cc36fbc05589bf9dc02 (diff) | |
download | linux-bfa8c73482dae6bafc0741cbfd63f84d11311b36.tar.xz |
drivers/virt/fsl_hypervisor.c: prevent integer overflow in ioctl
commit 6a024330650e24556b8a18cc654ad00cfecf6c6c upstream.
The "param.count" value is a u64 thatcomes from the user. The code
later in the function assumes that param.count is at least one and if
it's not then it leads to an Oops when we dereference the ZERO_SIZE_PTR.
Also the addition can have an integer overflow which would lead us to
allocate a smaller "pages" array than required. I can't immediately
tell what the possible run times implications are, but it's safest to
prevent the overflow.
Link: http://lkml.kernel.org/r/20181218082129.GE32567@kadam
Fixes: 6db7199407ca ("drivers/virt: introduce Freescale hypervisor management driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Timur Tabi <timur@freescale.com>
Cc: Mihai Caraman <mihai.caraman@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/virt/fsl_hypervisor.c')
-rw-r--r-- | drivers/virt/fsl_hypervisor.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c index 32c8fc5f7a5c..7c95e0a8f68b 100644 --- a/drivers/virt/fsl_hypervisor.c +++ b/drivers/virt/fsl_hypervisor.c @@ -215,6 +215,9 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) * hypervisor. */ lb_offset = param.local_vaddr & (PAGE_SIZE - 1); + if (param.count == 0 || + param.count > U64_MAX - lb_offset - PAGE_SIZE + 1) + return -EINVAL; num_pages = (param.count + lb_offset + PAGE_SIZE - 1) >> PAGE_SHIFT; /* Allocate the buffers we need */ |