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

Issue 917463003: Avoid writing the sandbox base address to memory in setjmp and memcpy (Closed)

Created:
5 years, 10 months ago by Derek Schuff
Modified:
5 years, 9 months ago
Reviewers:
Mark Seaborn
CC:
native-client-reviews_googlegroups.com, shyamsundarr
Base URL:
https://chromium.googlesource.com/native_client/nacl-newlib.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Avoid writing the sandbox base address to memory in memcpy PNaCl x86-64 code avoids revealing the sandbox base address to untrusted code, to make vulnerabilities harder to exploit. For this to be effective, the IRT also needs to have this property. Currently the IRT is built by PNaCl and so is safe in this way, but we want to switch to nacl-clang. nacl-clang has the same defaults for codegen, but includes assembly versions of memcpy, memset, and setjmp. This CL fixes memcpy in several ways - It avoids writing the sandbox base to memory. (It also avoids the movs string instructions.) - It uses L-prefix symbol names to keep them out of the object symbol table by default. - It uses rbp as a base pointer instead of rsi/rdi to avoid extra masking. - It removes use of nontemporal store and prefetch instructions. (It also removes the fence instruction, which was there because movnti has weak ordering with respect to other stores). R=mseaborn@chromium.org BUG= https://code.google.com/p/nativeclient/issues/detail?id=4088 Committed: https://git.chromium.org/gitweb?p=native_client/nacl-newlib.git;a=commit;h=fe55b309fd67115ffe77ed59609506cbd611b210

Patch Set 1 #

Total comments: 11

Patch Set 2 : review #

Patch Set 3 : remove movs, use local labels #

Patch Set 4 : remove nontemporals and setjmp modifications #

Total comments: 11

Patch Set 5 : review #

Total comments: 10

Patch Set 6 : review #

Unified diffs Side-by-side diffs Delta from patch set Stats (+118 lines, -58 lines) Patch
M newlib/libc/machine/x86_64/memcpy.S View 1 2 3 4 5 2 chunks +116 lines, -58 lines 0 comments Download
M newlib/libc/machine/x86_64/x86_64mach.h View 1 2 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 16 (1 generated)
Derek Schuff
I thought about just using PNaCl's setjmp implementation directly, but discovered that it uses a ...
5 years, 10 months ago (2015-02-11 01:36:15 UTC) #1
Mark Seaborn
Would it be worth running the nacl-clang Scons tests with Victor's prototype validator patch applied ...
5 years, 10 months ago (2015-02-11 02:23:45 UTC) #2
Derek Schuff
https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (right): https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S#newcode117 newlib/libc/machine/x86_64/memcpy.S:117: rep movsb %nacl:(rsi), %nacl:(rdi), r15 On 2015/02/11 02:23:45, Mark ...
5 years, 10 months ago (2015-02-11 18:19:12 UTC) #3
Derek Schuff
https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (right): https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S#newcode117 newlib/libc/machine/x86_64/memcpy.S:117: rep movsb %nacl:(rsi), %nacl:(rdi), r15 On 2015/02/11 18:19:11, Derek ...
5 years, 10 months ago (2015-02-11 18:36:00 UTC) #4
Mark Seaborn
https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (right): https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S#newcode117 newlib/libc/machine/x86_64/memcpy.S:117: rep movsb %nacl:(rsi), %nacl:(rdi), r15 On 2015/02/11 18:19:11, Derek ...
5 years, 10 months ago (2015-02-11 19:21:52 UTC) #5
Derek Schuff
https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (right): https://codereview.chromium.org/917463003/diff/1/newlib/libc/machine/x86_64/memcpy.S#newcode61 newlib/libc/machine/x86_64/memcpy.S:61: movq %nacl: (r15,rsi), rax On 2015/02/11 02:23:45, Mark Seaborn ...
5 years, 10 months ago (2015-02-11 23:16:06 UTC) #6
Derek Schuff
removed movs, PTAL
5 years, 10 months ago (2015-02-12 22:44:06 UTC) #7
Derek Schuff
On 2015/02/12 22:44:06, Derek Schuff wrote: > removed movs, PTAL moved setjmp changes to another ...
5 years, 10 months ago (2015-02-13 23:26:48 UTC) #8
Mark Seaborn
Any chance of splitting this into multiple CLs? If you do multiple changes in one ...
5 years, 10 months ago (2015-02-18 20:03:38 UTC) #9
Derek Schuff
https://codereview.chromium.org/917463003/diff/60001/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (left): https://codereview.chromium.org/917463003/diff/60001/newlib/libc/machine/x86_64/memcpy.S#oldcode90 newlib/libc/machine/x86_64/memcpy.S:90: sfence On 2015/02/18 20:03:38, Mark Seaborn wrote: > Please ...
5 years, 10 months ago (2015-02-18 20:47:41 UTC) #10
Derek Schuff
https://codereview.chromium.org/917463003/diff/60001/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (right): https://codereview.chromium.org/917463003/diff/60001/newlib/libc/machine/x86_64/memcpy.S#newcode113 newlib/libc/machine/x86_64/memcpy.S:113: popq rcx On 2015/02/18 20:47:40, Derek Schuff wrote: > ...
5 years, 10 months ago (2015-02-18 20:49:25 UTC) #11
Mark Seaborn
LGTM https://codereview.chromium.org/917463003/diff/80001/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (right): https://codereview.chromium.org/917463003/diff/80001/newlib/libc/machine/x86_64/memcpy.S#newcode45 newlib/libc/machine/x86_64/memcpy.S:45: movl edx, ecx /* Copy 128 bytes at ...
5 years, 10 months ago (2015-02-20 00:43:45 UTC) #12
Derek Schuff
Committed patchset #6 (id:100001) manually as fe55b309fd67115ffe77ed59609506cbd611b210 (presubmit successful).
5 years, 10 months ago (2015-02-20 01:10:41 UTC) #14
Derek Schuff
oops, forgot to mail all the 'Done's https://codereview.chromium.org/917463003/diff/80001/newlib/libc/machine/x86_64/memcpy.S File newlib/libc/machine/x86_64/memcpy.S (right): https://codereview.chromium.org/917463003/diff/80001/newlib/libc/machine/x86_64/memcpy.S#newcode45 newlib/libc/machine/x86_64/memcpy.S:45: movl edx, ...
5 years, 10 months ago (2015-02-23 17:19:43 UTC) #15
Mark Seaborn
5 years, 9 months ago (2015-03-09 17:55:07 UTC) #16
Message was sent while issue was closed.
Now that the rowhammer blog post is published
(http://googleprojectzero.blogspot.com/2015/03/exploiting-dram-rowhammer-bug-t...),
I can add some context:

The reason for removing the non-temporal memory accesses here is just in case
they can be used for row hammering.

Powered by Google App Engine
This is Rietveld 408576698