提交 38138fab 编写于 作者: A Alex Bennée 提交者: Laurent Vivier

linux-user/mmap.c: handle invalid len maps correctly

I've slightly re-organised the check to more closely match the
sequence that the kernel uses in do_mmap(). We check for both the zero
case (EINVAL) and the overflow length case (ENOMEM).
Signed-off-by: NAlex Bennée <alex.bennee@linaro.org>
Cc: umarcor <1783362@bugs.launchpad.net>
Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
Message-Id: <20180730134321.19898-2-alex.bennee@linaro.org>
Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
上级 6d9dd5fb
......@@ -391,14 +391,23 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
}
#endif
if (offset & ~TARGET_PAGE_MASK) {
if (!len) {
errno = EINVAL;
goto fail;
}
/* Also check for overflows... */
len = TARGET_PAGE_ALIGN(len);
if (len == 0)
goto the_end;
if (!len) {
errno = ENOMEM;
goto fail;
}
if (offset & ~TARGET_PAGE_MASK) {
errno = EINVAL;
goto fail;
}
real_start = start & qemu_host_page_mask;
host_offset = offset & qemu_host_page_mask;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册