witness: lock order reversal: 1st 0xfffffd806e0b8e78 inode (&ip->i_lock) 2nd 0xfffffd807e060620 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(fffffd807e060620,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807e060620,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807e060610) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff80002258b8e0,1,ffff800020abe508) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa747d8,c0106477,ffff80002258b8e0,1,fffffd807f7c66c0,ffff800020abe508) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd80669fc150,c0106477,ffff80002258b8e0,ffff800020abe508) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020abe508,ffff80002258b9f8,ffff80002258ba60) at sys_ioctl+0x5b8 syscall(ffff80002258bad0) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff80002258bad0) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,fa3ff6931b0) at Xsyscall+0x128 end of kernel end trace frame: 0xfa625e49270, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff80002258b4a0 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800022f88000 rax 0xffff800000a45580 r8 0xffffffff81ca8c05 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xe7c685b2ac55c5dc r12 0xfffffd80029b9c00 r13 0 r14 0xffffffff8260cf40 w_lodata+0x47800 r15 0xffffffff82619a10 w_lodata+0x542d0 rip 0xffffffff81f62b28 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff80002258b490 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.1) pid=120212 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=79, nice=20 forw=0xffffffffffffffff, list=0xffff800020abec70,0xffff800020abe028 process=0xffff800020adc700 user=0xffff800022586000, vmspace=0xfffffd807f00c000 estcpu=29, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 61786 261196 96282 0 7 0 syz-executor.1 61786 502022 96282 0 2 0x4000000 syz-executor.1 61786 394217 96282 0 2 0x4000000 syz-executor.1 *61786 120212 96282 0 7 0x4000000 syz-executor.1 61786 235987 96282 0 2 0x4000000 syz-executor.1 96282 420867 47314 0 3 0x82 nanosleep syz-executor.1 25513 424864 47314 0 3 0x82 piperd syz-executor.0 68119 327265 1 0 3 0x100083 ttyin getty 84621 311770 0 0 3 0x14200 bored sosplice 47314 436507 74771 0 3 0x82 thrsleep syz-fuzzer 47314 204695 74771 0 3 0x4000082 thrsleep syz-fuzzer 47314 362437 74771 0 3 0x4000082 thrsleep syz-fuzzer 47314 322799 74771 0 3 0x4000082 thrsleep syz-fuzzer 47314 128363 74771 0 3 0x4000082 kqread syz-fuzzer 47314 291391 74771 0 3 0x4000082 thrsleep syz-fuzzer 47314 164180 74771 0 3 0x4000082 thrsleep syz-fuzzer 47314 109864 74771 0 3 0x4000082 thrsleep syz-fuzzer 47314 137119 74771 0 3 0x4000082 thrsleep syz-fuzzer 47314 147111 74771 0 3 0x4000082 thrsleep syz-fuzzer 74771 161394 46931 0 3 0x10008a pause ksh 46931 60825 78243 0 3 0x92 select sshd 78243 94058 1 0 3 0x80 select sshd 43545 123269 80140 74 3 0x100092 bpf pflogd 80140 7106 1 0 3 0x80 netio pflogd 2717 511470 20849 73 3 0x100090 kqread syslogd 20849 138039 1 0 3 0x100082 netio syslogd 6898 243231 1 77 3 0x100090 poll dhclient 7279 170198 1 0 3 0x80 poll dhclient 67886 115034 0 0 3 0x14200 pgzero zerothread 96835 503103 0 0 3 0x14200 aiodoned aiodoned 79455 506585 0 0 3 0x14200 syncer update 60249 336920 0 0 3 0x14200 cleaner cleaner 48947 505851 0 0 3 0x14200 reaper reaper 11535 160083 0 0 3 0x14200 pgdaemon pagedaemon 16825 36996 0 0 3 0x14200 bored crynlk 45495 522 0 0 3 0x14200 bored crypto 32031 227320 0 0 3 0x40014200 acpi0 acpi0 66785 3519 0 0 3 0x40014200 idle1 1398 142525 0 0 3 0x14200 bored softnet 97693 86963 0 0 3 0x14200 bored systqmp 64222 290243 0 0 3 0x14200 bored systq 98753 421240 0 0 3 0x40014200 bored softclock 57046 23904 0 0 3 0x40014200 idle0 13530 206754 0 0 3 0x14200 bored smr 1 12488 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 61786 (syz-executor.1) thread 0xffff800020abe508 (120212) exclusive rrwlock inode r = 0 (0xfffffd806e0b8e78) #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 (0xffffffff8266bbe8) #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 9558 6432K 7073K 78643K 13874 0 0 pcb 13 8K 8K 78643K 115 0 0 rtable 108 4K 4K 78643K 693 0 0 ifaddr 72 15K 16K 78643K 199 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1521 0 0 iov 0 0K 32K 78643K 119 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1211 76K 77K 78643K 2480 0 0 UFS quota 1 32K 32K 78643K 1 0 0 UFS mount 5 36K 36K 78643K 5 0 0 shm 2 1K 9K 78643K 23 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 1K 78643K 180 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 1350 0 0 sigio 0 0K 0K 78643K 15 0 0 proc 53 50K 83K 78643K 814 0 0 subproc 32 2K 2K 78643K 153 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 79 0 0 in_multi 33 2K 2K 78643K 142 0 0 ether_multi 1 0K 0K 78643K 7 0 0 mrt 0 0K 0K 78643K 7 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 72 318K 318K 78643K 72 0 0 exec 0 0K 1K 78643K 442 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 104 21K 30K 78643K 5238 0 0 UVM aobj 65 4K 4K 78643K 67 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 107 0 0 NDP 16 0K 0K 78643K 63 0 0 temp 200 3556K 3639K 78643K 34573 0 0 kqueue 0 0K 0K 78643K 17 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 20 0 14 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 70 0 68 1 0 1 1 0 8 0 rtentry 112 124 0 80 2 0 2 2 0 8 0 unpcb 120 423 0 413 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 10821 0 10821 4 4 0 2 0 8 0 tcpcb 544 222 0 218 1 0 1 1 0 8 0 inpcb 280 671 0 664 2 1 1 2 0 8 0 rttmr 72 2 0 2 1 0 1 1 0 8 1 nd6 48 27 0 21 1 0 1 1 0 8 0 pkpcb 40 7 0 7 4 4 0 1 0 8 0 swfcl 56 3 0 0 1 0 1 1 0 8 0 ppxss 1128 17 0 17 6 5 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 41 0 20 1 0 1 1 0 8 0 pfstkey 112 41 0 20 1 0 1 1 0 8 0 pfstate 328 41 0 20 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 502 0 311 13 0 13 13 0 8 0 art_table 32 503 0 311 2 0 2 2 0 8 0 art_node 16 123 0 83 1 0 1 1 0 8 0 sysvmsgpl 40 17 0 11 1 0 1 1 0 8 0 semapl 112 178 0 168 1 0 1 1 0 8 0 shmpl 112 65 0 2 2 0 2 2 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 3466 0 2039 47 0 47 47 0 8 0 ffsino 272 3466 0 2039 96 0 96 96 0 8 0 nchpl 144 5470 0 3841 62 1 61 62 0 8 0 uvmvnodes 72 4393 0 0 80 0 80 80 0 8 0 vnodes 200 4393 0 0 232 0 232 232 0 8 0 namei 1024 17679 0 17679 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 3 0 3 2 2 0 1 0 8 0 scxspl 192 15308 0 15308 17 16 1 7 0 8 1 plimitpl 152 135 0 127 1 0 1 1 0 8 0 sigapl 432 1531 0 1516 3 1 2 3 0 8 0 futexpl 56 16526 0 16526 1 0 1 1 0 8 1 knotepl 112 401 0 382 1 0 1 1 0 8 0 kqueuepl 104 250 0 248 1 0 1 1 0 8 0 pipepl 112 776 0 757 1 0 1 1 0 8 0 fdescpl 488 1532 0 1516 3 0 3 3 0 8 0 filepl 152 8869 0 8762 8 3 5 6 0 8 0 lockfpl 104 436 0 436 2 1 1 1 0 8 1 lockfspl 48 147 0 147 2 1 1 1 0 8 1 sessionpl 112 27 0 16 1 0 1 1 0 8 0 pgrppl 48 44 0 33 1 0 1 1 0 8 0 ucredpl 96 1671 0 1662 1 0 1 1 0 8 0 zombiepl 144 1516 0 1516 2 1 1 1 0 8 1 processpl 896 1548 0 1516 4 0 4 4 0 8 0 procpl 632 4126 0 4081 8 3 5 5 0 8 1 srpgc 64 16 0 16 7 6 1 1 0 8 1 sosppl 128 19 0 19 6 5 1 1 0 8 1 sockpl 384 1182 0 1163 4 1 3 3 0 8 1 mcl64k 65536 10 0 0 2 0 2 2 0 8 0 mcl16k 16384 8 0 0 1 0 1 1 0 8 0 mcl12k 12288 9 0 0 1 0 1 1 0 8 0 mcl9k 9216 6 0 0 1 0 1 1 0 8 0 mcl8k 8192 12 0 0 2 0 2 2 0 8 0 mcl4k 4096 9 0 0 2 0 2 2 0 8 0 mcl2k2 2112 2 0 0 1 0 1 1 0 8 0 mcl2k 2048 275 0 0 33 1 32 33 0 8 0 mtagpl 80 18 0 0 1 0 1 1 0 8 0 mbufpl 256 307 0 0 18 0 18 18 0 8 0 bufpl 256 10517 0 3498 439 0 439 439 0 8 0 anonpl 16 154091 0 143516 86 35 51 66 0 124 0 amapchunkpl 152 9593 0 9481 18 11 7 10 0 158 0 amappl16 192 6462 0 5790 61 27 34 46 0 8 0 amappl15 184 595 0 595 2 2 0 1 0 8 0 amappl14 176 691 0 684 1 0 1 1 0 8 0 amappl13 168 98 0 96 4 3 1 1 0 8 0 amappl12 160 13 0 12 1 0 1 1 0 8 0 amappl11 152 218 0 203 1 0 1 1 0 8 0 amappl10 144 316 0 311 1 0 1 1 0 8 0 amappl9 136 692 0 688 1 0 1 1 0 8 0 amappl8 128 236 0 212 1 0 1 1 0 8 0 amappl7 120 289 0 281 1 0 1 1 0 8 0 amappl6 112 205 0 197 1 0 1 1 0 8 0 amappl5 104 201 0 186 1 0 1 1 0 8 0 amappl4 96 1630 0 1598 2 1 1 2 0 8 0 amappl3 88 649 0 639 1 0 1 1 0 8 0 amappl2 80 11302 0 11229 3 1 2 3 0 8 0 amappl1 72 43070 0 42623 26 16 10 20 0 8 0 amappl 80 4510 0 4470 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 66 0 2 2 0 2 2 0 8 0 uaddrrnd 24 1532 0 1516 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 1532 0 1516 1 0 1 1 0 8 0 vmmpekpl 168 14451 0 14417 2 0 2 2 0 8 0 vmmpepl 168 191842 0 190029 191 88 103 103 0 357 19 vmsppl 368 1531 0 1516 2 0 2 2 0 8 0 pdppl 4096 3071 0 3032 7 1 6 6 0 8 0 pvpl 32 447428 0 433633 210 75 135 162 0 265 8 pmappl 232 1531 0 1516 2 1 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 626 0 6 18 0 18 18 0 8 0