Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: sandbox/linux/seccomp/maps.cc

Issue 1807002: Correctly align memory allocations in the case where we need to allocate memo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <iostream> 7 #include <iostream>
8 #include <linux/unistd.h> 8 #include <linux/unistd.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <stdarg.h> 10 #include <stdarg.h>
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 unsigned long position; 214 unsigned long position;
215 if (isStackLine(ptr, buf + len)) { 215 if (isStackLine(ptr, buf + len)) {
216 // If we're adjacent to the stack, try to stay away from 216 // If we're adjacent to the stack, try to stay away from
217 // the GROWS_DOWN region. Pick the farthest away region that 217 // the GROWS_DOWN region. Pick the farthest away region that
218 // is still within the gap. 218 // is still within the gap.
219 219
220 if (static_cast<unsigned long>(addr) < kMaxDistance || // Underfl ow protection. 220 if (static_cast<unsigned long>(addr) < kMaxDistance || // Underfl ow protection.
221 static_cast<unsigned long>(addr) - kMaxDistance < gap_start) { 221 static_cast<unsigned long>(addr) - kMaxDistance < gap_start) {
222 position = gap_start; 222 position = gap_start;
223 } else { 223 } else {
224 position = addr - kMaxDistance; 224 position = (addr - kMaxDistance) & ~4095;
225 if (position < gap_start) {
226 position = gap_start;
227 }
225 } 228 }
226 } else { 229 } else {
227 // Otherwise, take the end of the region. 230 // Otherwise, take the end of the region.
228 position = gap_end - size; 231 position = gap_end - size;
229 } 232 }
230 new_addr = reinterpret_cast<char *>(sys.MMAP 233 new_addr = reinterpret_cast<char *>(sys.MMAP
231 (reinterpret_cast<void *>(position), size, prot, 234 (reinterpret_cast<void *>(position), size, prot,
232 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0)); 235 MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0));
233 if (new_addr != MAP_FAILED) { 236 if (new_addr != MAP_FAILED) {
234 goto done; 237 goto done;
(...skipping 21 matching lines...) Expand all
256 break; 259 break;
257 } 260 }
258 } 261 }
259 } while (len || long_line); 262 } while (len || long_line);
260 new_addr = NULL; 263 new_addr = NULL;
261 done: 264 done:
262 return reinterpret_cast<char*>(new_addr); 265 return reinterpret_cast<char*>(new_addr);
263 } 266 }
264 267
265 } // namespace 268 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698