[plcrashreporter] 3 new revisions pushed by landon.j.fuller@gmail.com on 2013-03-27 19:40 GMT

8 views
Skip to first unread message

codesite...@google.com

unread,
Mar 27, 2013, 3:40:32 PM3/27/13
to plcrashrepo...@googlegroups.com
3 new revisions:

Revision: 831795bf5623
Author: Landon Fuller <lan...@plausible.coop>
Date: Wed Mar 27 12:03:01 2013
Log: Only enable the vm_region_recurse() code when targeting iOS.
http://code.google.com/p/plcrashreporter/source/detail?r=831795bf5623

Revision: 952cebba6205
Author: Landon Fuller <lan...@plausible.coop>
Date: Wed Mar 27 12:03:21 2013
Log: Remove debug logging
http://code.google.com/p/plcrashreporter/source/detail?r=952cebba6205

Revision: d879e7fcc56c
Author: Landon Fuller <lan...@plausible.coop>
Date: Wed Mar 27 12:39:50 2013
Log: Implement page remapping using mach_make_memory_entry_64() and
vm_map(...
http://code.google.com/p/plcrashreporter/source/detail?r=d879e7fcc56c

==============================================================================
Revision: 831795bf5623
Author: Landon Fuller <lan...@plausible.coop>
Date: Wed Mar 27 12:03:01 2013
Log: Only enable the vm_region_recurse() code when targeting iOS.

http://code.google.com/p/plcrashreporter/source/detail?r=831795bf5623

Modified:
/Source/PLCrashAsync.h

=======================================
--- /Source/PLCrashAsync.h Tue Mar 26 12:42:48 2013
+++ /Source/PLCrashAsync.h Wed Mar 27 12:03:01 2013
@@ -37,13 +37,14 @@
#include <TargetConditionals.h>
#include <mach/mach.h>

-#if 1 /* TODO: TARGET_OS_IPHONE */
+#if TARGET_OS_IPHONE

/** If defined, the target architecture has a broken vm_remap() or
mach_vm_remap() implementation that triggers
* kernel panics. */
#define PL_HAVE_BROKEN_VM_REMAP 1

-#endif
+#endif /* TARGET_OS_IPHONE */
+

#if TARGET_OS_IPHONE


==============================================================================
Revision: 952cebba6205
Author: Landon Fuller <lan...@plausible.coop>
Date: Wed Mar 27 12:03:21 2013
Log: Remove debug logging

http://code.google.com/p/plcrashreporter/source/detail?r=952cebba6205

Modified:
/Source/PLCrashAsyncMObject.c

=======================================
--- /Source/PLCrashAsyncMObject.c Tue Mar 26 12:42:48 2013
+++ /Source/PLCrashAsyncMObject.c Wed Mar 27 12:03:21 2013
@@ -68,8 +68,6 @@
natural_t nesting_depth = 0;

region_base = start_address;
-
- PLCF_DEBUG("Recursing vm region for address=0x%" PRIx64 " looking
for terminator=0x%" PRIx64, (uint64_t) region_base, (uint64_t)
(address+length));

#ifdef PL_HAVE_MACH_VM
vm_region_submap_info_data_64_t info;
@@ -94,9 +92,6 @@
(uint64_t) region_base, (uint64_t) (region_size),
kt);
return PLCRASH_EACCESS;
}
-
- PLCF_DEBUG("Found vm region for address=0x%" PRIx64" length=0x%"
PRIx64,
- (uint64_t) region_base, (uint64_t) (region_size));

start_address = region_base + region_size;
}

==============================================================================
Revision: d879e7fcc56c
Author: Landon Fuller <lan...@plausible.coop>
Date: Wed Mar 27 12:39:50 2013
Log: Implement page remapping using mach_make_memory_entry_64() and
vm_map(), which *might* work around the vm_remap() bugs we've seen.

http://code.google.com/p/plcrashreporter/source/detail?r=d879e7fcc56c

Modified:
/Source/PLCrashAsyncMObject.c
/Source/PLCrashAsyncMachOImage.c

