staticvoid hashchk_handler(int signum, siginfo_t *info, void *context)
{ if (signum != SIGILL)
hashchk_failure_msg = "wrong signal received"; elseif (info->si_code != ILL_ILLOPN)
hashchk_failure_msg = "wrong signal code received";
longjmp(hashchk_detected_buf, 0);
}
/* * Check that hashchk triggers when DEXCR[NPHIE] is enabled * and is detected as such by the kernel exception handler
*/ staticint hashchk_detected_test(void)
{ struct sigaction old; int err;
err = require_nphie(); if (err) return err;
old = push_signal_handler(SIGILL, hashchk_handler); if (setjmp(hashchk_detected_buf)) goto out;
hashchk_failure_msg = NULL;
do_bad_hashchk();
hashchk_failure_msg = "hashchk failed to trigger";
/* * Check that new programs get different keys so a malicious process * can't recreate a victim's hash values.
*/ staticint hashchk_exec_random_key_test(void)
{
pid_t pid; int err; int pipefd[2];
err = require_nphie(); if (err) return err;
FAIL_IF_MSG(pipe(pipefd), "failed to create pipe");
pid = fork(); if (pid == 0) { if (dup2(pipefd[1], STDOUT_FILENO) == -1)
_exit(errno);
/* Verify the child used the same hash_values address */
FAIL_IF_EXIT_MSG(hash_values[HASH_COUNT] != (unsignedlong)&hash_values, "bad address check");
/* If all hashes are the same it means (most likely) same key */
FAIL_IF_MSG(count_hash_values_matches() == HASH_COUNT, "shared key detected");
return 0;
}
/* * Check that forks share the same key so that existing hash values * remain valid.
*/ staticint hashchk_fork_share_key_test(void)
{
pid_t pid; int err;
err = require_nphie(); if (err) return err;
fill_hash_values();
pid = fork(); if (pid == 0) { if (count_hash_values_matches() != HASH_COUNT)
_exit(1);
_exit(0);
}
/* * Check that threads share the same key so that existing hash values * remain valid.
*/ staticint hashchk_clone_share_key_test(void)
{ void *child_stack;
pid_t pid; int err;
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.