Skip to contentSkip to conversation

patch "drivers: char: mem: Fix wraparound check to allow mappings up to the" added to char-misc-linus

PATCH [email protected] 1 participant 1 message Jun 3, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

drivers: char: mem: Fix wraparound check to allow mappings up to the

to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

Quoted 1 line

From 32829da54d9368103a2f03269a5120aa9ee4d5da Mon Sep 17 00:00:00 2001

From: Julius Werner <[email protected]>
Date: Fri, 2 Jun 2017 15:36:39 -0700
Subject: drivers: char: mem: Fix wraparound check to allow mappings up to the
end

A recent fix to /dev/mem prevents mappings from wrapping around the end of physical address space. However, the check was written in a way that also prevents a mapping reaching just up to the end of physical address space, which may be a valid use case (especially on 32-bit systems). This patch fixes it by checking the last mapped address (instead of the first address behind that) for overflow.

Fixes b299cde245 ("drivers: char: mem: Check for address space wraparound with mmap()")
---
 drivers/char/mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/mem.c +1 -1
index 6e0cbe092220..593a8818aca9 100644
@@ -343,7 +343,7 @@ static int mmap_mem(struct file *file, struct vm_area_struct *vma)
 	phys_addr_t offset = (phys_addr_t)vma->vm_pgoff << PAGE_SHIFT;
 
 	/* It's illegal to wrap around the end of the physical address space. */
-	if (offset + (phys_addr_t)size < offset)
+	if (offset + (phys_addr_t)size - 1 < offset)
 		return -EINVAL;
 
 	if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
Signature · 1 line
2.13.0