Commit 82619fc4 authored by Egor Pasko's avatar Egor Pasko Committed by Commit Bot

crazylinker: Remove size check with dlopen_ext

The size is used only to reserve address space (with mmap(2)). In the
kernel mmap(2) will always silently align to the next page. Hence
lifting this check should be safe.

Recently program headers changed in Chrome DSOs on Android so the amount
of virtual address space to reserve became unaligned (when DFMs are
enabled we need to reserve more address space than what we immediately
require). It does not prevent the system android_dlopen_ext() from
working (as checked by cjgrant@ on the bug), hence this change would
likely make the crazylinker implementation of android_dlopen_ext()
closer to the reference one. Though I did not verify the alignment of
the reserved size for libmonochrome.so (potentially could still stay
aligned because, after all, it is a different library from
libchrome.so).

The amount of testing for this hotfix is inspired by perf season: NO
TESTING BEYOND CQ. Thanks for accepting this :)

Bug: 998712
Change-Id: I330bda4ac47d2cda4b70a15a5a0c26174028723e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784602Reviewed-by: default avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: default avatarChristopher Grant <cjgrant@chromium.org>
Commit-Queue: Egor Pasko <pasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693145}
parent f0ddb863
...@@ -103,3 +103,5 @@ Local Modifications: ...@@ -103,3 +103,5 @@ Local Modifications:
- Safer zip parsing code (avoid integer overflows and add range checks). - Safer zip parsing code (avoid integer overflows and add range checks).
- Add a document about testing the crazy linker in a Chromium checkout - Add a document about testing the crazy linker in a Chromium checkout
- Remove unnecessary alignment check for size of area that is about to mmap(2).
...@@ -127,11 +127,6 @@ bool InternalElfLoader::LoadAt(const LoadParams& params, Error* error) { ...@@ -127,11 +127,6 @@ bool InternalElfLoader::LoadAt(const LoadParams& params, Error* error) {
static_cast<unsigned long>(params.reserved_size)); static_cast<unsigned long>(params.reserved_size));
return false; return false;
} }
if (params.reserved_size != PAGE_START(params.reserved_size)) {
error->Format("Reserved size 0x%08lx is not page-aligned",
static_cast<unsigned long>(params.reserved_size));
return false;
}
} }
// Check that the file offset is also properly page-aligned. // Check that the file offset is also properly page-aligned.
......
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