aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShachar Raindel <raindel@mellanox.com>2015-03-18 17:39:08 +0000
committerStefan Bader <stefan.bader@canonical.com>2015-05-29 11:54:15 +0200
commit4da8e76370cead7bd2d5d7d3c0c885183cc0ed6a (patch)
tree9a3e9566a58a248bd1ede59cd45f2004b47e0cf8
parent38d3b392b9f9dd15630112a586bf302309b06a53 (diff)
downloadlinux-2.6.32.y-drm33.z-4da8e76370cead7bd2d5d7d3c0c885183cc0ed6a.tar.gz
IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic
commit 8494057ab5e40df590ef6ef7d66324d3ae33356b upstream. Properly verify that the resulting page aligned end address is larger than both the start address and the length of the memory area requested. Both the start and length arguments for ib_umem_get are controlled by the user. A misbehaving user can provide values which will cause an integer overflow when calculating the page aligned end address. This overflow can cause also miscalculation of the number of pages mapped, and additional logic issues. Addresses: CVE-2014-8159 Signed-off-by: Shachar Raindel <raindel@mellanox.com> Signed-off-by: Jack Morgenstein <jackm@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> (cherry picked from commit 485f16b743d98527620396639b73d7214006f3c7) Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
-rw-r--r--drivers/infiniband/core/umem.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 6f7c096abf1366..2ecd8d6115aadf 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -92,6 +92,14 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
if (dmasync)
dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs);
+ /*
+ * If the combination of the addr and size requested for this memory
+ * region causes an integer overflow, return error.
+ */
+ if ((PAGE_ALIGN(addr + size) <= size) ||
+ (PAGE_ALIGN(addr + size) <= addr))
+ return ERR_PTR(-EINVAL);
+
if (!can_do_mlock())
return ERR_PTR(-EPERM);