Chromium Code Reviews

Issue 1608253002: Never unmap memory reserved for RELRO file creation. (Closed)

Created:
4 years, 11 months ago by simonb (inactive)
Modified:
4 years, 11 months ago
Reviewers:
CC:
chromium-reviews
Base URL:
https://chromium.googlesource.com/chromium/src.git@2623
Target Ref:
refs/pending/branch-heads/2623
Project:
chromium
Visibility:
Public.

Description

Never unmap memory reserved for RELRO file creation. After loading a library with android_dlopen_ext and passing the flag ANDROID_DLEXT_RESERVED_ADDRESS, a subsequent dlclose will unmap the part of the reservation occupied by the library, but leave the remainder of the reservation mapped. If we ourselves later unmap the entire reservation, we may also unmap data from a thread that happened to map into the hole created in our reservation by the dlclose unmap. This is an unpleasant mmap/munmap threads race. Because dlclose's unmap is opaque to us, we cannot readily unmap the remaining portions of our reservation because we do not know exactly where they now start and end. However, we only dlclose on relro creation, and this occurs just once, on browser process startup. By leaving these remaining reservation portions mapped but unused, we 'waste' a few Mb of virtual address space, but crucially we do not waste actual memory because these addresses are never used by anything. Implemented by explicitly releasing the reservation scoped mapping *before* the dlclose call in relro creation. Also, make failure to trim address space on library load for run a non-fatal error (warning). Failure to munmap can really only be due to coding error. And even if it does fail the library code can and will still run okay, albeit again with minor loss of some virtual address space that we otherwise might have recovered. BUG=568880 Review URL: https://codereview.chromium.org/1583093007 Cr-Commit-Position: refs/heads/master@{#370015} (cherry picked from commit b857f7676bc16665ca86d81db877dc11094bcb7a) Committed: https://chromium.googlesource.com/chromium/src/+/3547a47a96f4af6a7fb78e50cc86e3f812783438

Patch Set 1 #

Unified diffs Side-by-side diffs Stats (+66 lines, -38 lines)
M base/android/linker/modern_linker_jni.cc View 5 chunks +66 lines, -38 lines 0 comments

Messages

Total messages: 2 (1 generated)
simonb (inactive)
4 years, 11 months ago (2016-01-20 15:04:53 UTC) #2
Message was sent while issue was closed.
Committed patchset #1 (id:1) manually as
3547a47a96f4af6a7fb78e50cc86e3f812783438.

Powered by Google App Engine