[llvm] ba0e714 - Do not map read-only data memory sections with EXECUTE flags.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 01:55:56 PDT 2020


Author: David Turner
Date: 2020-08-05T10:51:48+02:00
New Revision: ba0e71432a60e1fa2da9e098cbc574a1d9b9618b

URL: https://github.com/llvm/llvm-project/commit/ba0e71432a60e1fa2da9e098cbc574a1d9b9618b
DIFF: https://github.com/llvm/llvm-project/commit/ba0e71432a60e1fa2da9e098cbc574a1d9b9618b.diff

LOG: Do not map read-only data memory sections with EXECUTE flags.

The code in SectionMemoryManager.cpp unnecessarily maps
read-only data sections with the READ+EXECUTE flags. This is
undesirable from a security stand-point.

Moreover, on the Fuchsia platform, which is now very strict
about mapping pages with the EXECUTE permission, this simply
fails, because the section's pages were initially allocated
with only the READ+WRITE flags.

A more detailed description of the issue can be found in this
public SwiftShader bug:

  https://issuetracker.google.com/issues/154586551

This patch just restrict the mapping to the READ flag for ROData
sections. Code sections are still mapped with READ+EXECUTE as
expected.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D78574

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/SectionMemoryManager.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp b/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
index febcabfaa571..138b18a1ddcb 100644
--- a/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/SectionMemoryManager.cpp
@@ -161,8 +161,7 @@ bool SectionMemoryManager::finalizeMemory(std::string *ErrMsg) {
   }
 
   // Make read-only data memory read-only.
-  ec = applyMemoryGroupPermissions(RODataMem,
-                                   sys::Memory::MF_READ | sys::Memory::MF_EXEC);
+  ec = applyMemoryGroupPermissions(RODataMem, sys::Memory::MF_READ);
   if (ec) {
     if (ErrMsg) {
       *ErrMsg = ec.message();


        


More information about the llvm-commits mailing list