diff options
author | Eyal Itkin <eyal.itkin@gmail.com> | 2017-02-07 08:45:19 -0500 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2017-02-08 12:28:30 -0500 |
commit | 647bf3d8a8e5777319da92af672289b2a6c4dc66 (patch) | |
tree | 8d9a8e7885ba0e86ef6d52b1feffb3b698fc42ba | |
parent | 628f07d33c1f2e7bf31e0a4a988bb07914bd5e73 (diff) |
IB/rxe: Fix mem_check_range integer overflow
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>
-rw-r--r-- | drivers/infiniband/sw/rxe/rxe_mr.c | 8 |
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 d0faca294006..86a6585b847d 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) | |||
59 | 59 | ||
60 | case RXE_MEM_TYPE_MR: | 60 | case RXE_MEM_TYPE_MR: |
61 | case RXE_MEM_TYPE_FMR: | 61 | case RXE_MEM_TYPE_FMR: |
62 | return ((iova < mem->iova) || | 62 | if (iova < mem->iova || |
63 | ((iova + length) > (mem->iova + mem->length))) ? | 63 | length > mem->length || |
64 | -EFAULT : 0; | 64 | iova > mem->iova + mem->length - length) |
65 | return -EFAULT; | ||
66 | return 0; | ||
65 | 67 | ||
66 | default: | 68 | default: |
67 | return -EFAULT; | 69 | return -EFAULT; |