diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2020-09-21 18:37:45 +0300 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-09-22 10:12:23 +0200 |
| commit | 3e8f6c27551f163a2fd2661e4b3cac126a5e7ef2 (patch) | |
| tree | 244bb7c316cb02764cb9074422ba32d3bb8f6d36 /executor/executor_linux.h | |
| parent | 2450c42f1be626b601353c1e039f8fcbadfaffb1 (diff) | |
executor: make exit code during fail() depend on fault injection
fail()'s are often used during the validation of kernel reactions to
queries that were issued by pseudo syscalls implementations. As fault
injection may cause the kernel not to succeed in handling these
queries (e.g. socket writes or reads may fail), this could ultimately
lead to unwanted "lost connection to test machine" crashes.
In order to avoid this and, on the other hand, to still have the
ability to signal a disastrous situation, the exit code of this
function now depends on the current context.
All fail() invocations during system call execution with enabled fault
injection lead to termination with zero exit code. In all other cases,
the exit code is kFailStatus.
This is achieved by introduction of a special thread-specific variable
`current_thread` that allows to access information about the thread in
which the current code is executing.
Also, this commit eliminates current_cover as it is no longer needed.
Diffstat (limited to 'executor/executor_linux.h')
| -rw-r--r-- | executor/executor_linux.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/executor/executor_linux.h b/executor/executor_linux.h index 26ce9ef52..f8aed1791 100644 --- a/executor/executor_linux.h +++ b/executor/executor_linux.h @@ -80,8 +80,6 @@ static void os_init(int argc, char** argv, char* data, size_t data_size) fail("mmap of right data PROT_NONE page failed"); } -static __thread cover_t* current_cover; - static intptr_t execute_syscall(const call_t* c, intptr_t a[kMaxArgs]) { if (c->call) @@ -186,7 +184,6 @@ static void cover_enable(cover_t* cov, bool collect_comps, bool extra) if (!extra) { if (ioctl(cov->fd, KCOV_ENABLE, kcov_mode)) exitf("cover enable write trace failed, mode=%d", kcov_mode); - current_cover = cov; return; } if (is_kernel_64_bit) @@ -201,9 +198,9 @@ static void cover_reset(cover_t* cov) if (!flag_coverage) return; if (cov == 0) { - if (current_cover == 0) - fail("cover_reset: current_cover == 0"); - cov = current_cover; + if (current_thread == 0) + fail("cover_reset: current_thread == 0"); + cov = ¤t_thread->cov; } *(uint64*)cov->data = 0; } |
