witness: lock order reversal: 1st 0xfffffd8068d672c8 inode (&ip->i_lock) 2nd 0xfffffd807d14a808 fdlock (&newfdp->fd_fd.fd_lock) lock order "&newfdp->fd_fd.fd_lock"(rwlock) -> "&ip->i_lock"(rrwlock) first seen at: #0 witness_checkorder+0x6a7 sys/kern/subr_witness.c:879 #1 rw_enter+0xd1 sys/kern/kern_rwlock.c:247 #2 rrw_enter+0x4f sys/kern/kern_rwlock.c:435 #3 VOP_LOCK+0x4b sys/kern/vfs_vops.c:602 #4 vn_closefile+0x119 vn_lock sys/kern/vfs_vnops.c:561 [inline] #4 vn_closefile+0x119 vn_close sys/kern/vfs_vnops.c:288 [inline] #4 vn_closefile+0x119 sys/kern/vfs_vnops.c:587 #5 fdrop+0xc9 sys/kern/kern_descrip.c:1273 #6 closef+0x11d sys/kern/kern_descrip.c:1257 #7 finishdup+0x2b6 sys/kern/kern_descrip.c:686 #8 dodup3+0x5c5 sys/kern/kern_descrip.c:377 #9 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] #9 syscall+0x552 sys/arch/amd64/amd64/trap.c:555 #10 Xsyscall+0x128 lock order "&ip->i_lock"(rrwlock) -> "&newfdp->fd_fd.fd_lock"(rwlock) first seen at: #0 witness_checkorder+0x6a7 sys/kern/subr_witness.c:879 #1 rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 #2 diskmapioctl+0x237 sys/dev/diskmap.c:106 #3 VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 #4 vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 #5 sys_ioctl+0x5b8 #6 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] #6 syscall+0x552 sys/arch/amd64/amd64/trap.c:555 #7 Xsyscall+0x128 Stopped at db_enter+0x18: addq $0x8,%rsp ddb{1}> ddb{1}> set $lines = 0 ddb{1}> set $maxwidth = 0 ddb{1}> show panic the kernel did not panic ddb{1}> trace db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398 witness_checkorder(fffffd807d14a808,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807d14a808,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807d14a7f8) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800023d959c0,1,ffff800020a5e9e8) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa80648,c0106477,ffff800023d959c0,1,fffffd807f7c67e0,ffff800020a5e9e8) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd80667bb428,c0106477,ffff800023d959c0,ffff800020a5e9e8) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020a5e9e8,ffff800023d95ad8,ffff800023d95b40) at sys_ioctl+0x5b8 syscall(ffff800023d95bb0) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800023d95bb0) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,9b196be71b0) at Xsyscall+0x128 end of kernel end trace frame: 0x9b3aac3fc80, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800023d95580 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800024180000 rax 0xffff800000b22f00 r8 0xffffffff8157a035 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xa118c207156bbbfb r12 0xfffffd80029bac00 r13 0 r14 0xffffffff825b6d10 w_lodata+0x4a350 r15 0xffffffff825c0be0 w_lodata+0x54220 rip 0xffffffff810d7398 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800023d95570 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.1) pid=371217 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=75, nice=20 forw=0xffffffffffffffff, list=0xffff800020a893d8,0xffff800020a88790 process=0xffff800020adca80 user=0xffff800023d90000, vmspace=0xfffffd807f00b170 estcpu=25, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 3152 30888 98110 0 7 0 syz-executor.1 3152 283925 98110 0 2 0x4000000 syz-executor.1 3152 44625 98110 0 2 0x4000000 syz-executor.1 * 3152 371217 98110 0 7 0x4000000 syz-executor.1 3152 243637 98110 0 2 0x4000000 syz-executor.1 98110 512069 99408 0 3 0x82 nanosleep syz-executor.1 45014 399671 0 0 3 0x14200 bored sosplice 47489 420402 99408 0 3 0x82 piperd syz-executor.0 99408 95080 74657 0 3 0x82 thrsleep syz-fuzzer 99408 509878 74657 0 3 0x4000082 thrsleep syz-fuzzer 99408 506722 74657 0 3 0x4000082 thrsleep syz-fuzzer 99408 152088 74657 0 3 0x4000082 thrsleep syz-fuzzer 99408 313069 74657 0 3 0x4000082 thrsleep syz-fuzzer 99408 194288 74657 0 3 0x4000082 thrsleep syz-fuzzer 99408 292487 74657 0 3 0x4000082 kqread syz-fuzzer 99408 209436 74657 0 3 0x4000082 thrsleep syz-fuzzer 99408 288769 74657 0 3 0x4000082 thrsleep syz-fuzzer 99408 285228 74657 0 3 0x4000082 thrsleep syz-fuzzer 74657 454179 51200 0 3 0x10008a pause ksh 51200 284809 76136 0 3 0x92 select sshd 46549 44544 1 0 3 0x100083 ttyin getty 76136 199164 1 0 3 0x80 select sshd 441 157067 24842 74 3 0x100092 bpf pflogd 24842 357796 1 0 3 0x80 netio pflogd 88261 85768 93297 73 3 0x100090 kqread syslogd 93297 291117 1 0 3 0x100082 netio syslogd 84031 168269 1 77 3 0x100090 poll dhclient 35357 486021 1 0 3 0x80 poll dhclient 35594 205919 0 0 3 0x14200 pgzero zerothread 10042 252569 0 0 3 0x14200 aiodoned aiodoned 63312 111511 0 0 3 0x14200 syncer update 61404 404293 0 0 3 0x14200 cleaner cleaner 96599 460725 0 0 3 0x14200 reaper reaper 93308 343111 0 0 3 0x14200 pgdaemon pagedaemon 61397 163125 0 0 3 0x14200 bored crynlk 43945 183190 0 0 3 0x14200 bored crypto 8371 405776 0 0 3 0x40014200 acpi0 acpi0 61742 520514 0 0 3 0x40014200 idle1 48889 134622 0 0 3 0x14200 bored softnet 96760 119722 0 0 3 0x14200 bored systqmp 32927 283143 0 0 3 0x14200 bored systq 82029 100469 0 0 3 0x40014200 bored softclock 78021 35180 0 0 3 0x40014200 idle0 18537 368150 0 0 3 0x14200 bored smr 1 241635 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 3152 (syz-executor.1) thread 0xffff800020a5e9e8 (371217) exclusive rrwlock inode r = 0 (0xfffffd8068d672c8) #0 witness_lock+0x52e sys/kern/subr_witness.c:1163 #1 rw_enter+0x46d sys/kern/kern_rwlock.c:306 #2 rrw_enter+0x4f sys/kern/kern_rwlock.c:435 #3 VOP_LOCK+0x4b sys/kern/vfs_vops.c:602 #4 vn_lock+0x6e sys/kern/vfs_vnops.c:561 #5 spec_open+0x431 sys/kern/spec_vnops.c:159 #6 VOP_OPEN+0x6a sys/kern/vfs_vops.c:153 #7 vn_open+0x495 sys/kern/vfs_vnops.c:174 #8 diskmapioctl+0x18e sys/dev/diskmap.c:91 #9 VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 #10 vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 #11 sys_ioctl+0x5b8 #12 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] #12 syscall+0x552 sys/arch/amd64/amd64/trap.c:555 #13 Xsyscall+0x128 exclusive kernel_lock &kernel_lock r = 0 (0xffffffff8262ca18) #0 witness_lock+0x52e sys/kern/subr_witness.c:1163 #1 __mp_acquire_count+0x51 sys/kern/kern_lock.c:227 #2 mi_switch+0x38f sys/kern/sched_bsd.c:441 #3 sleep_finish+0x113 sys/kern/kern_synch.c:373 #4 rw_enter+0x366 sys/kern/kern_rwlock.c:282 #5 rrw_enter+0x4f sys/kern/kern_rwlock.c:435 #6 VOP_LOCK+0x4b sys/kern/vfs_vops.c:602 #7 vn_lock+0x6e sys/kern/vfs_vnops.c:561 #8 spec_open+0x431 sys/kern/spec_vnops.c:159 #9 VOP_OPEN+0x6a sys/kern/vfs_vops.c:153 #10 vn_open+0x495 sys/kern/vfs_vnops.c:174 #11 diskmapioctl+0x18e sys/dev/diskmap.c:91 #12 VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 #13 vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 #14 sys_ioctl+0x5b8 #15 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] #15 syscall+0x552 sys/arch/amd64/amd64/trap.c:555 #16 Xsyscall+0x128 ddb{1}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9498 6409K 6908K 78643K 11382 0 0 pcb 13 8K 8K 78643K 59 0 0 rtable 113 4K 4K 78643K 334 0 0 ifaddr 49 12K 12K 78643K 92 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1481 0 0 iov 0 0K 16K 78643K 36 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1215 76K 77K 78643K 1510 0 0 UFS quota 1 32K 32K 78643K 1 0 0 UFS mount 5 36K 36K 78643K 5 0 0 shm 2 1K 5K 78643K 6 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 0K 78643K 33 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 343 0 0 sigio 0 0K 0K 78643K 2 0 0 proc 53 50K 83K 78643K 475 0 0 subproc 32 2K 2K 78643K 51 0 0 NFS srvsock 1 0K 0K 78643K 1 0 0 NFS daemon 1 16K 16K 78643K 1 0 0 ip_moptions 0 0K 0K 78643K 22 0 0 in_multi 33 2K 2K 78643K 53 0 0 ether_multi 1 0K 0K 78643K 3 0 0 mrt 0 0K 0K 78643K 1 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 66 291K 291K 78643K 66 0 0 exec 0 0K 1K 78643K 250 0 0 pagedep 1 8K 8K 78643K 1 0 0 inodedep 1 32K 32K 78643K 1 0 0 newblk 1 0K 0K 78643K 1 0 0 VM swap 7 26K 26K 78643K 7 0 0 UVM amap 98 21K 22K 78643K 2014 0 0 UVM aobj 14 2K 2K 78643K 14 0 0 memdesc 1 4K 4K 78643K 1 0 0 crypto data 1 1K 1K 78643K 1 0 0 ip6_options 0 0K 0K 78643K 28 0 0 NDP 9 0K 0K 78643K 26 0 0 temp 134 3547K 3611K 78643K 4422 0 0 kqueue 0 0K 0K 78643K 2 0 0 SYN cache 2 16K 16K 78643K 2 0 0 ddb{1}> show all pools Name Size Requests Fail Releases Pgreq Pgrel Npage Hiwat Minpg Maxpg Idle arp 64 9 0 2 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 39 0 37 1 0 1 1 0 8 0 rtentry 112 57 0 12 2 0 2 2 0 8 0 unpcb 120 91 0 81 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 10610 0 10610 3 3 0 2 0 8 0 tcpcb 544 72 0 68 1 0 1 1 0 8 0 inpcb 280 207 0 199 3 2 1 2 0 8 0 nd6 48 9 0 3 1 0 1 1 0 8 0 ppxss 1128 4 0 4 1 1 0 1 0 8 0 pffrag 232 1 0 1 1 0 1 1 0 482 1 pffrnode 88 1 0 1 1 0 1 1 0 8 1 pffrent 40 3 0 3 1 0 1 1 0 8 1 pfosfp 40 846 0 423 5 0 5 5 0 8 0 pfosfpen 112 1428 0 714 21 0 21 21 0 8 0 pfstitem 24 25 0 2 1 0 1 1 0 8 0 pfstkey 112 25 0 2 1 0 1 1 0 8 0 pfstate 328 25 0 2 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 233 0 44 12 0 12 12 0 8 0 art_table 32 234 0 44 2 0 2 2 0 8 0 art_node 16 56 0 15 1 0 1 1 0 8 0 sysvmsgpl 40 6 0 2 1 0 1 1 0 8 0 semapl 112 29 0 19 1 0 1 1 0 8 0 shmpl 112 12 0 0 1 0 1 1 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 1937 0 516 47 0 47 47 0 8 0 ffsino 272 1937 0 516 96 0 96 96 0 8 0 nchpl 144 2613 0 980 62 0 62 62 0 8 0 uvmvnodes 72 2182 0 0 40 0 40 40 0 8 0 vnodes 200 2182 0 0 115 0 115 115 0 8 0 namei 1024 7651 0 7651 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 1 0 1 1 1 0 1 0 8 0 scxspl 192 6919 0 6919 10 9 1 7 0 8 1 plimitpl 152 59 0 51 1 0 1 1 0 8 0 sigapl 432 540 0 525 3 1 2 3 0 8 0 futexpl 56 4263 0 4263 1 0 1 1 0 8 1 knotepl 112 99 0 80 1 0 1 1 0 8 0 kqueuepl 104 51 0 49 1 0 1 1 0 8 0 pipepl 112 306 0 287 1 0 1 1 0 8 0 fdescpl 488 541 0 525 3 0 3 3 0 8 0 filepl 152 2891 0 2785 6 1 5 5 0 8 0 lockfpl 104 75 0 75 2 1 1 1 0 8 1 lockfspl 48 30 0 30 2 1 1 1 0 8 1 sessionpl 112 19 0 8 1 0 1 1 0 8 0 pgrppl 48 22 0 11 1 0 1 1 0 8 0 ucredpl 96 417 0 408 1 0 1 1 0 8 0 zombiepl 144 525 0 525 2 1 1 1 0 8 1 processpl 896 557 0 525 4 0 4 4 0 8 0 procpl 632 1202 0 1157 5 0 5 5 0 8 1 srpgc 64 2 0 2 1 1 0 1 0 8 0 sosppl 128 2 0 2 1 1 0 1 0 8 0 sockpl 384 345 0 326 4 1 3 3 0 8 1 mcl64k 65536 4 0 0 1 0 1 1 0 8 0 mcl16k 16384 1 0 0 1 0 1 1 0 8 0 mcl12k 12288 7 0 0 1 0 1 1 0 8 0 mcl9k 9216 2 0 0 1 0 1 1 0 8 0 mcl8k 8192 3 0 0 1 0 1 1 0 8 0 mcl4k 4096 7 0 0 1 0 1 1 0 8 0 mcl2k 2048 239 0 0 29 0 29 29 0 8 0 mtagpl 80 10 0 0 1 0 1 1 0 8 0 mbufpl 256 265 0 0 17 0 17 17 0 8 0 bufpl 256 6270 0 1167 319 0 319 319 0 8 0 anonpl 16 58849 0 46883 56 7 49 54 0 124 0 amapchunkpl 152 2894 0 2786 12 7 5 10 0 158 0 amappl16 192 2069 0 1412 34 0 34 34 0 8 0 amappl15 184 1 0 1 1 1 0 1 0 8 0 amappl14 176 57 0 52 1 0 1 1 0 8 0 amappl13 168 16 0 14 1 0 1 1 0 8 0 amappl12 160 21 0 18 1 0 1 1 0 8 0 amappl11 152 144 0 129 1 0 1 1 0 8 0 amappl10 144 228 0 222 1 0 1 1 0 8 0 amappl9 136 682 0 677 1 0 1 1 0 8 0 amappl8 128 223 0 206 1 0 1 1 0 8 0 amappl7 120 187 0 180 1 0 1 1 0 8 0 amappl6 112 144 0 135 1 0 1 1 0 8 0 amappl5 104 142 0 128 1 0 1 1 0 8 0 amappl4 96 798 0 768 2 1 1 2 0 8 0 amappl3 88 196 0 186 1 0 1 1 0 8 0 amappl2 80 3352 0 3279 3 1 2 3 0 8 0 amappl1 72 21477 0 21039 25 15 10 19 0 8 0 amappl 80 1471 0 1432 1 0 1 1 0 84 0 dma4096 4096 1 0 1 1 1 0 1 0 8 0 dma256 256 6 0 6 1 1 0 1 0 8 0 dma64 64 259 0 259 1 1 0 1 0 8 0 dma32 32 7 0 7 1 1 0 1 0 8 0 dma16 16 17 0 17 1 1 0 1 0 8 0 aobjpl 64 13 0 0 1 0 1 1 0 8 0 uaddrrnd 24 541 0 525 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 541 0 525 1 0 1 1 0 8 0 vmmpekpl 168 7991 0 7956 2 0 2 2 0 8 0 vmmpepl 168 72271 0 70485 133 39 94 99 0 357 12 vmsppl 368 540 0 525 2 0 2 2 0 8 0 pdppl 4096 1089 0 1050 7 1 6 6 0 8 0 pvpl 32 193547 0 178392 156 31 125 137 0 265 2 pmappl 232 540 0 525 2 1 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 497 0 5 15 0 15 15 0 8 0