Skip to contentSkip to conversation

Fixes on top of CVE-2014-8159 kernel: infiniband: uverbs: unprotected physical memory access

PATCH RESEND New Yann Droneaud 2 participants 3 messages Apr 8, 2015 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

cover Fixes on top of CVE-2014-8159 kernel: infiniband: uverbs: unprotected physical memory access

[Re-sent patch set with correct Cc: <[email protected]>]

Hi,

Please find one patch to prevent a possible issue partially addressed by commit 8494057ab5e4 ("IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic") (see discussions in [1]) and another one to add back the possibility of registering memory mapped at 0 (which is probably not something to be allowed, but it's not up to ib_umem_get() to prevent it).

[1] "Re: CVE-2014-8159 kernel: infiniband: uverbs: unprotected physical memory access"

http://mid.gmane.org/1428497043.22575.176.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org
http://marc.info/?i=1428497043.22575.176.camel-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org

Regards.

Yann Droneaud (2):
IB/core: disallow registering 0-sized memory region IB/core: don't disallow registering region starting at 0x0

 drivers/infiniband/core/umem.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 6 lines
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH RESEND 1/2 IB/core: disallow registering 0-sized memory region

If ib_umem_get() is called with a size equal to 0 and an non-page aligned address, one page will be pinned and a 0-sized umem will be returned to the caller.

This should not be allowed: it's not expected for a memory region to have a size equal to 0.

This patch adds a check to explicitly refuse to register a 0-sized region.

Additionally, it updates check added in commit 8494057ab5e4 ("IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic") to not care about 0-sized region:
it would had catched 0-sized region only if address was already page aligned.

Cc <[email protected]> # 8494057ab5e4 ("IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic")
Cc Shachar Raindel <[email protected]>
Cc Jack Morgenstein <[email protected]>
Cc Or Gerlitz <[email protected]>
---
 drivers/infiniband/core/umem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/core/umem.c +4 -1
index 8c014b5dab4c..cbe361645c1b 100644
@@ -99,12 +99,15 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
 	if (dmasync)
 		dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs);
 
+	if (!size)
+		return ERR_PTR(-EINVAL);
+
 	/*
 	 * 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))
+	    (PAGE_ALIGN(addr + size) < addr))
 		return ERR_PTR(-EINVAL);
 
 	if (!can_do_mlock())
Signature · 1 line
2.1.0

A message that is not in the archive (sent off-list or not yet received): cover.1428523125.git.ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org

#3 lore raw

PATCH RESEND 2/2 IB/core: don't disallow registering region starting at 0x0

In a call to ib_umem_get(), if address is 0x0 and size is already page aligned, check added in commit 8494057ab5e4 ("IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic") will refuse to register a memory region that could otherwise be valid (provided vm.mmap_min_addr sysctl and mmap_low_allowed SELinux knobs allow userspace to map something at address 0x0).

This patch allows back such registration: ib_umem_get() should probably don't care of the base address provided it can be pinned with get_user_pages().

Cc <[email protected]> # 8494057ab5e4 ("IB/uverbs: Prevent integer overflow in ib_umem_get address arithmetic")
Cc Shachar Raindel <raindel-VPRAkNaXOzVWk0Htik3J/[email protected]>
Cc Jack Morgenstein <jackm-VPRAkNaXOzVWk0Htik3J/[email protected]>
Cc Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/[email protected]>
---
 drivers/infiniband/core/umem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem.c +1 -1
index cbe361645c1b..a0aadd05ab6d 100644
@@ -106,7 +106,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
 	 * 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) ||
+	if ((PAGE_ALIGN(addr + size) < size) ||
 	    (PAGE_ALIGN(addr + size) < addr))
 		return ERR_PTR(-EINVAL);
 
Signature · 6 lines
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html