summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2022-08-17 17:05:03 +0200
committerRichard Henderson <richard.henderson@linaro.org>2022-09-06 08:04:25 +0100
commitaa98e2d885ca9de66ddd56d88b19b0e162cc90d7 (patch)
tree62bfe94717671e34be3b22a6cf769830aa7b37c6
parent872f3d046f2381e3f416519e82df96bd60818311 (diff)
downloadfocaccia-qemu-aa98e2d885ca9de66ddd56d88b19b0e162cc90d7.tar.gz
focaccia-qemu-aa98e2d885ca9de66ddd56d88b19b0e162cc90d7.zip
linux-user: Clear translations on mprotect()
Currently it's possible to execute pages that do not have PAGE_EXEC
if there is an existing translation block. Fix by invalidating TBs
that touch the affected pages.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20220817150506.592862-2-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r--linux-user/mmap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 048c4135af..6a828e8418 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -177,9 +177,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot)
             goto error;
         }
     }
+
     page_set_flags(start, start + len, page_flags);
-    mmap_unlock();
-    return 0;
+    tb_invalidate_phys_range(start, start + len);
+    ret = 0;
+
 error:
     mmap_unlock();
     return ret;