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

Issue 8596009: Add test for patching a system call instruction (Closed)

Created:
9 years, 1 month ago by Mark Seaborn
Modified:
9 years, 1 month ago
Reviewers:
Markus (顧孟勤)
CC:
chromium-reviews
Visibility:
Public.

Description

Add test for patching a system call instruction This tests patching a specific, fixed instruction sequence, whereas the existing tests just test whatever is in the version of glibc on the system. Change library.cc to make the patching code easier to test: Split out a patchSystemCallsInRange() method, since the existing methods assume they are operating on a whole dynamically-loaded ELF object. Change maps_ to be per-instance so that creating Library objects with different Maps objects works. This doesn't try to cover the various corner cases in library.cc yet. BUG=http://code.google.com/p/seccompsandbox/issues/detail?id=17 TEST=test_patching_syscall Committed: http://code.google.com/p/seccompsandbox/source/detail?r=177

Patch Set 1 #

Patch Set 2 : Add comment #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+102 lines, -11 lines) Patch
M library.h View 2 chunks +3 lines, -1 line 0 comments Download
M library.cc View 5 chunks +15 lines, -10 lines 0 comments Download
M makefile View 1 chunk +2 lines, -0 lines 0 comments Download
M seccomp.gyp View 1 chunk +2 lines, -0 lines 0 comments Download
A tests/test_patching.cc View 1 chunk +51 lines, -0 lines 1 comment Download
A tests/test_patching_input.S View 1 1 chunk +26 lines, -0 lines 0 comments Download
M tests/test_runner.h View 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
Mark Seaborn
9 years, 1 month ago (2011-11-18 17:15:40 UTC) #1
Markus (顧孟勤)
lgtm http://codereview.chromium.org/8596009/diff/3001/tests/test_patching.cc File tests/test_patching.cc (right): http://codereview.chromium.org/8596009/diff/3001/tests/test_patching.cc#newcode23 tests/test_patching.cc:23: char *page_start = (char *) ((uintptr_t) start & ...
9 years, 1 month ago (2011-11-18 18:16:46 UTC) #2
Mark Seaborn
9 years, 1 month ago (2011-11-18 18:28:49 UTC) #3
On 18 November 2011 10:16, <markus@chromium.org> wrote:

> lgtm
>
>
> http://codereview.chromium.**org/8596009/diff/3001/tests/**
>
test_patching.cc<http://codereview.chromium.org/8596009/diff/3001/tests/test_patching.cc>
> File tests/test_patching.cc (right):
>
> http://codereview.chromium.**org/8596009/diff/3001/tests/**
>
test_patching.cc#newcode23<http://codereview.chromium.org/8596009/diff/3001/tests/test_patching.cc#newcode23>
> tests/test_patching.cc:23: char *page_start = (char *) ((uintptr_t)
> start & ~(getpagesize() - 1));
> You should probably round "end" up to the next page boundary. That way,
> you do the right thing if your function straddles a page boundary. And
> you also make sure that mprotect always gets a "len" parameter that is a
> multiple of the page size. I am actually surprised the kernel doesn't
> check this already.
>

I believe the kernel rounds the size up for you.  The Linux man page
specifically says "addr must be aligned to a page boundary" but does not
say the same about len.  The same goes for
http://pubs.opengroup.org/onlinepubs/7908799/xsh/mprotect.html.

I'm using "end - page_start" not "end - start" so it should do the right
thing if the function cross a page boundary.

It's the same with the args for mmap() and munmap().  I observe that ld.so
passes unaligned sizes to mmap() sometimes.

Cheers,
Mark

Powered by Google App Engine
This is Rietveld 408576698