=======================================
--- /Source/PLCrashAsyncMObject.c Wed Mar 27 12:03:21 2013
+++ /Source/PLCrashAsyncMObject.c Wed Mar 27 12:39:50 2013
@@ -40,66 +40,6 @@
* @{
*/

-#ifdef PL_HAVE_BROKEN_VM_REMAP
-
-/**
- * Verify the validity of the given @a address and @a length within the
current process. Note that this validity
- * is only gauranteed insofar as the pages in question are not unmapped,
which may occur for any reason, including
- * the case where the process' threads have not been suspended.
- *
- * @param address The target address to verify.
- * @param length The total size of the range to be verified.
- *
- * @warning This function is provided as a work-around for bugs in
vm_remap() that have been reported
- * in iOS 6. Should those bugs be isolated and fixed, this implementation
may be removed.
- */
-static plcrash_error_t plcrash_async_mobject_vm_regions_valid
(pl_vm_address_t address, pl_vm_size_t length) {
- kern_return_t kt;
-
- if (length == 0)
- return PLCRASH_ESUCCESS;
-
- pl_vm_address_t start_address = address;
-
- while (start_address < address+length) {
- mach_msg_type_number_t info_count;
- pl_vm_address_t region_base;
- pl_vm_size_t region_size;
- natural_t nesting_depth = 0;
-
- region_base = start_address;
-
-#ifdef PL_HAVE_MACH_VM
- vm_region_submap_info_data_64_t info;
- info_count = VM_REGION_SUBMAP_INFO_COUNT_64;
-
- kt = mach_vm_region_recurse(mach_task_self(), &region_base,
&region_size, &nesting_depth, (vm_region_recurse_info_t) &info,
&info_count);
-#else
- vm_region_submap_info_data_t info;
- info_count = VM_REGION_SUBMAP_INFO_COUNT;
-
- kt = vm_region_recurse(mach_task_self(), &region_base,
&region_size, &nesting_depth, (vm_region_recurse_info_t) &info,
&info_count);
-#endif
-
- if (kt != KERN_SUCCESS) {
- PLCF_DEBUG("Failed to recurse vm region for address=0x%"
PRIx64" length=0x%" PRIx64 ": %x",
- (uint64_t) region_base, (uint64_t) (region_size), kt);
- return PLCRASH_EINTERNAL;
- }
-
- if ((info.protection & VM_PROT_READ) == 0) {
- PLCF_DEBUG("Missing read permissions for address=0x%" PRIx64"
length=0x%" PRIx64 ": %x",
- (uint64_t) region_base, (uint64_t) (region_size),
kt);
- return PLCRASH_EACCESS;
- }
-
- start_address = region_base + region_size;
- }
-
- return PLCRASH_ESUCCESS;
-}
-
-#endif

/**
* Initialize a new memory object reference, mapping @a task_addr from @a
task into the current process. The mapping
@@ -116,22 +56,6 @@
* @warn Callers must call plcrash_async_mobject_free() on @a mobj, even
if plcrash_async_mobject_init() fails.
*/
plcrash_error_t plcrash_async_mobject_init (plcrash_async_mobject_t *mobj,
mach_port_t task, pl_vm_address_t task_addr, pl_vm_size_t length) {
-#ifdef PL_HAVE_BROKEN_VM_REMAP
- if (plcrash_async_mobject_vm_regions_valid(task_addr, length) !=
PLCRASH_ESUCCESS)
- return PLCRASH_ENOMEM;
-
- /* This operation mode is unsupported when running out-of-process */
- PLCF_ASSERT(task == mach_task_self());
-
- mobj->vm_address = 0x0;
- mobj->address = task_addr;
- mobj->length = length;
- mobj->vm_slide = 0;
- mobj->task_address = task_addr;
-
- return PLCRASH_ESUCCESS;
-
-#else
/* We must first initialize vm_address to 0x0. We'll check this in
_free() to determine whether calling vm_deallocate() is required */
mobj->vm_address = 0x0;

@@ -141,14 +65,45 @@
pl_vm_size_t page_size = mach_vm_round_page(length + (task_addr -
mach_vm_trunc_page(task_addr)));

/* Remap the target pages into our process */
+
+
+#ifdef PL_HAVE_BROKEN_VM_REMAP
+ /* Memory object implementation */
+ memory_object_size_t entry_length = page_size;
+ mach_port_t mem_handle;
+ kt = mach_make_memory_entry_64(task, &entry_length, task_addr,
VM_PROT_READ, &mem_handle, MACH_PORT_NULL);
+ if (kt != KERN_SUCCESS) {
+ PLCF_DEBUG("mach_make_memory_entry_64() failed: %d", kt);
+ return PLCRASH_ENOMEM;
+ }
+
+ kt = vm_map(mach_task_self(), &mobj->vm_address, page_size, 0x0,
VM_FLAGS_ANYWHERE, mem_handle, 0x0, TRUE, VM_PROT_READ, VM_PROT_READ,
VM_INHERIT_COPY);
+ if (kt != KERN_SUCCESS) {
+ PLCF_DEBUG("vm_map() failure: %d", kt);
+
+ kt = mach_port_mod_refs(mach_task_self(), mem_handle,
MACH_PORT_RIGHT_SEND, -1);
+ if (kt != KERN_SUCCESS) {
+ PLCF_DEBUG("mach_port_mod_refs(-1) failed: %d", kt);
+ }
+
+ return PLCRASH_ENOMEM;
+ }
+
+ kt = mach_port_mod_refs(mach_task_self(), mem_handle,
MACH_PORT_RIGHT_SEND, -1);
+ if (kt != KERN_SUCCESS) {
+ PLCF_DEBUG("mach_port_mod_refs(-1) failed: %d", kt);
+ }
+
+#else
+ /* vm_remap() implementation */
vm_prot_t cur_prot;
vm_prot_t max_prot;
-
+
#ifdef PL_HAVE_MACH_VM
kt = mach_vm_remap(mach_task_self(), &mobj->vm_address, page_size,
0x0, TRUE, task, task_addr, FALSE, &cur_prot, &max_prot, VM_INHERIT_COPY);
#else
kt = vm_remap(mach_task_self(), &mobj->vm_address, page_size, 0x0,
TRUE, task, task_addr, FALSE, &cur_prot, &max_prot, VM_INHERIT_COPY);
-#endif
+#endif /* !PL_HAVE_MACH_VM */

if (kt != KERN_SUCCESS) {
PLCF_DEBUG("vm_remap() failure: %d", kt);
@@ -159,6 +114,8 @@
if ((cur_prot & VM_PROT_READ) == 0) {
return PLCRASH_EACCESS;
}
+
+#endif /* PL_HAVE_BROKEN_VM_REMAP */

/* Determine the offset to the actual data */
mobj->address = mobj->vm_address + (task_addr -
mach_vm_trunc_page(task_addr));
@@ -172,7 +129,6 @@
mobj->task_address = task_addr;

return PLCRASH_ESUCCESS;
-#endif /* !PL_HAVE_BROKEN_VM_REMAP */
}


=======================================
--- /Source/PLCrashAsyncMachOImage.c Tue Jan 1 14:02:34 2013
+++ /Source/PLCrashAsyncMachOImage.c Wed Mar 27 12:39:50 2013
@@ -586,7 +586,7 @@
pl_async_macho_mapped_segment_t linkedit_seg;
plcrash_error_t err =
plcrash_async_macho_map_segment(image, "__LINKEDIT", &linkedit_seg);
if (err != PLCRASH_ESUCCESS) {
- PLCF_DEBUG("plcrash_async_mobject_init() failure: %d", err);
+ PLCF_DEBUG("plcrash_async_mobject_init() failure: %d in %s", err,
image->name);
return PLCRASH_EINTERNAL;
}

Reply all
Reply to author
Forward
0 new messages