public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] overflow check calculation in mm/mmap.c is incorrect linux-3.12.38
@ 2015-04-30  5:14 Reese Faucette
  2015-05-07 23:53 ` Andrew Morton
  2015-05-08  9:46 ` Rasmus Villemoes
  0 siblings, 2 replies; 4+ messages in thread
From: Reese Faucette @ 2015-04-30  5:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: alan

When checking for overflow, the code in mm/mmap.c compares the first byte
*after* the end of mapped region to the start of the region instead of the
last byte of the mapped region.  This prevents mapping a region which abuts
the end of physical space, as mmap() incorrectly rejects the region with
-EOVERFLOW, because pgoff + (len >> PAGE_SHIFT) will be 0, which is < pgoff.
-reese

Reese Faucette
Cisco Systems, Inc.

====================================================
--- mm/mmap.c
+++ mm/mmap.c
@@ -1241,7 +1241,7 @@
                return -ENOMEM;

        /* offset overflow? */
-       if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
+       if ((pgoff + (len >> PAGE_SHIFT) - 1) < pgoff)
                return -EOVERFLOW;

        /* Too many mappings? */


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-13 16:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-30  5:14 [PATCH] overflow check calculation in mm/mmap.c is incorrect linux-3.12.38 Reese Faucette
2015-05-07 23:53 ` Andrew Morton
2015-05-08  9:46 ` Rasmus Villemoes
2015-05-13 16:58   ` Reese Faucette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox