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

Issue 1189823002: Update breakpad for Android packed relocations. (Closed)

Created:
5 years, 6 months ago by simonb (inactive)
Modified:
5 years, 5 months ago
Base URL:
https://chromium.googlesource.com/external/google-breakpad/src.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Update breakpad for Android packed relocations. Shared libraries containing Android packed relocations have a load bias that differs from the start address in /proc/$$/maps. Current breakpad assumes that the load bias and mapping start address are the same. Fixed by changing the client to detect the presence of Android packed relocations in the address space of a loaded library, and adjusting the stored mapping start address of any that are packed so that it contains the linker's load bias. For this to work properly, it is important that the non-packed library is symbolized for breakpad. Either packed or non-packed libraries may be run on the device; the client detects which has been loaded by the linker. BUG=499747

Patch Set 1 #

Patch Set 2 : Improved readability, check for packing in dump_symbols #

Patch Set 3 : memcmp -> my_memcmp #

Total comments: 30

Patch Set 4 : Update for review comments #

Total comments: 2

Patch Set 5 : Update for more review comments #

Patch Set 6 : Remove assertion. #

Total comments: 20

Patch Set 7 : Update for more review comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+223 lines, -2 lines) Patch
M client/linux/microdump_writer/microdump_writer.cc View 1 chunk +1 line, -1 line 0 comments Download
M client/linux/minidump_writer/linux_dumper.h View 1 2 3 4 5 6 3 chunks +65 lines, -0 lines 0 comments Download
M client/linux/minidump_writer/linux_dumper.cc View 1 2 3 4 5 6 3 chunks +125 lines, -0 lines 0 comments Download
M client/linux/minidump_writer/minidump_writer.cc View 1 chunk +1 line, -1 line 0 comments Download
M common/linux/dump_symbols.cc View 1 2 3 2 chunks +31 lines, -0 lines 0 comments Download

Messages

