diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-11-26 16:37:46 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2016-11-26 16:41:40 +0100 |
| commit | c732a41acb817d330610e0e3ebbdcafca6fc2095 (patch) | |
| tree | 8721d2bb959076c5e3124acc7ce2bd9d9912161d /csource/common.go | |
| parent | 5d942834552931a373297d3421acd2d731bb9e86 (diff) | |
csource: don't emit syz_ syscalls is they are not used
Diffstat (limited to 'csource/common.go')
| -rw-r--r-- | csource/common.go | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/csource/common.go b/csource/common.go index 70e84ad1f..5cd07cdfe 100644 --- a/csource/common.go +++ b/csource/common.go @@ -115,6 +115,7 @@ static void install_segv_handler() __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } +#ifdef __NR_syz_open_dev static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) { if (a0 == 0xc || a0 == 0xb) { @@ -133,7 +134,9 @@ static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) return open(buf, a2, 0); } } +#endif +#ifdef __NR_syz_open_pts static uintptr_t syz_open_pts(uintptr_t a0, uintptr_t a1) { int ptyno = 0; @@ -143,7 +146,9 @@ static uintptr_t syz_open_pts(uintptr_t a0, uintptr_t a1) sprintf(buf, "/dev/pts/%d", ptyno); return open(buf, a1, 0); } +#endif +#ifdef __NR_syz_fuse_mount static uintptr_t syz_fuse_mount(uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5) { uint64_t target = a0; @@ -167,7 +172,9 @@ static uintptr_t syz_fuse_mount(uintptr_t a0, uintptr_t a1, uintptr_t a2, uintpt syscall(SYS_mount, "", target, "fuse", flags, buf); return fd; } +#endif +#ifdef __NR_syz_fuseblk_mount static uintptr_t syz_fuseblk_mount(uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7) { uint64_t target = a0; @@ -197,22 +204,33 @@ static uintptr_t syz_fuseblk_mount(uintptr_t a0, uintptr_t a1, uintptr_t a2, uin syscall(SYS_mount, blkdev, target, "fuseblk", flags, buf); return fd; } +#endif static uintptr_t execute_syscall(int nr, uintptr_t a0, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8) { switch (nr) { default: return syscall(nr, a0, a1, a2, a3, a4, a5); +#ifdef __NR_syz_test case __NR_syz_test: return 0; +#endif +#ifdef __NR_syz_open_dev case __NR_syz_open_dev: return syz_open_dev(a0, a1, a2); +#endif +#ifdef __NR_syz_open_pts case __NR_syz_open_pts: return syz_open_pts(a0, a1); +#endif +#ifdef __NR_syz_fuse_mount case __NR_syz_fuse_mount: return syz_fuse_mount(a0, a1, a2, a3, a4, a5); +#endif +#ifdef __NR_syz_fuseblk_mount case __NR_syz_fuseblk_mount: return syz_fuseblk_mount(a0, a1, a2, a3, a4, a5, a6, a7); +#endif } } @@ -405,7 +423,8 @@ retry: remove_dir(filename); continue; } - for (int i = 0;; i++) { + int i; + for (i = 0;; i++) { debug("unlink(%s)\n", filename); if (unlink(filename) == 0) break; @@ -421,7 +440,8 @@ retry: } } closedir(dp); - for (int i = 0;; i++) { + int i; + for (i = 0;; i++) { debug("rmdir(%s)\n", dir); if (rmdir(dir) == 0) break; @@ -447,6 +467,7 @@ retry: } } +#if defined(SYZ_EXECUTOR) || defined(SYZ_REPEAT) static uint64_t current_time_ms() { struct timespec ts; @@ -455,13 +476,15 @@ static uint64_t current_time_ms() fail("clock_gettime failed"); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } +#endif #if defined(SYZ_REPEAT) static void test(); void loop() { - for (int iter = 0;; iter++) { + int iter; + for (iter = 0;; iter++) { char cwdbuf[256]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) |
