panic: rw_enter: pf_state_lock locking against myself Stopped at db_enter+0x18: addq $0x8,%rsp TID PID UID PRFLAGS PFLAGS CPU COMMAND 330691 17810 0 0 0 1 syz-executor.0 *191858 17810 0 0 0x4000000 0 syz-executor.0 db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398 panic(ffffffff8240652b) at panic+0x15e sys/kern/subr_prf.c:218 rw_enter(ffffffff826db7e0,1) at rw_enter+0x4bd rw_enter_diag sys/kern/kern_rwlock.c:183 [inline] rw_enter(ffffffff826db7e0,1) at rw_enter+0x4bd sys/kern/kern_rwlock.c:274 pf_state_insert(ffff800000b5c400,ffff8000242d4fe8,ffff8000242d4ff0,fffffd80672bfc88) at pf_state_insert+0xa0 sys/net/pf.c:951 pfsync_state_import(ffff800000b40000,1) at pfsync_state_import+0xcbe sys/net/if_pfsync.c:699 pfioctl(4900,c1084425,ffff800000b40000,3,ffff800021288a80) at pfioctl+0x50ac sys/net/pf_ioctl.c:1729 VOP_IOCTL(fffffd806f729e20,c1084425,ffff800000b40000,3,fffffd807f7b7a80,ffff800021288a80) at VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297 vn_ioctl(fffffd806af2cc98,c1084425,ffff800000b40000,ffff800021288a80) at vn_ioctl+0xba sys/kern/vfs_vnops.c:531 sys_ioctl(ffff800021288a80,ffff8000242d5498,ffff8000242d54e0) at sys_ioctl+0x4b0 syscall(ffff8000242d5560) at syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] syscall(ffff8000242d5560) at syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 Xsyscall() at Xsyscall+0x128 end of kernel end trace frame: 0x18406dc7f50, count: 4 https://www.openbsd.org/ddb.html describes the minimum info required in bug reports. Insufficient info makes it difficult to find and fix bugs. ddb{0}> ddb{0}> set $lines = 0 ddb{0}> set $maxwidth = 0 ddb{0}> show panic rw_enter: pf_state_lock locking against myself ddb{0}> trace db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398 panic(ffffffff8240652b) at panic+0x15e sys/kern/subr_prf.c:218 rw_enter(ffffffff826db7e0,1) at rw_enter+0x4bd rw_enter_diag sys/kern/kern_rwlock.c:183 [inline] rw_enter(ffffffff826db7e0,1) at rw_enter+0x4bd sys/kern/kern_rwlock.c:274 pf_state_insert(ffff800000b5c400,ffff8000242d4fe8,ffff8000242d4ff0,fffffd80672bfc88) at pf_state_insert+0xa0 sys/net/pf.c:951 pfsync_state_import(ffff800000b40000,1) at pfsync_state_import+0xcbe sys/net/if_pfsync.c:699 pfioctl(4900,c1084425,ffff800000b40000,3,ffff800021288a80) at pfioctl+0x50ac sys/net/pf_ioctl.c:1729 VOP_IOCTL(fffffd806f729e20,c1084425,ffff800000b40000,3,fffffd807f7b7a80,ffff800021288a80) at VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297 vn_ioctl(fffffd806af2cc98,c1084425,ffff800000b40000,ffff800021288a80) at vn_ioctl+0xba sys/kern/vfs_vnops.c:531 sys_ioctl(ffff800021288a80,ffff8000242d5498,ffff8000242d54e0) at sys_ioctl+0x4b0 syscall(ffff8000242d5560) at syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] syscall(ffff8000242d5560) at syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 Xsyscall() at Xsyscall+0x128 end of kernel end trace frame: 0x18406dc7f50, count: -11 ddb{0}> show registers rdi 0 rsi 0x1 rbp 0xffff8000242d4df0 rbx 0xffff8000242d4e00 rdx 0x8b rcx 0x2 rax 0x1 r8 0xffffffff82038635 kprintf+0x145 r9 0x1 r10 0xa72080d7709f43cc r11 0xaa7d7508097d61c5 r12 0x3000000008 r13 0xffff8000242d4ea0 r14 0x100 r15 0x1 rip 0xffffffff81c04668 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff8000242d4de0 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.0) pid=191858 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=75, nice=20 forw=0xffffffffffffffff, list=0xffff8000212887e0,0xffffffff828cbd48 process=0xffff800021234cb8 user=0xffff8000242d0000, vmspace=0xfffffd80673fdb90 estcpu=36, cpticks=1, pctcpu=0.0 user=0, sys=1, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 17810 330691 45537 0 7 0 syz-executor.0 *17810 191858 45537 0 7 0x4000000 syz-executor.0 66381 385135 0 0 3 0x14200 bored sosplice 61065 297984 90466 0 2 0x2 syz-executor.1 45537 344262 90466 0 3 0x82 nanoslp syz-executor.0 90466 82544 1814 0 3 0x82 thrsleep syz-fuzzer 90466 245330 1814 0 2 0x4000482 syz-fuzzer 90466 522364 1814 0 3 0x4000082 thrsleep syz-fuzzer 90466 175875 1814 0 2 0x4000082 syz-fuzzer 90466 477579 1814 0 3 0x4000082 thrsleep syz-fuzzer 90466 438832 1814 0 3 0x4000082 thrsleep syz-fuzzer 90466 480513 1814 0 3 0x4000082 thrsleep syz-fuzzer 90466 428424 1814 0 3 0x4000082 thrsleep syz-fuzzer 1814 132075 28268 0 3 0x10008a sigsusp ksh 28268 36217 6045 0 3 0x92 select sshd 12052 437199 1 0 3 0x100083 ttyin getty 6045 480026 1 0 3 0x80 select sshd 37678 78024 96630 74 3 0x100092 bpf pflogd 96630 176083 1 0 3 0x80 netio pflogd 68829 427956 13119 73 3 0x100090 kqread syslogd 13119 140049 1 0 3 0x100082 netio syslogd 4587 22169 1 77 3 0x100090 poll dhclient 73756 439175 1 0 3 0x80 poll dhclient 1431 312100 0 0 3 0x14200 bored smr 59297 55646 0 0 3 0x14200 pgzero zerothread 59004 417055 0 0 3 0x14200 aiodoned aiodoned 63402 218290 0 0 3 0x14200 syncer update 58692 450535 0 0 3 0x14200 cleaner cleaner 80373 492751 0 0 3 0x14200 reaper reaper 32930 244962 0 0 3 0x14200 pgdaemon pagedaemon 78993 267033 0 0 3 0x14200 bored crynlk 32298 432981 0 0 3 0x14200 bored crypto 17573 356081 0 0 3 0x14200 bored viomb 64219 420810 0 0 3 0x40014200 acpi0 acpi0 75018 500514 0 0 3 0x40014200 idle1 28144 260422 0 0 3 0x14200 bored softnet 34203 302821 0 0 3 0x14200 bored systqmp 86024 46949 0 0 3 0x14200 bored systq 92886 370368 0 0 3 0x40014200 bored softclock 22858 118739 0 0 3 0x40014200 idle0 1 91727 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks Process 17810 (syz-executor.0) thread 0xffff800021288a80 (191858) exclusive rwlock pf_state_lock r = 0 (0xffffffff826db7f0) #0 witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline] #0 witness_lock+0x4b0 sys/kern/subr_witness.c:1182 #1 pfioctl+0x509f sys/net/pf_ioctl.c:1729 #2 VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297 #3 vn_ioctl+0xba sys/kern/vfs_vnops.c:531 #4 sys_ioctl+0x4b0 #5 syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] #5 syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 #6 Xsyscall+0x128 exclusive rwlock pf_lock r = 0 (0xffffffff826db7c0) #0 witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline] #0 witness_lock+0x4b0 sys/kern/subr_witness.c:1182 #1 pfioctl+0x5093 sys/net/pf_ioctl.c:1728 #2 VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297 #3 vn_ioctl+0xba sys/kern/vfs_vnops.c:531 #4 sys_ioctl+0x4b0 #5 syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] #5 syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 #6 Xsyscall+0x128 exclusive rwlock netlock r = 0 (0xffffffff82721440) #0 witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline] #0 witness_lock+0x4b0 sys/kern/subr_witness.c:1182 #1 pfioctl+0x2de3 sys/net/pf_ioctl.c:1727 #2 VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297 #3 vn_ioctl+0xba sys/kern/vfs_vnops.c:531 #4 sys_ioctl+0x4b0 #5 syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] #5 syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 #6 Xsyscall+0x128 exclusive kernel_lock &kernel_lock r = 0 (0xffffffff828cbf70) #0 witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline] #0 witness_lock+0x4b0 sys/kern/subr_witness.c:1182 #1 vn_ioctl+0x40 sys/kern/vfs_vnops.c:514 #2 sys_ioctl+0x4b0 #3 syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] #3 syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 #4 Xsyscall+0x128 Process 61065 (syz-executor.1) thread 0xffff800021289500 (297984) exclusive rrwlock inode r = 0 (0xfffffd806d981e78) #0 witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline] #0 witness_lock+0x4b0 sys/kern/subr_witness.c:1182 #1 rw_enter+0x416 sys/kern/kern_rwlock.c:310 #2 rrw_enter+0x88 sys/kern/kern_rwlock.c:461 #3 ufs_ihashins+0x45 sys/ufs/ufs/ufs_ihash.c:140 #4 ffs_vget+0x135 sys/ufs/ffs/ffs_vfsops.c:1350 #5 ffs_inode_alloc+0x1e1 sys/ufs/ffs/ffs_alloc.c:394 #6 ufs_mkdir+0xf4 sys/ufs/ufs/ufs_vnops.c:1162 #7 VOP_MKDIR+0xc6 sys/kern/vfs_vops.c:459 #8 domkdirat+0x121 sys/kern/vfs_syscalls.c:3064 #9 syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] #9 syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 #10 Xsyscall+0x128 exclusive rrwlock inode r = 0 (0xfffffd806b26c1a8) #0 witness_lock+0x4b0 stacktrace_save sys/sys/stacktrace.h:36 [inline] #0 witness_lock+0x4b0 sys/kern/subr_witness.c:1182 #1 rw_enter+0x416 sys/kern/kern_rwlock.c:310 #2 rrw_enter+0x88 sys/kern/kern_rwlock.c:461 #3 VOP_LOCK+0x4b sys/kern/vfs_vops.c:614 #4 vn_lock+0x6c sys/kern/vfs_vnops.c:575 #5 vfs_lookup+0xe6 sys/kern/vfs_lookup.c:419 #6 namei+0x5f7 sys/kern/vfs_lookup.c:249 #7 domkdirat+0x75 sys/kern/vfs_syscalls.c:3049 #8 syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] #8 syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 #9 Xsyscall+0x128 ddb{0}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim devbuf 9504 6676K 7324K 78643K 11289 0 pcb 13 8K 8K 78643K 82 0 rtable 91 2K 3K 78643K 277 0 ifaddr 43 10K 11K 78643K 67 0 counters 44 34K 34K 78643K 52 0 ioctlops 1 0K 4K 78643K 1485 0 iov 0 0K 16K 78643K 47 0 mount 1 1K 1K 78643K 1 0 vnodes 1221 77K 77K 78643K 1517 0 UFS quota 1 32K 32K 78643K 1 0 UFS mount 5 36K 36K 78643K 5 0 shm 2 1K 1K 78643K 2 0 VM map 2 1K 1K 78643K 2 0 sem 12 1K 1K 78643K 48 0 dirhash 12 2K 2K 78643K 12 0 ACPI 1697 195K 286K 78643K 12598 0 file desc 5 13K 25K 78643K 681 0 proc 61 63K 95K 78643K 563 0 subproc 32 2K 2K 78643K 51 0 NFS srvsock 1 0K 0K 78643K 1 0 NFS daemon 1 16K 16K 78643K 1 0 ip_moptions 2 0K 0K 78643K 38 0 in_multi 23 1K 2K 78643K 75 0 ether_multi 1 0K 0K 78643K 16 0 ISOFS mount 1 32K 32K 78643K 1 0 MSDOSFS mount 1 16K 16K 78643K 1 0 ttys 43 201K 201K 78643K 43 0 exec 0 0K 2K 78643K 395 0 pagedep 1 8K 8K 78643K 1 0 inodedep 1 32K 32K 78643K 1 0 newblk 1 0K 0K 78643K 1 0 VM swap 7 26K 26K 78643K 7 0 UVM amap 143 234K 234K 78643K 2263 0 UVM aobj 3 2K 2K 78643K 3 0 memdesc 1 4K 4K 78643K 1 0 crypto data 1 1K 1K 78643K 1 0 ip6_options 0 0K 0K 78643K 34 0 NDP 6 0K 0K 78643K 16 0 temp 105 3973K 4037K 78643K 3847 0 kqueue 3 4K 6K 78643K 38 0 SYN cache 2 16K 16K 78643K 2 0 ddb{0}> show all pools Name Size Requests Fail Releases Pgreq Pgrel Npage Hiwat Minpg Maxpg Idle arp 64 8 0 2 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 120 21 0 19 1 0 1 1 0 8 0 rtentry 112 56 0 19 2 0 2 2 0 8 0 unpcb 120 82 0 72 1 0 1 1 0 8 0 syncache 296 4 0 4 1 1 0 1 0 8 0 tcpqe 32 14 0 14 2 2 0 1 0 8 0 tcpcb 736 122 0 118 4 2 2 3 0 8 1 inpcb 304 289 0 281 2 0 2 2 0 8 1 nd6 48 9 0 6 1 0 1 1 0 8 0 kcovpl 48 3 0 1 1 0 1 1 0 8 0 ppxss 1128 3 0 3 1 0 1 1 0 8 1 pfstscr 40 2 0 0 1 0 1 1 0 8 0 pfosfp 40 1428 0 1005 5 0 5 5 0 8 0 pfosfpen 112 1428 0 714 21 0 21 21 0 8 0 pfstitem 24 16 0 12 1 0 1 1 0 8 0 pfstkey 112 18 0 12 1 0 1 1 0 8 0 pfstate 320 17 0 12 2 0 2 2 0 8 0 pfrule 1360 21 0 16 2 1 1 2 0 8 0 art_heap8 4096 1 0 0 1 0 1 1 0 8 0 art_heap4 256 237 0 88 12 0 12 12 0 8 2 art_table 32 238 0 88 2 0 2 2 0 8 0 art_node 16 55 0 21 1 0 1 1 0 8 0 sysvmsgpl 40 57 0 38 1 0 1 1 0 8 0 semupl 112 7 0 7 1 1 0 1 0 8 0 semapl 112 38 0 28 1 0 1 1 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino2pl 256 2260 0 857 89 1 88 89 0 8 0 ffsino 272 2260 0 857 94 0 94 94 0 8 0 nchpl 144 3275 0 1675 60 0 60 60 0 8 0 uvmvnodes 72 2517 0 0 46 0 46 46 0 8 0 vnodes 224 2517 0 0 149 0 149 149 0 8 0 namei 1024 8440 0 8439 1 0 1 1 0 8 0 percpumem 16 37 0 4 1 0 1 1 0 8 0 vcpupl 1984 14 0 0 2 0 2 2 0 8 0 vmpool 560 14 0 0 1 0 1 1 0 8 0 scxspl 216 10770 0 10770 12 11 1 8 0 8 1 plimitpl 152 16 0 8 1 0 1 1 0 8 0 sigapl 424 896 0 863 4 0 4 4 0 8 0 futexpl 56 4668 0 4668 1 0 1 1 0 8 1 knotepl 112 116 0 96 1 0 1 1 0 8 0 kqueuepl 168 245 0 241 1 0 1 1 0 8 0 pipepl 336 100 0 89 3 2 1 2 0 8 0 fdescpl 496 879 0 863 4 1 3 3 0 8 0 filepl 152 3226 0 3119 5 0 5 5 0 8 0 lockfpl 104 92 0 91 1 0 1 1 0 8 0 lockfspl 48 41 0 40 1 0 1 1 0 8 0 sessionpl 144 19 0 8 1 0 1 1 0 8 0 pgrppl 48 19 0 8 1 0 1 1 0 8 0 ucredpl 96 541 0 532 1 0 1 1 0 8 0 zombiepl 144 863 0 863 1 0 1 1 0 8 1 processpl 1080 896 0 863 3 0 3 3 0 8 0 procpl 672 1667 0 1626 4 0 4 4 0 8 0 sosppl 168 5 0 5 1 0 1 1 0 8 1 sockpl 432 392 0 372 3 0 3 3 0 8 0 mcl64k 65536 2 0 0 1 0 1 1 0 8 0 mcl4k 4096 3 0 0 1 0 1 1 0 8 0 mcl2k 2048 150 0 0 13 0 13 13 0 8 0 mtagpl 96 30 0 0 1 0 1 1 0 8 0 mbufpl 256 291 0 0 15 0 15 15 0 8 0 bufpl 280 5348 0 181 370 0 370 370 0 8 0 anonpl 24 71018 0 67037 27 1 26 26 0 186 0 amapchunkpl 152 3406 0 3260 9 3 6 8 0 158 0 amappl16 200 2366 0 2239 8 1 7 8 0 8 0 amappl15 192 324 0 322 2 1 1 1 0 8 0 amappl14 184 31 0 27 1 0 1 1 0 8 0 amappl13 176 31 0 30 1 0 1 1 0 8 0 amappl12 168 3 0 1 1 0 1 1 0 8 0 amappl11 160 383 0 365 1 0 1 1 0 8 0 amappl10 152 17 0 13 1 0 1 1 0 8 0 amappl9 144 19 0 18 1 0 1 1 0 8 0 amappl8 136 133 0 101 2 0 2 2 0 8 0 amappl7 128 257 0 249 1 0 1 1 0 8 0 amappl6 120 71 0 61 1 0 1 1 0 8 0 amappl5 112 1564 0 1545 1 0 1 1 0 8 0 amappl4 104 602 0 578 1 0 1 1 0 8 0 amappl3 96 133 0 125 1 0 1 1 0 8 0 amappl2 88 6091 0 6009 4 1 3 3 0 8 1 amappl1 80 33877 0 33399 26 14 12 21 0 8 0 amappl 88 1968 0 1894 2 0 2 2 0 92 0 dma4096 4096 1 0 1 1 1 0 1 0 8 0 dma1024 1024 1 0 0 1 0 1 1 0 8 0 dma256 256 6 0 6 1 1 0 1 0 8 0 dma128 128 253 0 253 1 1 0 1 0 8 0 dma64 64 6 0 6 1 1 0 1 0 8 0 dma32 32 7 0 7 1 1 0 1 0 8 0 dma16 16 18 0 17 1 0 1 1 0 8 0 aobjpl 64 2 0 0 1 0 1 1 0 8 0 uaddrrnd 24 893 0 863 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 893 0 863 1 0 1 1 0 8 0 vmmpekpl 168 8335 0 8306 2 0 2 2 0 8 0 vmmpepl 168 115212 0 113843 87 21 66 76 0 357 1 vmsppl 368 892 0 863 3 0 3 3 0 8 0 rwobjpl 56 26014 0 25172 24 11 13 19 0 8 0 pdppl 4096 1793 0 1740 71 16 55 55 0 8 2 pvpl 32 338069 0 331032 134 68 66 117 0 265 4 pmappl 232 892 0 863 3 1 2 2 0 8 0 extentpl 40 58 0 40 1 0 1 1 0 8 0 phpool 112 316 0 24 9 0 9 9 0 8 0 ddb{0}> machine ddbcpu 0 Invalid cpu 0 ddb{0}> trace db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398 panic(ffffffff8240652b) at panic+0x15e sys/kern/subr_prf.c:218 rw_enter(ffffffff826db7e0,1) at rw_enter+0x4bd rw_enter_diag sys/kern/kern_rwlock.c:183 [inline] rw_enter(ffffffff826db7e0,1) at rw_enter+0x4bd sys/kern/kern_rwlock.c:274 pf_state_insert(ffff800000b5c400,ffff8000242d4fe8,ffff8000242d4ff0,fffffd80672bfc88) at pf_state_insert+0xa0 sys/net/pf.c:951 pfsync_state_import(ffff800000b40000,1) at pfsync_state_import+0xcbe sys/net/if_pfsync.c:699 pfioctl(4900,c1084425,ffff800000b40000,3,ffff800021288a80) at pfioctl+0x50ac sys/net/pf_ioctl.c:1729 VOP_IOCTL(fffffd806f729e20,c1084425,ffff800000b40000,3,fffffd807f7b7a80,ffff800021288a80) at VOP_IOCTL+0x9a sys/kern/vfs_vops.c:297 vn_ioctl(fffffd806af2cc98,c1084425,ffff800000b40000,ffff800021288a80) at vn_ioctl+0xba sys/kern/vfs_vnops.c:531 sys_ioctl(ffff800021288a80,ffff8000242d5498,ffff8000242d54e0) at sys_ioctl+0x4b0 syscall(ffff8000242d5560) at syscall+0x4a1 mi_syscall sys/sys/syscall_mi.h:102 [inline] syscall(ffff8000242d5560) at syscall+0x4a1 sys/arch/amd64/amd64/trap.c:590 Xsyscall() at Xsyscall+0x128 end of kernel end trace frame: 0x18406dc7f50, count: -11 ddb{0}> machine ddbcpu 1