summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorEyal Itkin <eyal.itkin@gmail.com>2017-02-07 16:45:19 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-14 15:25:42 -0800
commitb7dd5edc3dd9191f2cb1bd508279b0ff7274c5aa (patch)
treeb43edcc130cd4e7749344fa29ed8f16bc0c82f90 /drivers
parent5476efeec1351d6df008a38c528099be65bfed0f (diff)
downloadlinux-rpi3-b7dd5edc3dd9191f2cb1bd508279b0ff7274c5aa.tar.gz
linux-rpi3-b7dd5edc3dd9191f2cb1bd508279b0ff7274c5aa.tar.bz2
linux-rpi3-b7dd5edc3dd9191f2cb1bd508279b0ff7274c5aa.zip
IB/rxe: Fix mem_check_range integer overflow
commit 647bf3d8a8e5777319da92af672289b2a6c4dc66 upstream. Update the range check to avoid integer-overflow in edge case. Resolves CVE 2016-8636. Signed-off-by: Eyal Itkin <eyal.itkin@gmail.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/infiniband/sw/rxe/rxe_mr.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
index 1869152f1d23..9b732c5f89e1 100644
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -59,9 +59,11 @@ int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length)
case RXE_MEM_TYPE_MR:
case RXE_MEM_TYPE_FMR:
- return ((iova < mem->iova) ||
- ((iova + length) > (mem->iova + mem->length))) ?
- -EFAULT : 0;
+ if (iova < mem->iova ||
+ length > mem->length ||
+ iova > mem->iova + mem->length - length)
+ return -EFAULT;
+ return 0;
default:
return -EFAULT;