OSDN Git Service

linux-user/mmap.c: fix integer underflow in target_mremap
authorJonathan Marler <johnnymarler@gmail.com>
Sat, 2 May 2020 16:12:25 +0000 (10:12 -0600)
committerLaurent Vivier <laurent@vivier.eu>
Fri, 5 Jun 2020 19:23:22 +0000 (21:23 +0200)
commit257a7e212d5e518ac53bd6a02a3157cf4594c8b3
tree0ae92131a977d26170d8f2f1f3ab2ab856528c29
parentfd568660b7ae9b9e45cbb616acc91ae4c065c32d
linux-user/mmap.c: fix integer underflow in target_mremap

Fixes: https://bugs.launchpad.net/bugs/1876373

This code path in mmap occurs when a page size is decreased with mremap.  When a section of pages is shrunk, qemu calls mmap_reserve on the pages that were released.  However, it has the diff operation reversed, subtracting the larger old_size from the smaller new_size.  Instead, it should be subtracting the smaller new_size from the larger old_size.  You can also see in the previous line of the change that this mmap_reserve call only occurs when old_size > new_size.

Bug: https://bugs.launchpad.net/qemu/+bug/1876373
Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
Reviewded-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200502161225.14346-1-johnnymarler@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/mmap.c