lkml.org 
[lkml]   [2015]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] overflow check calculation in mm/mmap.c is incorrect linux-3.12.38
Date
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? */


\
 
 \ /
  Last update: 2015-04-30 07:41    [W:0.164 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site