Total messages: 19 (2 generated)
simonb (inactive)
Initial review, for style, viability, and general breakpaddiness. Thanks.
5 years, 6 months ago (2015-06-17 17:20:45 UTC) #2
rmcilroy
https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc#newcode466 client/linux/minidump_writer/linux_dumper.cc:466: assert(min_vaddr != max_addr); Do we want to be a ...
5 years, 6 months ago (2015-06-18 09:42:11 UTC) #3
simonb (inactive)
Thanks for comments. Updates in patch set 4. https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc#newcode466 client/linux/minidump_writer/linux_dumper.cc:466: assert(min_vaddr ...
5 years, 6 months ago (2015-06-18 10:46:39 UTC) #4
Primiano Tucci (use gerrit)
Many thanks for splitting the code into their own functions, that makes it **much** more ...
5 years, 6 months ago (2015-06-18 10:59:39 UTC) #5
rmcilroy
https://codereview.chromium.org/1189823002/diff/60001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/60001/client/linux/minidump_writer/linux_dumper.cc#newcode529 client/linux/minidump_writer/linux_dumper.cc:529: return false; As discussed offline, let's make this a ...
5 years, 6 months ago (2015-06-18 15:08:13 UTC) #6
simonb (inactive)
Thanks for review feedback. Addressed in patch set 5. https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc#newcode447 client/linux/minidump_writer/linux_dumper.cc:447: ...
5 years, 6 months ago (2015-06-18 16:24:39 UTC) #7
rmcilroy
lgtm, but please get a breakpad owner's review (thestig@?) https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc#newcode466 client/linux/minidump_writer/linux_dumper.cc:466: ...
5 years, 6 months ago (2015-06-18 17:13:36 UTC) #8
simonb (inactive)
+thestig for any further comments, thanks. [ I'm aware this change cannot be landed from ...
5 years, 6 months ago (2015-06-18 17:16:56 UTC) #10
Primiano Tucci (use gerrit)
LGTM, make sure an owner stamps this. Note: before landing make sure that: - "make ...
5 years, 6 months ago (2015-06-18 17:21:43 UTC) #11
simonb (inactive)
https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/40001/client/linux/minidump_writer/linux_dumper.cc#newcode466 client/linux/minidump_writer/linux_dumper.cc:466: assert(min_vaddr != max_addr); On 2015/06/18 17:13:36, rmcilroy wrote: > ...
5 years, 6 months ago (2015-06-18 17:33:40 UTC) #12
Lei Zhang
Mostly nits and some question regarding {over,under}flows. https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc#newcode424 client/linux/minidump_writer/linux_dumper.cc:424: // Read ...
5 years, 6 months ago (2015-06-18 21:45:38 UTC) #13
Primiano Tucci (use gerrit)
https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc#newcode478 client/linux/minidump_writer/linux_dumper.cc:478: uintptr_t dyn_addr = load_bias + dyn_vaddr; On 2015/06/18 21:45:37, ...
5 years, 6 months ago (2015-06-18 21:56:13 UTC) #14
simonb (inactive)
Thanks, comments addressed in patch set 7. https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc#newcode424 client/linux/minidump_writer/linux_dumper.cc:424: // Read ...
5 years, 6 months ago (2015-06-19 12:19:28 UTC) #15
rmcilroy
thestig@: We would like to get this in before the weekend, and since you seemed ...
5 years, 6 months ago (2015-06-19 16:02:18 UTC) #16
Lei Zhang
Just the question about underflows. Otherwise lgtm. https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc File client/linux/minidump_writer/linux_dumper.cc (right): https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_writer/linux_dumper.cc#newcode506 client/linux/minidump_writer/linux_dumper.cc:506: const uintptr_t ...
5 years, 6 months ago (2015-06-19 18:59:28 UTC) #17
rmcilroy
Just for history, this landed as r1459 (Simon could you answer Lei's question and then ...
5 years, 6 months ago (2015-06-22 15:15:26 UTC) #18
simonb (inactive)
5 years, 6 months ago (2015-06-22 16:52:42 UTC) #19
https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_...
File client/linux/minidump_writer/linux_dumper.cc (right):

https://codereview.chromium.org/1189823002/diff/100001/client/linux/minidump_...
client/linux/minidump_writer/linux_dumper.cc:506: const uintptr_t load_bias =
start_addr - min_vaddr;
On 2015/06/19 18:59:28, Lei Zhang wrote:
> On 2015/06/19 12:19:27, simonb wrote:
> > On 2015/06/18 21:45:37, Lei Zhang wrote:
> > > Is |min_vaddr| guaranteeded to be less than |start_addr| ? i.e. this won't
> > > underflow.
> > 
> > Done.
> 
> Can I get a yes/no answer on this question?

Sorry, mis-clicked Done here.

What all of this code is doing is re-calculating the value of load_bias that the
linker used internally, and in the same way as the linker.  Line 346 of:
https://android.googlesource.com/platform/bionic/+/android-m-preview/linker/l...
Or in the case of the chromium crazy linker:
https://cs.corp.google.com/#clankium/src/third_party/android_crazy_linker/src...

The linker selects a (somewhat) random address for start_addr, in Android's case
with ASLR.  min_vaddr is equal to the space saved by relocation packing, so
around 0x200000 (32-bit) to 0x600000 (64-bit).  ASLR from mmap in the linker
would have to return an address lower than this for min_vaddr to be greater than
start_addr.

If it does, the linker's load_bias is 'negative' through underflow, so our's
must be also.  load_bias is an 'effective' value, and addresses between it and
start_addr are never accessed.  When added back in inside the linker, the
symmetrical overflow gets the right values.

The probability of load_bias becoming negative is low, but perhaps non-zero.  If
it occurs, the right actions for breakpad to take are to wrap it on use, using
the the target's overflow/underflow, so 32/64 bit depending on the target's
type, to arrive at the right addresses.

Having said that, it appears that breakpad non-client code may not wrap as it
should for this case.  For example, the microdump reader casts to uint64_t
before use, so this would not wrap the adjustment in the way the target did. 
I'm not sure about other parts of breakpad at the moment.

Any ideas for the best fix for this?

Unstated here is that the load_bias and the start_addr for a library are not
necessarily the same, but breakpad assumes that they always are because they
have been up to now.  Relocation packing uncouples them by introducing a
non-zero vaddr to the first LOAD segment.  Breakpad reads start_addr from
/proc/self/maps, but maps does not expose load_bias, and that is what breakpad
really requires.

Powered by Google App Engine
This is Rietveld 408576698