Commit 3722bbeb authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Strip authentication signatures off of heap profiler pointers.

Some iOS devices enable pointer authentication, which uses the
higher-order bits of pointers to store a signature. This CL strips the
signature off of frame pointers before attempting to compute a module
offset.

The iOS documentation recommends using the ptrauth_strip() macro, but
for now we will simply use a static mask.

BUG=1084257

Change-Id: I760056a00cb698b3efd5370149b5b1ea77a199a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207961
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#769897}
parent ba226b50
...@@ -150,8 +150,20 @@ void CallStackProfileBuilder::OnSampleCompleted( ...@@ -150,8 +150,20 @@ void CallStackProfileBuilder::OnSampleCompleted(
} }
// Write CallStackProfile::Location protobuf message. // Write CallStackProfile::Location protobuf message.
uintptr_t instruction_pointer = frame.instruction_pointer;
#if defined(OS_IOS)
#if !TARGET_IPHONE_SIMULATOR
// Some iOS devices enable pointer authentication, which uses the
// higher-order bits of pointers to store a signature. Strip that signature
// off before computing the module_offset.
// TODO(crbug.com/1084272): Use the ptrauth_strip() macro once it is
// available.
instruction_pointer &= 0xFFFFFFFFF;
#endif // !TARGET_IPHONE_SIMULATOR
#endif // defined(OS_IOS)
ptrdiff_t module_offset = ptrdiff_t module_offset =
reinterpret_cast<const char*>(frame.instruction_pointer) - reinterpret_cast<const char*>(instruction_pointer) -
reinterpret_cast<const char*>(frame.module->GetBaseAddress()); reinterpret_cast<const char*>(frame.module->GetBaseAddress());
DCHECK_GE(module_offset, 0); DCHECK_GE(module_offset, 0);
location->set_address(static_cast<uint64_t>(module_offset)); location->set_address(static_cast<uint64_t>(module_offset));
......
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