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

Unified Diff: tests/mmap/mmap_test.cc

Issue 11141016: mprotect system call exposed to the untrusted code. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« src/untrusted/irt/irt.h ('K') | « src/untrusted/nacl/sys_private.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/mmap/mmap_test.cc
diff --git a/tests/mmap/mmap_test.cc b/tests/mmap/mmap_test.cc
index 81598a969f64fbefe2108c30f795533ea7a17b48..9ea767b192963a340173f9948a35c9d8e22f4bb8 100644
--- a/tests/mmap/mmap_test.cc
+++ b/tests/mmap/mmap_test.cc
@@ -269,21 +269,18 @@ bool test_mprotect() {
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
assert(addr != MAP_FAILED);
printf("mmap done\n");
- /*
- * Change the protection to make the page unreadable. TODO(phosek): use
- * the mprotect() wrapper function once mprotect() is added to the IRT.
- */
- int rc = NACL_SYSCALL(mprotect)(addr, map_size, PROT_NONE);
+ /* Change the protection to make the page unreadable. */
+ int rc = mprotect(addr, map_size, PROT_NONE);
Mark Seaborn 2012/10/14 00:47:16 For this to work, you'll need to add an mprotect()
Petr Hosek 2012/10/14 00:53:21 Undone.
assert(rc == 0);
assert_addr_is_unreadable(addr);
assert_addr_is_unreadable(addr + 0x1000);
assert_addr_is_unreadable(addr + 0x10000);
/* Change the protection to make the page accessible again. */
- rc = NACL_SYSCALL(mprotect)(addr, map_size, PROT_READ | PROT_WRITE);
+ rc = mprotect(addr, map_size, PROT_READ | PROT_WRITE);
assert(rc == 0);
addr[0] = '5';
/* Change the protection to make the page read-only. */
- rc = NACL_SYSCALL(mprotect)(addr, map_size, PROT_READ);
+ rc = mprotect(addr, map_size, PROT_READ);
assert(rc == 0);
assert_addr_is_unwritable(addr, '9');
assert('5' == addr[0]);
@@ -315,12 +312,9 @@ bool test_mprotect_unmapped_memory() {
int rc = munmap(addr, map_size);
assert(rc == 0);
printf("munmap done\n");
- /*
- * Change the protection to make the page unreadable. TODO(phosek): use
- * the mprotect() wrapper function once mprotect() is added to the IRT.
- */
- rc = NACL_SYSCALL(mprotect)(addr, map_size, PROT_NONE);
- if (-EACCES == rc) {
+ /* Change the protection to make the page unreadable. */
+ rc = mprotect(addr, map_size, PROT_NONE);
+ if (-1 == rc && EACCES == errno) {
printf("mprotect good (failed as expected)\n");
return true;
}
« src/untrusted/irt/irt.h ('K') | « src/untrusted/nacl/sys_private.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698