summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2017-06-02 15:36:39 -0700
committerBen Hutchings <ben@decadent.org.uk>2017-09-15 18:30:49 +0100
commite0d4246a9441204e5ff5b6de69d72443b80de485 (patch)
tree04df0eea91b28254d0dabcb37a9f13f0947b1a47 /drivers
parent35378d86b9f7417ab0495bac6cd781998cfe26eb (diff)
downloadlinux-e0d4246a9441204e5ff5b6de69d72443b80de485.tar.gz
linux-e0d4246a9441204e5ff5b6de69d72443b80de485.tar.bz2
linux-e0d4246a9441204e5ff5b6de69d72443b80de485.zip
drivers: char: mem: Fix wraparound check to allow mappings up to the end
commit 32829da54d9368103a2f03269a5120aa9ee4d5da upstream. 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()") Reported-by: Nico Huber <nico.h@gmx.de> Signed-off-by: Julius Werner <jwerner@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/char/mem.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 1c8cfa67f7e1..d78365603952 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -325,7 +325,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))