summaryrefslogtreecommitdiffstats
path: root/third_party/mach_override
diff options
context:
space:
mode:
authorianbeer@chromium.org <ianbeer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 11:53:44 +0000
committerianbeer@chromium.org <ianbeer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 11:53:44 +0000
commit10bf5bde91beaca60e19e0ecc668b9e7096bd659 (patch)
treece9f7f95242199eb218c1da672d508b14d03bacd /third_party/mach_override
parent4e3c752307b8a68f8d279aa4612662f8684f5363 (diff)
downloadchromium_src-10bf5bde91beaca60e19e0ecc668b9e7096bd659.zip
chromium_src-10bf5bde91beaca60e19e0ecc668b9e7096bd659.tar.gz
chromium_src-10bf5bde91beaca60e19e0ecc668b9e7096bd659.tar.bz2
Randomize mach_override_ptr trampoline addresses on 32-bit
BUG=265731 Review URL: https://chromiumcodereview.appspot.com/22798004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/mach_override')
-rw-r--r--third_party/mach_override/README.chromium3
-rw-r--r--third_party/mach_override/mach_override.c15
2 files changed, 15 insertions, 3 deletions
diff --git a/third_party/mach_override/README.chromium b/third_party/mach_override/README.chromium
index adb7d47..46f2010 100644
--- a/third_party/mach_override/README.chromium
+++ b/third_party/mach_override/README.chromium
@@ -19,3 +19,6 @@ implementations at run time.
Local Modifications:
Ensure no rwx pages remain after mach_override_ptr:
https://codereview.chromium.org/21208002/
+
+Randomize mach_override_ptr trampoline addresses on 32-bit:
+https://codereview.chromium.org/22798004/
diff --git a/third_party/mach_override/mach_override.c b/third_party/mach_override/mach_override.c
index ea41569..21afa28 100644
--- a/third_party/mach_override/mach_override.c
+++ b/third_party/mach_override/mach_override.c
@@ -11,6 +11,7 @@
#include <mach/mach_host.h>
#include <mach/mach_init.h>
#include <mach/vm_map.h>
+#include <mach/vm_statistics.h>
#include <sys/mman.h>
#include <CoreServices/CoreServices.h>
@@ -379,15 +380,22 @@ allocateBranchIsland(
assert( island );
assert( sizeof( BranchIsland ) <= kPageSize );
+#if defined(__i386__)
+ vm_address_t page = 0;
+ mach_error_t err = vm_allocate( mach_task_self(), &page, kPageSize, VM_FLAGS_ANYWHERE );
+ if( err == err_none ) {
+ *island = (BranchIsland*) page;
+ return err_none;
+ }
+ return err;
+#else
+
#if defined(__ppc__) || defined(__POWERPC__)
vm_address_t first = 0xfeffffff;
vm_address_t last = 0xfe000000 + kPageSize;
#elif defined(__x86_64__)
vm_address_t first = ((uint64_t)originalFunctionAddress & ~(uint64_t)(((uint64_t)1 << 31) - 1)) | ((uint64_t)1 << 31); // start in the middle of the page?
vm_address_t last = 0x0;
-#else
- vm_address_t first = 0xffc00000;
- vm_address_t last = 0xfffe0000;
#endif
vm_address_t page = first;
@@ -410,6 +418,7 @@ allocateBranchIsland(
}
return KERN_NO_SPACE;
+#endif
}
/***************************************************************************//**