DescriptionNever 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
Messages
Total messages: 17 (7 generated)
|