]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
VG_(am_extend_into_adjacent_reservation_client): Do not allow the
authorJulian Seward <jseward@acm.org>
Wed, 28 Sep 2005 01:46:31 +0000 (01:46 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 28 Sep 2005 01:46:31 +0000 (01:46 +0000)
reservation segment to be shrunk below one page.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4803

coregrind/m_aspacemgr/aspacemgr.c
coregrind/pub_core_aspacemgr.h

index 97ac7604261a59c4ecd31e1ec299a1f55ade9543..f0ec2f5d454991c87036f1e951c6e41cd0a24cdb 100644 (file)
@@ -2383,8 +2383,10 @@ Bool VG_(am_create_reservation) ( Addr start, SizeT length,
    extended forwards in the address space, and the reservation must be
    the next one along.  If DELTA is negative, the segment is extended
    backwards in the address space and the reservation must be the
-   previous one.  DELTA must be page aligned and must not exceed the
-   size of the reservation segment. */
+   previous one.  DELTA must be page aligned.  abs(DELTA) must not
+   exceed the size of the reservation segment minus one page, that is,
+   the reservation segment after the operation must be at least one
+   page long. */
 
 Bool VG_(am_extend_into_adjacent_reservation_client) ( NSegment* seg, 
                                                        SSizeT    delta )
@@ -2418,7 +2420,8 @@ Bool VG_(am_extend_into_adjacent_reservation_client) ( NSegment* seg,
           || nsegments[segR].kind != SkResvn
           || nsegments[segR].smode != SmLower
           || nsegments[segR].start != nsegments[segA].end + 1
-          || delta > (nsegments[segR].end - nsegments[segR].start + 1))
+          || delta + VKI_PAGE_SIZE 
+                > (nsegments[segR].end - nsegments[segR].start + 1))
         return False;
         
       /* Extend the kernel's mapping. */
@@ -2452,7 +2455,8 @@ Bool VG_(am_extend_into_adjacent_reservation_client) ( NSegment* seg,
           || nsegments[segR].kind != SkResvn
           || nsegments[segR].smode != SmUpper
           || nsegments[segR].end + 1 != nsegments[segA].start
-          || delta > (nsegments[segR].end - nsegments[segR].start + 1))
+          || delta + VKI_PAGE_SIZE 
+                > (nsegments[segR].end - nsegments[segR].start + 1))
         return False;
         
       /* Extend the kernel's mapping. */
index b4fb4d859f55016c28c4b4decc2e72bd0e078da4..e73d8a95df7c330319a7cc379693217995b5d7d7 100644 (file)
@@ -262,8 +262,10 @@ extern Bool VG_(am_create_reservation)
    extended forwards in the address space, and the reservation must be
    the next one along.  If DELTA is negative, the segment is extended
    backwards in the address space and the reservation must be the
-   previous one.  DELTA must be page aligned and must not exceed the
-   size of the reservation segment. */
+   previous one.  DELTA must be page aligned.  abs(DELTA) must not
+   exceed the size of the reservation segment minus one page, that is,
+   the reservation segment after the operation must be at least one
+   page long. */
 extern Bool VG_(am_extend_into_adjacent_reservation_client) 
    ( NSegment* seg, SSizeT delta );