1#!/bin/sh 2 3# panic: handle_workitem_remove: bad file delta 4# cpuid = 2 5# time = 1753799597 6# KDB: stack backtrace: 7# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00ffc84b70 8# vpanic() at vpanic+0x136/frame 0xfffffe00ffc84ca0 9# panic() at panic+0x43/frame 0xfffffe00ffc84d00 10# handle_workitem_remove() at handle_workitem_remove+0x68d/frame 0xfffffe00ffc84d70 11# handle_workitem_remove() at handle_workitem_remove+0x52d/frame 0xfffffe00ffc84de0 12# process_worklist_item() at process_worklist_item+0x21e/frame 0xfffffe00ffc84e70 13# softdep_process_worklist() at softdep_process_worklist+0xbd/frame 0xfffffe00ffc84eb0 14# softdep_flush() at softdep_flush+0x10f/frame 0xfffffe00ffc84ef0 15# fork_exit() at fork_exit+0x82/frame 0xfffffe00ffc84f30 16# fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00ffc84f30 17# --- trap 0, rip = 0, rsp = 0, rbp = 0 --- 18# KDB: enter: panic 19# [ thread pid 16 tid 100253 ] 20# Stopped at kdb_enter+0x33: movq $0,0x1230852(%rip) 21# db> x/s version 22# version: FreeBSD 15.0-CURRENT #0 main-n279158-f1f77adfd9bc-dirty: Tue Jul 29 15:49:28 CEST 2025 23# pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO 24 25[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 26 27. ../default.cfg 28set -u 29prog=$(basename "$0" .sh) 30cat > /tmp/$prog.c <<EOF 31// https://syzkaller.appspot.com/bug?id=0a60b828818a364deb4721d58b2ed5167b1f6296 32// autogenerated by syzkaller (https://github.com/google/syzkaller) 33 34#define _GNU_SOURCE 35 36#include <sys/types.h> 37 38#include <pwd.h> 39#include <signal.h> 40#include <stdarg.h> 41#include <stdbool.h> 42#include <stdint.h> 43#include <stdio.h> 44#include <stdlib.h> 45#include <string.h> 46#include <sys/endian.h> 47#include <sys/syscall.h> 48#include <sys/wait.h> 49#include <time.h> 50#include <unistd.h> 51 52static void kill_and_wait(int pid, int* status) 53{ 54 kill(pid, SIGKILL); 55 while (waitpid(-1, status, 0) != pid) { 56 } 57} 58 59static void sleep_ms(uint64_t ms) 60{ 61 usleep(ms * 1000); 62} 63 64static uint64_t current_time_ms(void) 65{ 66 struct timespec ts; 67 if (clock_gettime(CLOCK_MONOTONIC, &ts)) 68 exit(1); 69 return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; 70} 71 72static void execute_one(void); 73 74#define WAIT_FLAGS 0 75 76static void loop(void) 77{ 78// int iter = 0; 79 for (;; /*iter++*/) { 80 int pid = fork(); 81 if (pid < 0) 82 exit(1); 83 if (pid == 0) { 84 execute_one(); 85 exit(0); 86 } 87 int status = 0; 88 uint64_t start = current_time_ms(); 89 for (;;) { 90 sleep_ms(10); 91 if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) 92 break; 93 if (current_time_ms() - start < 5000) 94 continue; 95 kill_and_wait(pid, &status); 96 break; 97 } 98 } 99} 100 101uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; 102 103void execute_one(void) 104{ 105 intptr_t res = 0; 106 if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { 107 } 108 memcpy((void*)0x200000000180, "./file0\000", 8); 109 syscall(SYS_mkdir, /*path=*/0x200000000180ul, /*mode=*/0ul); 110 memcpy((void*)0x200000000000, "./file0/file0\000", 14); 111 syscall(SYS_mkdir, /*path=*/0x200000000000ul, /*mode=*/0ul); 112 memcpy((void*)0x200000000080, ".\000", 2); 113 res = syscall(SYS_open, /*file=*/0x200000000080ul, 114 /*flags=O_DIRECT*/ 0x10000ul, /*mode=*/0ul); 115 if (res != -1) 116 r[0] = res; 117 memcpy((void*)0x200000000080, ".\000", 2); 118 res = 119 syscall(SYS_open, /*file=*/0x200000000080ul, /*flags=*/0ul, /*mode=*/0ul); 120 if (res != -1) 121 r[1] = res; 122 memcpy((void*)0x200000000080, ".\000", 2); 123 res = syscall(SYS_open, /*file=*/0x200000000080ul, /*flags=O_NONBLOCK*/ 4ul, 124 /*mode=*/0ul); 125 if (res != -1) 126 r[2] = res; 127 memcpy((void*)0x200000000100, "./file1\000", 8); 128 syscall(SYS_mkdirat, /*fd=*/r[2], /*path=*/0x200000000100ul, 129 /*mode=S_IROTH|S_IWUSR*/ 0x84ul); 130 memcpy((void*)0x200000000340, "./file0/file0\000", 14); 131 memcpy((void*)0x200000000380, "./file1\000", 8); 132 syscall(SYS_renameat, /*oldfd=*/r[0], /*old=*/0x200000000340ul, 133 /*newfd=*/r[1], /*new=*/0x200000000380ul); 134} 135int main(void) 136{ 137 syscall(SYS_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, 138 /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, 139 /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x1012ul, 140 /*fd=*/(intptr_t)-1, /*offset=*/0ul); 141 const char* reason; 142 (void)reason; 143 loop(); 144 return 0; 145} 146EOF 147mycc -o /tmp/$prog -Wall -Wextra -O0 /tmp/$prog.c || exit 1 148 149(cd ../testcases/swap; ./swap -t 3m -i 30 -l 100 > /dev/null 2>&1) & 150sleep 5 151 152work=/tmp/$prog.dir 153rm -rf $work 154mkdir $work 155cd /tmp/$prog.dir 156for i in `jot 30`; do 157 ( 158 mkdir d$i 159 cd d$i 160 timeout 3m /tmp/$prog > /dev/null 2>&1 & 161 ) 162done 163while pgrep -q $prog; do sleep 2; done 164while pkill swap; do :; done 165wait 166 167rm -rf /tmp/$prog /tmp/$prog.c /tmp/$prog.core /tmp/$prog.?????? $work 168exit 0 169