浏览代码

Merge tag 'rdma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband

Pull infiniband/rdma fix from Roland Dreier:
 "Fix for exploitable integer overflow in uverbs interface"

* tag 'rdma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband:
  IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic
Linus Torvalds 10 年之前
父节点
当前提交
06459fc02f
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      drivers/infiniband/core/umem.c

+ 8 - 0
drivers/infiniband/core/umem.c

@@ -99,6 +99,14 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
 	if (dmasync)
 	if (dmasync)
 		dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs);
 		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())
 	if (!can_do_mlock())
 		return ERR_PTR(-EPERM);
 		return ERR_PTR(-EPERM);