tools/testing/selftests/arm64/pauth/pac.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/arm64/pauth/pac.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/arm64/pauth/pac.c- Extension
.c- Size
- 9003 bytes
- Lines
- 374
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sys/auxv.hsys/types.hsys/wait.hsignal.hsetjmp.hsched.hkselftest_harness.hhelper.h
Detected Declarations
function sign_specificfunction sign_allfunction n_samefunction n_same_single_setfunction exec_sign_allfunction pac_signal_handlerfunction fork
Annotated Snippet
if (ret == -1) {
perror("dup2 returned error");
exit(1);
}
dup2(new_stdout[1], STDOUT_FILENO);
if (ret == -1) {
perror("dup2 returned error");
exit(1);
}
close(new_stdin[0]);
close(new_stdin[1]);
close(new_stdout[0]);
close(new_stdout[1]);
ret = execl("exec_target", "exec_target", (char *)NULL);
if (ret == -1) {
perror("exec returned error");
exit(1);
}
}
close(new_stdin[0]);
close(new_stdout[1]);
ret = write(new_stdin[1], &val, sizeof(size_t));
if (ret == -1) {
perror("write returned error");
return -1;
}
/*
* wait for the worker to finish, so that read() reads all data
* will also context switch with worker so that this function can be used
* for context switch tests
*/
waitpid(pid, &status, 0);
if (WIFEXITED(status) == 0) {
fprintf(stderr, "worker exited unexpectedly\n");
return -1;
}
if (WEXITSTATUS(status) != 0) {
fprintf(stderr, "worker exited with error\n");
return -1;
}
ret = read(new_stdout[0], signed_vals, sizeof(struct signatures));
if (ret == -1) {
perror("read returned error");
return -1;
}
close(new_stdin[1]);
close(new_stdout[0]);
return 0;
}
sigjmp_buf jmpbuf;
void pac_signal_handler(int signum, siginfo_t *si, void *uc)
{
if (signum == SIGSEGV || signum == SIGILL)
siglongjmp(jmpbuf, 1);
}
/* check that a corrupted PAC results in SIGSEGV or SIGILL */
TEST(corrupt_pac)
{
struct sigaction sa;
ASSERT_PAUTH_ENABLED();
if (sigsetjmp(jmpbuf, 1) == 0) {
sa.sa_sigaction = pac_signal_handler;
sa.sa_flags = SA_SIGINFO | SA_RESETHAND;
sigemptyset(&sa.sa_mask);
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGILL, &sa, NULL);
pac_corruptor();
ASSERT_TRUE(0) TH_LOG("SIGSEGV/SIGILL signal did not occur");
}
}
/*
* There are no separate pac* and aut* controls so checking only the pac*
* instructions is sufficient
*/
TEST(pac_instructions_not_nop)
Annotation
- Immediate include surface: `sys/auxv.h`, `sys/types.h`, `sys/wait.h`, `signal.h`, `setjmp.h`, `sched.h`, `kselftest_harness.h`, `helper.h`.
- Detected declarations: `function sign_specific`, `function sign_all`, `function n_same`, `function n_same_single_set`, `function exec_sign_all`, `function pac_signal_handler`, `function fork`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.