stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "drivers: char: mem: Fix wraparound check to allow mappings up to the end" has been added to the 4.4-stable tree
@ 2017-06-12 12:49 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-06-12 12:49 UTC (permalink / raw)
  To: jwerner, gregkh, nico.h; +Cc: stable, stable-commits


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 end

to the 4.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drivers-char-mem-fix-wraparound-check-to-allow-mappings-up-to-the-end.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 32829da54d9368103a2f03269a5120aa9ee4d5da Mon Sep 17 00:00:00 2001
From: Julius Werner <jwerner@chromium.org>
Date: Fri, 2 Jun 2017 15:36:39 -0700
Subject: drivers: char: mem: Fix wraparound check to allow mappings up to the end

From: Julius Werner <jwerner@chromium.org>

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>

---
 drivers/char/mem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -346,7 +346,7 @@ static int mmap_mem(struct file *file, s
 	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))


Patches currently in stable-queue which might be from jwerner@chromium.org are

queue-4.4/drivers-char-mem-fix-wraparound-check-to-allow-mappings-up-to-the-end.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-06-12 12:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-12 12:49 Patch "drivers: char: mem: Fix wraparound check to allow mappings up to the end" has been added to the 4.4-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).