Skip to content

Commit c7788e8

Browse files
authored
Merge pull request #2 from marler8997/mremapUnderflow
add mremap underflow patch
2 parents 016e2c1 + f3cfd3f commit c7788e8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

command/patch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ set -e
66

77
WORKDIR "/work/src/${QEMU_SRC_BASENAME}"
88
RUN patch -p1 -i "${WORK_ROOT}/patch/${QEMU_NAME}.diff"
9+
RUN patch -p1 -i "${WORK_ROOT}/patch/mremap-underflow.diff"

patch/mremap-underflow.diff

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
2+
index e378033797..da0fe4cc86 100644
3+
--- a/linux-user/mmap.c
4+
+++ b/linux-user/mmap.c
5+
@@ -708,7 +708,8 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
6+
if (prot == 0) {
7+
host_addr = mremap(g2h(old_addr), old_size, new_size, flags);
8+
if (host_addr != MAP_FAILED && reserved_va && old_size > new_size) {
9+
- mmap_reserve(old_addr + old_size, new_size - old_size);
10+
+ if (new_size > old_size)
11+
+ mmap_reserve(old_addr + old_size, new_size - old_size);
12+
}
13+
} else {
14+
errno = ENOMEM;

0 commit comments

Comments
 (0)