qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3] linux-user: mprotect() should returns 0 when len is 0.


From: Soichiro Isshiki
Subject: [PATCH v3] linux-user: mprotect() should returns 0 when len is 0.
Date: Sat, 8 Oct 2022 22:06:43 +0900

On Sat, Oct 8, 2022 at 12:41 AM Soichiro Isshiki <sisshiki@isshiki-clinic.com> 
wrote:
> A validation for wrap-around was added, I think it is neccesory.

I noticed the validation for wrap-around is *not* necessary, because it is done
by guest_range_valid_untagged().

Signed-off-by: Soichiro Isshiki <sisshiki@mac.com>
---
 linux-user/mmap.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 28f3bc85ed..6f23a1ac39 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -124,17 +124,17 @@ int target_mprotect(abi_ulong start, abi_ulong len, int 
target_prot)
     if ((start & ~TARGET_PAGE_MASK) != 0) {
         return -TARGET_EINVAL;
     }
-    page_flags = validate_prot_to_pageflags(&host_prot, target_prot);
-    if (!page_flags) {
-        return -TARGET_EINVAL;
+    if (len == 0) {
+        return 0;
     }
     len = TARGET_PAGE_ALIGN(len);
-    end = start + len;
     if (!guest_range_valid_untagged(start, len)) {
         return -TARGET_ENOMEM;
     }
-    if (len == 0) {
-        return 0;
+    end = start + len;
+    page_flags = validate_prot_to_pageflags(&host_prot, target_prot);
+    if (!page_flags) {
+        return -TARGET_EINVAL;
     }
 
     mmap_lock();
-- 
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]