Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Issue 1583093007: 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:
dimitry, rmcilroy
CC:
chromium-reviews, vmpstr+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
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 Committed: https://crrev.com/b857f7676bc16665ca86d81db877dc11094bcb7a Cr-Commit-Position: refs/heads/master@{#370015}

Patch Set 1 #

Total comments: 6

Patch Set 2 : Update for review feedback. #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+66 lines, -38 lines) Patch
M base/android/linker/modern_linker_jni.cc View 1 5 chunks +66 lines, -38 lines 1 comment Download

Messages

Total messages: 17 (7 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1583093007/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1583093007/1
4 years, 11 months ago (2016-01-15 13:26:25 UTC) #2
simonb (inactive)
4 years, 11 months ago (2016-01-15 13:27:19 UTC) #4
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 11 months ago (2016-01-15 13:58:55 UTC) #6
rmcilroy
LGTM. https://codereview.chromium.org/1583093007/diff/1/base/android/linker/modern_linker_jni.cc File base/android/linker/modern_linker_jni.cc (right): https://codereview.chromium.org/1583093007/diff/1/base/android/linker/modern_linker_jni.cc#newcode316 base/android/linker/modern_linker_jni.cc:316: LOG_ERROR("WARNING: library reservation was too small"); LOG_WARN ? ...
4 years, 11 months ago (2016-01-15 15:56:00 UTC) #7
simonb (inactive)
https://codereview.chromium.org/1583093007/diff/1/base/android/linker/modern_linker_jni.cc File base/android/linker/modern_linker_jni.cc (right): https://codereview.chromium.org/1583093007/diff/1/base/android/linker/modern_linker_jni.cc#newcode316 base/android/linker/modern_linker_jni.cc:316: LOG_ERROR("WARNING: library reservation was too small"); On 2016/01/15 at ...
4 years, 11 months ago (2016-01-15 16:18:18 UTC) #8
dimitry
https://codereview.chromium.org/1583093007/diff/20001/base/android/linker/modern_linker_jni.cc File base/android/linker/modern_linker_jni.cc (right): https://codereview.chromium.org/1583093007/diff/20001/base/android/linker/modern_linker_jni.cc#newcode311 base/android/linker/modern_linker_jni.cc:311: if (munmap(unmap, length) == -1) { what is going ...
4 years, 11 months ago (2016-01-15 22:18:10 UTC) #10
simonb (inactive)
On 2016/01/15 at 22:18:10, dimitry wrote: > https://codereview.chromium.org/1583093007/diff/20001/base/android/linker/modern_linker_jni.cc > File base/android/linker/modern_linker_jni.cc (right): > > https://codereview.chromium.org/1583093007/diff/20001/base/android/linker/modern_linker_jni.cc#newcode311 ...
4 years, 11 months ago (2016-01-18 11:43:30 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1583093007/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1583093007/20001
4 years, 11 months ago (2016-01-18 12:03:58 UTC) #14
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 11 months ago (2016-01-18 12:44:22 UTC) #15
commit-bot: I haz the power
4 years, 11 months ago (2016-01-18 12:45:18 UTC) #17
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/b857f7676bc16665ca86d81db877dc11094bcb7a
Cr-Commit-Position: refs/heads/master@{#370015}

Powered by Google App Engine
This is Rietveld 408576698