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

Issue 661438: Seccomp sandbox changes (performance and correctness fixes, primarily targetting x86-32) (Closed)

Created:
10 years, 9 months ago by Markus (顧孟勤)
Modified:
9 years, 7 months ago
Reviewers:
Craig, agl, Evan Martin
CC:
chromium-reviews, agl
Visibility:
Public.

Description

- Add a custom allocator for STL objects. This fixes sandbox failures that were observed on some machines (in particular in 32bit mode). - Some more changes to avoid calling into glibc when we can make a direct system call, instead. These particular call sites were unlikely to cause any problems. But it makes the code easier to audit if we avoid all unnecessary calls into glibc. - In 64bit mode, gettimeofday() is handled by vsyscalls and tends to be cheap. In 32bit mode, it is just a regular system call. Some users rely on being able to call gettimeofday() at a very high rate (up to thousands of consecutive calls). Recognize this system call pattern and optimize for it. - Add debugging option that allows us to warn about expensive system calls. In many cases, these warnings can then be used to optimize the sandboxed application. - Fix compilation on newer versions of gcc. - Changed the x86-32 version of the code that we use when intercepting system calls. Previously, we would use CALL to jump to the set of instructions that we had relocated. But we made the mistake of allowing relocation of instructions that reference %esp. This doesn't work, as CALL modifies the stack. We now avoid using CALL and instead jump directly. On x86-32 that requires the use of a PUSH/RET combination as there is no 32bit wide JMP instruction. The x86-64 version of the code was already written in a way that would avoid this particular problem. (I would like to thank Craig Schlenter for his exceptional detective work in tracking down the root cause of this bug!) - For debugging purposes, injected a really small library (less than 4kB) and discovered that some of our memory map manipulations implicitly relied on mappings to be at least two pages long. Fixed the code that made this incorrect assumption. - For really small libraries, the runtime linker can choose a different more compact layout. Our computation of the ASR offset did not know how to deal with that. Fixed by explicitly looking for a ".text" segment instead of looking for a PT_DYNAMIC section. - Closed a file descriptor that we kept open longer than needed. - Removed some unused code. - Added copyright headers TEST=tested on i386 and x86-64 BUG=36133 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=40900

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 19

Patch Set 3 : '' #

Total comments: 1

Patch Set 4 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+643 lines, -218 lines) Patch
A sandbox/linux/seccomp/allocator.h View 1 2 1 chunk +88 lines, -0 lines 0 comments Download
A sandbox/linux/seccomp/allocator.cc View 1 2 1 chunk +136 lines, -0 lines 0 comments Download
M sandbox/linux/seccomp/clone.cc View 2 chunks +4 lines, -1 line 0 comments Download
M sandbox/linux/seccomp/library.h View 1 2 3 5 chunks +24 lines, -10 lines 0 comments Download
M sandbox/linux/seccomp/library.cc View 1 2 23 chunks +95 lines, -58 lines 0 comments Download
M sandbox/linux/seccomp/maps.h View 1 2 5 chunks +14 lines, -3 lines 0 comments Download
M sandbox/linux/seccomp/maps.cc View 1 2 4 chunks +11 lines, -7 lines 0 comments Download
M sandbox/linux/seccomp/sandbox.cc View 1 2 5 chunks +17 lines, -12 lines 0 comments Download
M sandbox/linux/seccomp/sandbox_impl.h View 2 chunks +4 lines, -1 line 0 comments Download
MM sandbox/linux/seccomp/securemem.h View 1 2 4 chunks +11 lines, -3 lines 0 comments Download
M sandbox/linux/seccomp/syscall.cc View 1 2 4 chunks +79 lines, -11 lines 0 comments Download
M sandbox/linux/seccomp/trusted_thread.cc View 1 2 36 chunks +158 lines, -112 lines 0 comments Download
M sandbox/sandbox.gyp View 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Markus (顧孟勤)
Yesterday night, I finally found a bug that might explain the problems that Craig has ...
10 years, 9 months ago (2010-03-03 02:01:24 UTC) #1
Craig
> Craig, can you let me know whether this fixes the problems that you were ...
10 years, 9 months ago (2010-03-03 05:36:47 UTC) #2
Craig Schlenter
On Wed, Mar 3, 2010 at 7:36 AM, <craig.schlenter@chromium.org> wrote: > The only thing I ...
10 years, 9 months ago (2010-03-03 10:52:04 UTC) #3
agl
LGTM http://codereview.chromium.org/661438/diff/1019/19 File sandbox/linux/seccomp/allocator.cc (right): http://codereview.chromium.org/661438/diff/1019/19#newcode1 sandbox/linux/seccomp/allocator.cc:1: // The allocator is very simplistic. It requests ...
10 years, 9 months ago (2010-03-03 15:31:42 UTC) #4
Markus (顧孟勤)
Thanks to Craig's excellent detective work, we now know why the code was crashing on ...
10 years, 9 months ago (2010-03-06 02:56:09 UTC) #5
Craig
Both the standalone and chromium versions of the sandbox work for me now. Yay!!! Thank ...
10 years, 9 months ago (2010-03-06 15:09:51 UTC) #6
Craig
On 2010/03/06 15:09:51, Craig wrote: > or add cflags -Wall -Wextra. whoops and -Werror too ...
10 years, 9 months ago (2010-03-06 15:11:13 UTC) #7
agl
10 years, 9 months ago (2010-03-08 14:22:58 UTC) #8
LGTM in case you were waiting for it.

Powered by Google App Engine
This is Rietveld 408576698