Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Include page protections in the debuggerd map output.

Bug: 7941716
Change-Id: I3bf475425c628c06f7799340c8a6132aab741742
  • Loading branch information...
commit d1420be6133fc5ba71d59315936fb85239ea78b1 1 parent 38219ee
Elliott Hughes authored
30 debuggerd/tombstone.c
@@ -350,6 +350,18 @@ static void dump_backtrace_and_stack(const ptrace_context_t* context, log_t* log
350 350 }
351 351 }
352 352
  353 +static void dump_map(log_t* log, map_info_t* m, const char* what) {
  354 + if (m != NULL) {
  355 + _LOG(log, false, " %08x-%08x %c%c%c %s\n", m->start, m->end,
  356 + m->is_readable ? 'r' : '-',
  357 + m->is_writable ? 'w' : '-',
  358 + m->is_executable ? 'x' : '-',
  359 + m->name);
  360 + } else {
  361 + _LOG(log, false, " (no %s)\n", what);
  362 + }
  363 +}
  364 +
353 365 static void dump_nearby_maps(const ptrace_context_t* context, log_t* log, pid_t tid) {
354 366 siginfo_t si;
355 367 memset(&si, 0, sizeof(si));
@@ -396,21 +408,9 @@ static void dump_nearby_maps(const ptrace_context_t* context, log_t* log, pid_t
396 408 * Show "next" then "match" then "prev" so that the addresses appear in
397 409 * ascending order (like /proc/pid/maps).
398 410 */
399   - if (next != NULL) {
400   - _LOG(log, false, " %08x-%08x %s\n", next->start, next->end, next->name);
401   - } else {
402   - _LOG(log, false, " (no map below)\n");
403   - }
404   - if (map != NULL) {
405   - _LOG(log, false, " %08x-%08x %s\n", map->start, map->end, map->name);
406   - } else {
407   - _LOG(log, false, " (no map for address)\n");
408   - }
409   - if (prev != NULL) {
410   - _LOG(log, false, " %08x-%08x %s\n", prev->start, prev->end, prev->name);
411   - } else {
412   - _LOG(log, false, " (no map above)\n");
413   - }
  411 + dump_map(log, next, "map below");
  412 + dump_map(log, map, "map for address");
  413 + dump_map(log, prev, "map above");
414 414 }
415 415
416 416 static void dump_thread(const ptrace_context_t* context, log_t* log, pid_t tid, bool at_fault,
6 include/corkscrew/map_info.h
@@ -32,6 +32,7 @@ typedef struct map_info {
32 32 uintptr_t start;
33 33 uintptr_t end;
34 34 bool is_readable;
  35 + bool is_writable;
35 36 bool is_executable;
36 37 void* data; // arbitrary data associated with the map by the user, initially NULL
37 38 char name[];
@@ -46,9 +47,10 @@ void free_map_info_list(map_info_t* milist);
46 47 /* Finds the memory map that contains the specified address. */
47 48 const map_info_t* find_map_info(const map_info_t* milist, uintptr_t addr);
48 49
49   -/* Returns true if the addr is in an readable map. */
  50 +/* Returns true if the addr is in a readable map. */
50 51 bool is_readable_map(const map_info_t* milist, uintptr_t addr);
51   -
  52 +/* Returns true if the addr is in a writable map. */
  53 +bool is_writable_map(const map_info_t* milist, uintptr_t addr);
52 54 /* Returns true if the addr is in an executable map. */
53 55 bool is_executable_map(const map_info_t* milist, uintptr_t addr);
54 56
11 libcorkscrew/map_info.c
@@ -57,13 +57,15 @@ static map_info_t* parse_maps_line(const char* line)
57 57 mi->start = start;
58 58 mi->end = end;
59 59 mi->is_readable = strlen(permissions) == 4 && permissions[0] == 'r';
  60 + mi->is_writable = strlen(permissions) == 4 && permissions[1] == 'w';
60 61 mi->is_executable = strlen(permissions) == 4 && permissions[2] == 'x';
61 62 mi->data = NULL;
62 63 memcpy(mi->name, name, name_len);
63 64 mi->name[name_len] = '\0';
64 65 ALOGV("Parsed map: start=0x%08x, end=0x%08x, "
65   - "is_readable=%d, is_executable=%d, name=%s",
66   - mi->start, mi->end, mi->is_readable, mi->is_executable, mi->name);
  66 + "is_readable=%d, is_writable=%d, is_executable=%d, name=%s",
  67 + mi->start, mi->end,
  68 + mi->is_readable, mi->is_writable, mi->is_executable, mi->name);
67 69 }
68 70 return mi;
69 71 }
@@ -110,6 +112,11 @@ bool is_readable_map(const map_info_t* milist, uintptr_t addr) {
110 112 return mi && mi->is_readable;
111 113 }
112 114
  115 +bool is_writable_map(const map_info_t* milist, uintptr_t addr) {
  116 + const map_info_t* mi = find_map_info(milist, addr);
  117 + return mi && mi->is_writable;
  118 +}
  119 +
113 120 bool is_executable_map(const map_info_t* milist, uintptr_t addr) {
114 121 const map_info_t* mi = find_map_info(milist, addr);
115 122 return mi && mi->is_executable;

Git Notes

review

Code-Review+2: Elliott Hughes <enh@google.com>
Verified+1: Elliott Hughes <enh@google.com>
Code-Review+1: Brian Carlstrom <bdc@google.com>
Submitted-by: Elliott Hughes <enh@google.com>
Submitted-at: Thu, 03 Jan 2013 14:52:34 -0800
Reviewed-on: https://android-review.googlesource.com/49042
Project: platform/system/core
Branch: refs/heads/master

0 comments on commit d1420be

Please sign in to comment.
Something went wrong with that request. Please try again.