From d3f3ee38c6479cd014750456f0fca25a58e5dc28 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Tue, 2 Mar 2021 10:32:39 -0500 Subject: [PATCH] Add syscall_clock_gettime_heap snippet This invokes clock_gettime, but uses a timespec from the heap instead of the stack. It appears to be successful for me on x86-64 GNU/Linux. This rules out one possible cause of the error reported in #310: I was worried that an address from the range occupied by the heap might somehow be corrupted by the syscall variadic argument de-mangling, but that looks like it is not the case. --- test/snippets/syscall_clock_gettime_heap.c | 8 ++++++++ test/snippets/syscall_clock_gettime_heap.variable | 1 + 2 files changed, 9 insertions(+) create mode 100644 test/snippets/syscall_clock_gettime_heap.c create mode 100644 test/snippets/syscall_clock_gettime_heap.variable diff --git a/test/snippets/syscall_clock_gettime_heap.c b/test/snippets/syscall_clock_gettime_heap.c new file mode 100644 index 0000000..06ebb4f --- /dev/null +++ b/test/snippets/syscall_clock_gettime_heap.c @@ -0,0 +1,8 @@ +struct timespec *ts = malloc(sizeof(struct timespec)); +clockid_t ckid = CLOCK_REALTIME; +long ret = syscall(__NR_clock_gettime, ckid, ts); +if (ret == 0) + printf("[%s] syscall(__NR_gettime, CLOCK_REALTIME[%d], ts) -> {%lld, %ld}\n", where, ckid, (long long)ts->tv_sec, ts->tv_nsec); +else + printf("[%s] syscall(__NR_gettime, CLOCK_REALTIME[%d], ts) returned non-zero (%ld)\n", where, ckid, ret); + diff --git a/test/snippets/syscall_clock_gettime_heap.variable b/test/snippets/syscall_clock_gettime_heap.variable new file mode 100644 index 0000000..3f75b5f --- /dev/null +++ b/test/snippets/syscall_clock_gettime_heap.variable @@ -0,0 +1 @@ +FAKETIME 2020-02-02 02:02:02+00:00