diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-08-08 12:48:06 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-08-08 12:48:06 +0200 |
| commit | 9a791c399266a650acac45ac55a066a84aad7c64 (patch) | |
| tree | 681c84b68c945f14cc64087bd19c6d04ee2f25cb /executor/executor_bsd.h | |
| parent | ddeb9f8d8828ea4f297656445164e17a9f4c2591 (diff) | |
executor: remap cover fd's to higher values
Remap cover fd's to 24x range to prevent interference
with fd's used during fuzzing and also to make
fd number consistent with/without cover enabled.
Diffstat (limited to 'executor/executor_bsd.h')
| -rw-r--r-- | executor/executor_bsd.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h index 0bed21679..73b026379 100644 --- a/executor/executor_bsd.h +++ b/executor/executor_bsd.h @@ -58,9 +58,12 @@ static long execute_syscall(const call_t* c, long a[kMaxArgs]) static void cover_open(cover_t* cov) { - cov->fd = open("/dev/kcov", O_RDWR); - if (cov->fd == -1) + int fd = open("/dev/kcov", O_RDWR); + if (fd == -1) fail("open of /dev/kcov failed"); + if (dup2(fd, cov->fd) < 0) + fail("filed to dup2(%d, %d) cover fd", fd, cov->fd); + close(fd); if (ioctl(cov->fd, KIOSETBUFSIZE, &kCoverSize)) fail("ioctl init trace write failed"); size_t mmap_alloc_size = kCoverSize * (is_kernel_64_bit ? 8 : 4); |
