run("Checking for x32 by calling x32 getpid()\n");
ret = probe_syscall(0, SYS_GETPID | X32_BIT);
sh->indent++; if (ret == mypid) {
info("x32 is supported\n");
with_x32 = true;
} elseif (ret == -ENOSYS) {
info("x32 is not supported\n");
with_x32 = false;
} else {
fail("x32 getpid() returned %lld, but it should have returned either %lld or -ENOSYS\n", ret, (longlong)mypid);
with_x32 = false;
}
sh->indent--; return with_x32;
}
/* *TheMSBissupposedtobeignored,soweloopoverafew *totestthatout.
*/ for (size_t i = 0; i < ARRAY_SIZE(msbs); i++) { int msb = msbs[i];
run("Checking system calls with msb = %d (0x%x)\n",
msb, msb);
sh->indent++;
test_syscalls_common(msb); if (with_x32)
test_syscalls_with_x32(msb); else
test_syscalls_without_x32(msb);
sh->probing_syscall = false; /* Do this on entry only */
/* For these, don't even getregs */ if (pass == PTP_NOTHING || pass == PTP_DONE) return;
ptrace(PTRACE_GETREGS, testpid, NULL, ®s);
if (regs.orig_rax != regs.rbx) {
fail("orig_rax %#llx doesn't match syscall number %#llx\n",
(unsignedlonglong)regs.orig_rax,
(unsignedlonglong)regs.rbx);
}
switch (pass) { case PTP_GETREGS: /* Just read, no writeback */ return; case PTP_WRITEBACK: /* Write back the same register state verbatim */ break; case PTP_FUZZRET:
regs.rax = MODIFIED_BY_PTRACE; break; case PTP_FUZZHIGH:
regs.rax = MODIFIED_BY_PTRACE;
regs.orig_rax = regs.orig_rax | 0xffffffff00000000ULL; break; case PTP_INTNUM:
regs.rax = MODIFIED_BY_PTRACE;
regs.orig_rax = (int)regs.orig_rax; break; default:
crit("invalid ptrace_pass\n"); break;
}
ptrace(PTRACE_SETREGS, testpid, NULL, ®s);
}
staticvoid syscall_numbering_tracer(pid_t testpid)
{ int wstatus;
do {
pid_t wpid = waitpid(testpid, &wstatus, 0); if (wpid < 0 && errno != EINTR) break; if (wpid != testpid) continue; if (!WIFSTOPPED(wstatus)) break; /* Thread exited? */
if (sh->probing_syscall && WSTOPSIG(wstatus) == SIGTRAP)
mess_with_syscall(testpid, sh->ptrace_pass);
} while (sh->ptrace_pass != PTP_DONE &&
!ptrace(PTRACE_SYSCALL, testpid, NULL, NULL));
ptrace(PTRACE_DETACH, testpid, NULL, NULL);
/* Wait for the child process to terminate */ while (waitpid(testpid, &wstatus, 0) != testpid || !WIFEXITED(wstatus)) /* wait some more */;
}
/* *Harmlessfiledescriptortoworkon...
*/
nullfd = open("/dev/null", O_RDWR); if (nullfd < 0) {
crit("Unable to open /dev/null: %s\n", strerror(errno));
}
/* *Setupablockofsharedmemory...
*/
sh = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ|PROT_WRITE,
MAP_ANONYMOUS|MAP_SHARED, 0, 0); if (sh == MAP_FAILED) {
crit("Unable to allocated shared memory block: %s\n",
strerror(errno));
}
with_x32 = test_x32();
run("Running tests without ptrace...\n");
test_syscall_numbering();
test_traced_syscall_numbering();
nerr = sh->nerr; if (!nerr) {
ok("All system calls succeeded or failed as expected\n"); return0;
} else {
fail("A total of %u system call%s had incorrect behavior\n",
nerr, nerr != 1 ? "s" : ""); return1;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.3 Sekunden
(vorverarbeitet am 2026-10-12)
¤
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.