summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-09 09:32:23 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-09 11:31:18 +0100
commitb940dd4fa8532f1527df30a179cce342fc49ad73 (patch)
tree80dccf667cc7ce2c5abeb4a90c8f3b77341e5bef /Userland
parent9588f01739179bebbed960ceecbad92bca90d7f9 (diff)
downloadserenity-b940dd4fa8532f1527df30a179cce342fc49ad73.zip
UserspaceEmulator: Never try to mprotect(PROT_EXEC) MmapRegion backing
We never want to map host memory executable anyway, so let's always mask off the PROT_EXEC bit.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/DevTools/UserspaceEmulator/MmapRegion.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp
index 4661feb656..43655962e0 100644
--- a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp
+++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp
@@ -242,7 +242,10 @@ void MmapRegion::set_prot(int prot)
set_writable(prot & PROT_WRITE);
set_executable(prot & PROT_EXEC);
if (m_file_backed) {
- mprotect(m_data, size(), prot);
+ if (mprotect(m_data, size(), prot & ~PROT_EXEC) < 0) {
+ perror("MmapRegion::set_prot: mprotect");
+ exit(1);
+ }
}
}