Skip to content

Commit

Permalink
Add a targeted test to check that mknod() is not whitelisted
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Seaborn committed Sep 22, 2015
1 parent 61b184a commit ba4099d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def Main():
test_names = stdout.strip().split('\n')

for test_name in test_names:
RunTest(['./out/save_restore_tests', test_name], -1)
sysnum = -1
if test_name == 'test_mknod_not_whitelisted':
sysnum = __NR_mknod
RunTest(['./out/save_restore_tests', test_name], sysnum)

RunTest(['/usr/bin/python', 'tests/python_example.py'], __NR_mknod)

Expand Down
9 changes: 9 additions & 0 deletions tests/save_restore_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <unistd.h>
Expand All @@ -25,6 +26,13 @@ void do_snapshot() {
assert(errno == ENOSYS);
}

void test_mknod_not_whitelisted() {
// Test that mknod() (as an example) is not whitelisted.
int rc = mknod("", 0600, S_IFREG);
assert(rc == -1);
assert(errno == ENOENT);
}

void test_munmap_whole_mapping() {
// Test munmap() of an entire mapping.
int size = getpagesize();
Expand Down Expand Up @@ -206,6 +214,7 @@ struct TestCase {

const TestCase test_cases[] = {
#define TEST_CASE(NAME) { #NAME, NAME }
TEST_CASE(test_mknod_not_whitelisted),
TEST_CASE(test_munmap_whole_mapping),
TEST_CASE(test_munmap_splits_mapping),
TEST_CASE(test_mprotect),
Expand Down

0 comments on commit ba4099d

Please sign in to comment.