bsd-user: Use page_check_range_empty for MAP_EXCL
authorRichard Henderson <richard.henderson@linaro.org>
Fri, 7 Jul 2023 20:40:38 +0000 (21:40 +0100)
committerRichard Henderson <richard.henderson@linaro.org>
Sat, 15 Jul 2023 07:02:32 +0000 (08:02 +0100)
The previous check returned -1 when any page within
[start, start+len) is unmapped, not when all are unmapped.

Cc: Warner Losh <imp@bsdimp.com>
Cc: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Warner Losh <imp@bsdimp.com>
Message-Id: <20230707204054.8792-11-richard.henderson@linaro.org>

bsd-user/mmap.c

index 565b9f97edb41f9b5007dc7c03182a35ec8ba1ad..07b5b8055e74e09887ea08e89a08ca7a3e192b3c 100644 (file)
@@ -609,7 +609,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
         }
 
         /* Reject the mapping if any page within the range is mapped */
-        if ((flags & MAP_EXCL) && page_check_range(start, len, 0) < 0) {
+        if ((flags & MAP_EXCL) && !page_check_range_empty(start, end - 1)) {
             errno = EINVAL;
             goto fail;
         }