mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Fix unwind module for Android-ARM64
PiperOrigin-RevId: 414673588 Change-Id: Ib40e4f6b53692440591a1a1e9e069f974832f733
This commit is contained in:
parent
8562306c97
commit
8e8ce0955f
|
@ -23,6 +23,13 @@
|
|||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
// Android doesn't use an enum for __ptrace_request, use int instead.
|
||||
#if defined(__ANDROID__)
|
||||
using PtraceRequest = int;
|
||||
#else
|
||||
using PtraceRequest = __ptrace_request;
|
||||
#endif
|
||||
|
||||
namespace sandbox2 {
|
||||
namespace {
|
||||
|
||||
|
@ -53,7 +60,7 @@ void EnablePtraceEmulationWithUserRegs(absl::string_view regs) {
|
|||
// issuing ptrace syscalls. Accesses to registers will be emulated, for this the
|
||||
// register values should be set via EnablePtraceEmulationWithUserRegs().
|
||||
extern "C" long int ptrace_wrapped( // NOLINT
|
||||
enum __ptrace_request request, pid_t pid, void* addr, void* data) {
|
||||
PtraceRequest request, pid_t pid, void* addr, void* data) {
|
||||
if (!g_emulate_ptrace) {
|
||||
return ptrace(request, pid, addr, data);
|
||||
}
|
||||
|
@ -75,15 +82,15 @@ extern "C" long int ptrace_wrapped( // NOLINT
|
|||
}
|
||||
return read_data;
|
||||
}
|
||||
case PTRACE_PEEKUSER:
|
||||
case PTRACE_PEEKUSER: {
|
||||
// Make sure read is in-bounds and aligned.
|
||||
if (uintptr_t offset = reinterpret_cast<uintptr_t>(addr);
|
||||
offset + kRegSize > g_registers->size() * kRegSize ||
|
||||
auto offset = reinterpret_cast<uintptr_t>(addr);
|
||||
if (offset + kRegSize > g_registers->size() * kRegSize ||
|
||||
offset % kRegSize != 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return (*g_registers)[offset / kRegSize];
|
||||
}
|
||||
return (*g_registers)[offset / kRegSize];
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "ptrace_wrapped(): operation not permitted: %d\n",
|
||||
request);
|
||||
|
|
Loading…
Reference in New Issue
Block a user