From 13ac7b415d9c03f7861b634695af5c4887574013 Mon Sep 17 00:00:00 2001 From: "markus@chromium.org" Date: Wed, 28 Apr 2010 01:55:03 +0000 Subject: Correctly align memory allocations in the case where we need to allocate memory as far away from the stack as possible, but still as close to the VDSO as we can. BUG=none TEST=run the tests in a tight loop and notice that they no longer randomly fail Review URL: http://codereview.chromium.org/1807002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45775 0039d316-1c4b-4281-b951-d872f2087c98 --- sandbox/linux/seccomp/maps.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sandbox/linux') diff --git a/sandbox/linux/seccomp/maps.cc b/sandbox/linux/seccomp/maps.cc index d18405a..d253c63 100644 --- a/sandbox/linux/seccomp/maps.cc +++ b/sandbox/linux/seccomp/maps.cc @@ -221,7 +221,10 @@ char* Maps::allocNearAddr(char* addr_target, size_t size, int prot) const { static_cast(addr) - kMaxDistance < gap_start) { position = gap_start; } else { - position = addr - kMaxDistance; + position = (addr - kMaxDistance) & ~4095; + if (position < gap_start) { + position = gap_start; + } } } else { // Otherwise, take the end of the region. -- cgit v1.1