Skip to content

Commit

Permalink
linux-user: detect overflow of MAP_FIXED mmap
Browse files Browse the repository at this point in the history
Relaxing the restrictions on 64 bit guests leads to the user being
able to attempt to map right at the edge of addressable memory. This
in turn lead to address overflow tripping the assert in page_set_flags
when the end address wrapped around.

Detect the wrap earlier and correctly -ENOMEM the guest (in the
reported case LTP mmap15).

Fixes: 7d8cbba
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reported-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200605154929.26910-15-alex.bennee@linaro.org>
  • Loading branch information
stsquad committed Jun 8, 2020
1 parent b677121 commit 8ef6188
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion linux-user/mmap.c
Expand Up @@ -467,7 +467,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
* It can fail only on 64-bit host with 32-bit target.
* On any other target/host host mmap() handles this error correctly.
*/
if (!guest_range_valid(start, len)) {
if (end < start || !guest_range_valid(start, len)) {
errno = ENOMEM;
goto fail;
}
Expand Down

0 comments on commit 8ef6188

Please sign in to comment.