// SPDX-License-Identifier: GPL-2.0-only /* * This test is intended to reproduce a crash that happens when * kvm_arch_hardware_disable is called and it attempts to unregister the user * return notifiers.
*/ #include <fcntl.h> #include <pthread.h> #include <semaphore.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h>
for (j = 0; j < SLEEPING_THREAD_NUM; ++j) {
check_create_thread(&throw_away, NULL, sleeping_thread,
(void *)NULL);
check_set_affinity(throw_away, &cpu_set);
}
}
pr_debug("%s: [%d] all threads launched\n", __func__, run);
sem_post(sem); for (i = 0; i < VCPU_NUM; ++i)
check_join(threads[i], &b); /* Should not be reached */
TEST_ASSERT(false, "%s: [%d] child escaped the ninja", __func__, run);
}
void wait_for_child_setup(pid_t pid)
{ /* * Wait for the child to post to the semaphore, but wake up periodically * to check if the child exited prematurely.
*/ for (;;) { conststruct timespec wait_period = { .tv_sec = 1 }; int status;
if (!sem_timedwait(sem, &wait_period)) return;
/* Child is still running, keep waiting. */ if (pid != waitpid(pid, &status, WNOHANG)) continue;
/* * Child is no longer running, which is not expected. * * If it exited with a non-zero status, we explicitly forward * the child's status in case it exited with KSFT_SKIP.
*/ if (WIFEXITED(status)) exit(WEXITSTATUS(status)); else
TEST_ASSERT(false, "Child exited unexpectedly");
}
}
int main(int argc, char **argv)
{
uint32_t i; int s, r;
pid_t pid;
sem = sem_open("vm_sem", O_CREAT | O_EXCL, 0644, 0);
sem_unlink("vm_sem");
for (i = 0; i < FORK_NUM; ++i) {
pid = fork();
TEST_ASSERT(pid >= 0, "%s: unable to fork", __func__); if (pid == 0)
run_test(i); /* This function always exits */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.