aboutsummaryrefslogtreecommitdiffstats
path: root/executor/executor_test.h
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-06-10 11:06:30 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-06-11 05:18:24 +0000
commit5f02070655b3c1f2ab50a82fd5f466aaeb7af44a (patch)
tree6cd193271272ef3357a2be86af98d1edf7889b73 /executor/executor_test.h
parentb7d9eb04f4c510213e29f46db7eab4ec5c72a4ae (diff)
executor: add end-to-end coverage/signal/comparisons test
Diffstat (limited to 'executor/executor_test.h')
-rw-r--r--executor/executor_test.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/executor/executor_test.h b/executor/executor_test.h
index dd133e422..f796aed04 100644
--- a/executor/executor_test.h
+++ b/executor/executor_test.h
@@ -54,12 +54,15 @@ static void cover_enable(cover_t* cov, bool collect_comps, bool extra)
static void cover_reset(cover_t* cov)
{
- *(unsigned long*)(cov->data) = 0;
+ *(uint64*)(cov->data) = 0;
}
static void cover_collect(cover_t* cov)
{
- cov->size = *(unsigned long*)(cov->data);
+ if (is_kernel_64_bit)
+ cov->size = *(uint64*)cov->data;
+ else
+ cov->size = *(uint32*)cov->data;
}
static void cover_protect(cover_t* cov)
@@ -87,7 +90,25 @@ static void cover_unprotect(cover_t* cov)
{
}
+static bool is_kernel_data(uint64 addr)
+{
+ return addr >= 0xda1a0000 && addr <= 0xda1a1000;
+}
+
static bool use_cover_edges(uint64 pc)
{
return true;
}
+
+static long syz_inject_cover(volatile long a, volatile long b, volatile long c)
+{
+ cover_t* cov = &current_thread->cov;
+ if (cov->data == nullptr)
+ return ENOENT;
+ is_kernel_64_bit = a;
+ cov->data_offset = is_kernel_64_bit ? sizeof(uint64_t) : sizeof(uint32_t);
+ uint32 size = std::min((uint32)c, cov->mmap_alloc_size);
+ memcpy(cov->data, (void*)b, size);
+ memset(cov->data + size, 0xcd, std::min<uint64>(100, cov->mmap_alloc_size - size));
+ return 0;
+}