Commit 0848ce8f authored by Alex Ilin's avatar Alex Ilin Committed by Commit Bot

Do not populate ModuleCache on arm64 POSIX.

arm64 has execute-only memory (XOM) protecting code pages from being read.
PosixModule reads executable pages in order to extract module info. This
may result in a crash if the module is mapped as XOM.

This CL effectively disables ModuleCache on POSIX arm64 platforms.

Alternative solution would be to obtain map permissions before accessing
module's executable memory by parsing /proc/self/maps. Then, return
nullptr iff the mapping has execute-only protection.

Bug: 957801
Change-Id: I37b2dfa012a0f723a75579d0aabe4c096762f948
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1599391
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658995}
parent e6b955fb
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <elf.h> #include <elf.h>
#include "base/debug/elf_reader.h" #include "base/debug/elf_reader.h"
#include "build/build_config.h"
namespace base { namespace base {
...@@ -84,11 +85,19 @@ PosixModule::PosixModule(const Dl_info& dl_info) ...@@ -84,11 +85,19 @@ PosixModule::PosixModule(const Dl_info& dl_info)
// static // static
std::unique_ptr<ModuleCache::Module> ModuleCache::CreateModuleForAddress( std::unique_ptr<ModuleCache::Module> ModuleCache::CreateModuleForAddress(
uintptr_t address) { uintptr_t address) {
#if defined(ARCH_CPU_ARM64)
// arm64 has execute-only memory (XOM) protecting code pages from being read.
// PosixModule reads executable pages in order to extract module info. This
// may result in a crash if the module is mapped as XOM
// (https://crbug.com/957801).
return nullptr;
#else
Dl_info info; Dl_info info;
if (!dladdr(reinterpret_cast<const void*>(address), &info)) if (!dladdr(reinterpret_cast<const void*>(address), &info))
return nullptr; return nullptr;
return std::make_unique<PosixModule>(info); return std::make_unique<PosixModule>(info);
#endif
} }
} // namespace base } // namespace base
...@@ -62,8 +62,8 @@ class FakeModule : public ModuleCache::Module { ...@@ -62,8 +62,8 @@ class FakeModule : public ModuleCache::Module {
bool is_native_; bool is_native_;
}; };
#if defined(OS_POSIX) && !defined(OS_IOS) || defined(OS_WIN) || \ #if defined(OS_POSIX) && !defined(OS_IOS) && !defined(ARCH_CPU_ARM64) || \
defined(OS_FUCHSIA) defined(OS_WIN) || defined(OS_FUCHSIA)
#define MAYBE_TEST(TestSuite, TestName) TEST(TestSuite, TestName) #define MAYBE_TEST(TestSuite, TestName) TEST(TestSuite, TestName)
#else #else
#define MAYBE_TEST(TestSuite, TestName) TEST(TestSuite, DISABLED_##TestName) #define MAYBE_TEST(TestSuite, TestName) TEST(TestSuite, DISABLED_##TestName)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment