From: Jonathan Marler <johnnymarler@gmail.com>
To: qemu-devel@nongnu.org
Cc: Jonathan Marler <johnnymarler@gmail.com>
Subject: [PATCH] linux-user/mmap.c: fix integer underflow in target_mremap
Date: Sat, 2 May 2020 10:12:25 -0600 [thread overview]
Message-ID: <20200502161225.14346-1-johnnymarler@gmail.com> (raw)
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.
Signed-off-by: Jonathan Marler <johnnymarler@gmail.com>
---
linux-user/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index e378033797..caab62909e 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -708,7 +708,7 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
if (prot == 0) {
host_addr = mremap(g2h(old_addr), old_size, new_size, flags);
if (host_addr != MAP_FAILED && reserved_va && old_size > new_size) {
- mmap_reserve(old_addr + old_size, new_size - old_size);
+ mmap_reserve(old_addr + old_size, old_size - new_size);
}
} else {
errno = ENOMEM;
--
2.23.1
next reply other threads:[~2020-05-02 16:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-02 16:12 Jonathan Marler [this message]
2020-05-02 23:43 ` [PATCH] linux-user/mmap.c: fix integer underflow in target_mremap Jonathan Marler
2020-05-15 13:36 ` Jonathan Marler
2020-05-18 18:13 ` Jonathan Marler
2020-05-19 8:11 ` Stefano Garzarella
2020-05-19 12:17 ` Philippe Mathieu-Daudé
2020-05-28 9:34 ` Laurent Vivier
2020-05-28 9:35 ` Laurent Vivier
[not found] <20200502074901.30784-1-johnnymarler@gmail.com>
2020-05-02 8:38 ` Laurent Vivier
2020-05-02 16:13 ` Jonathan Marler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200502161225.14346-1-johnnymarler@gmail.com \
--to=johnnymarler@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).