witness: lock order reversal: 1st 0xfffffd806e6ca0a8 inode (&ip->i_lock) 2nd 0xfffffd807ead8068 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(fffffd807ead8068,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807ead8068,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807ead8058) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800022b8d290,1,ffff800020acf3e8) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa74328,c0106477,ffff800022b8d290,1,fffffd807f7c6780,ffff800020acf3e8) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd80675f3280,c0106477,ffff800022b8d290,ffff800020acf3e8) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020acf3e8,ffff800022b8d3a8,ffff800022b8d410) at sys_ioctl+0x5b8 syscall(ffff800022b8d480) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800022b8d480) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,3a76001c010) at Xsyscall+0x128 end of kernel end trace frame: 0x3a973d62270, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800022b8ce50 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800021352000 rax 0xffff800000b5d0c0 r8 0xffffffff81552515 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xeaf8ed08e92aed13 r12 0xfffffd80029b4c00 r13 0 r14 0xffffffff825a4af0 w_lodata+0x3ae90 r15 0xffffffff825bdd20 w_lodata+0x540c0 rip 0xffffffff81f8aae8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800022b8ce40 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.1) pid=327108 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=81, nice=20 forw=0xffffffffffffffff, list=0xffff800020aceef8,0xffff800020ace528 process=0xffff800020adc380 user=0xffff800022b88000, vmspace=0xfffffd807f00cb80 estcpu=31, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 53887 227108 72732 0 3 0x80 nanosleep syz-executor.0 53887 378912 72732 0 3 0x4000080 fsleep syz-executor.0 53887 398588 72732 0 3 0x4000080 fsleep syz-executor.0 56045 175536 97947 0 7 0 syz-executor.1 *56045 327108 97947 0 7 0x4000000 syz-executor.1 56045 355186 97947 0 2 0x4000000 syz-executor.1 56045 243944 97947 0 3 0x4000080 fsleep syz-executor.1 72732 227961 92416 0 3 0x82 nanosleep syz-executor.0 97947 5127 92416 0 3 0x82 nanosleep syz-executor.1 40572 278414 1 0 3 0x100083 ttyin getty 12179 224086 0 0 3 0x14200 bored sosplice 92416 481985 61378 0 3 0x82 thrsleep syz-fuzzer 92416 277363 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 170593 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 81107 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 21274 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 51960 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 459559 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 83095 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 24510 61378 0 3 0x4000082 thrsleep syz-fuzzer 92416 207671 61378 0 3 0x4000082 kqread syz-fuzzer 61378 390341 76592 0 3 0x10008a pause ksh 76592 488266 90608 0 3 0x92 select sshd 90608 31813 1 0 3 0x80 select sshd 25170 139976 34347 74 3 0x100092 bpf pflogd 34347 523007 1 0 3 0x80 netio pflogd 65471 14539 76465 73 3 0x100090 kqread syslogd 76465 258705 1 0 3 0x100082 netio syslogd 44828 274940 1 77 3 0x100090 poll dhclient 77165 286096 1 0 3 0x80 poll dhclient 10936 170566 0 0 3 0x14200 pgzero zerothread 94486 217670 0 0 3 0x14200 aiodoned aiodoned 3847 392624 0 0 3 0x14200 syncer update 76655 493400 0 0 3 0x14200 cleaner cleaner 24227 24361 0 0 3 0x14200 reaper reaper 48854 218539 0 0 3 0x14200 pgdaemon pagedaemon 81238 279466 0 0 3 0x14200 bored crynlk 70067 231187 0 0 3 0x14200 bored crypto 68013 372580 0 0 3 0x40014200 acpi0 acpi0 68510 366858 0 0 3 0x40014200 idle1 54622 433776 0 0 3 0x14200 bored softnet 82473 397169 0 0 3 0x14200 bored systqmp 76961 522465 0 0 3 0x14200 bored systq 59347 188275 0 0 3 0x40014200 bored softclock 200 267781 0 0 3 0x40014200 idle0 45697 120797 0 0 3 0x14200 bored smr 1 258989 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 56045 (syz-executor.1) thread 0xffff800020acf3e8 (327108) exclusive rrwlock inode r = 0 (0xfffffd806e6ca0a8) #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 (0xffffffff82629140) #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 9625 6479K 14921K 78643K 51987 0 0 pcb 13 8K 8K 78643K 1149 0 0 rtable 119 13K 13K 78643K 4988 0 0 ifaddr 90 24K 28K 78643K 1838 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 2320 0 0 iov 0 0K 32K 78643K 1521 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1200 75K 77K 78643K 16032 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 219 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 0K 78643K 1744 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 6 17K 25K 78643K 16159 0 0 sigio 0 0K 0K 78643K 206 0 0 proc 54 51K 83K 78643K 3807 0 0 subproc 32 2K 2K 78643K 788 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 1502 0 0 in_multi 33 2K 2K 78643K 1015 0 0 ether_multi 1 0K 0K 78643K 59 0 0 mrt 0 0K 0K 78643K 53 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 132 583K 583K 78643K 132 0 0 exec 0 0K 1K 78643K 2173 0 0 pfkey data 0 0K 4K 78643K 4 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 131 23K 32K 78643K 52517 0 0 UVM aobj 130 6K 6K 78643K 144 0 0 memdesc 1 4K 4K 78643K 1 0 0 crypto data 1 1K 1K 78643K 1 0 0 ip6_options 0 0K 1K 78643K 842 0 0 NDP 24 0K 0K 78643K 560 0 0 temp 242 3549K 4189K 78643K 216266 0 0 kqueue 0 0K 0K 78643K 151 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 99 0 93 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 696 0 694 1 0 1 1 0 8 0 rtentry 112 561 0 517 3 1 2 2 0 8 0 unpcb 120 5246 0 5235 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 9634 0 9634 1 1 0 1 0 8 0 tcpcb 544 2435 0 2431 1 0 1 1 0 8 0 inpcb 280 7399 0 7388 32 30 2 2 0 8 1 rttmr 72 10 0 10 10 10 0 1 0 8 0 nd6 48 138 0 132 1 0 1 1 0 8 0 pkpcb 40 91 0 91 35 35 0 1 0 8 0 swfcl 56 9 0 0 1 0 1 1 0 8 0 ppxss 1128 323 0 323 37 36 1 1 0 8 1 pffrag 232 41 0 41 20 20 0 1 0 482 0 pffrnode 88 41 0 41 20 20 0 1 0 8 0 pffrent 40 98 0 98 21 21 0 1 0 8 0 pfosfp 40 846 0 846 5 5 0 5 0 8 0 pfosfpen 112 1428 0 1428 21 21 0 21 0 8 0 pfstitem 24 424 0 399 1 0 1 1 0 8 0 pfstkey 112 424 0 399 2 1 1 2 0 8 0 pfstate 328 424 0 398 6 3 3 4 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 2229 0 2032 20 7 13 13 0 8 0 art_table 32 2230 0 2032 2 0 2 2 0 8 0 art_node 16 543 0 503 1 0 1 1 0 8 0 sysvmsgpl 40 13 0 12 2 1 1 1 0 8 0 semupl 112 1 0 1 1 1 0 1 0 8 0 semapl 112 1740 0 1730 1 0 1 1 0 8 0 shmpl 112 142 0 14 4 0 4 4 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 26413 0 24936 48 0 48 48 0 8 0 ffsino 272 26413 0 24936 100 1 99 99 0 8 0 nchpl 144 49115 0 47480 62 0 62 62 0 8 0 uvmvnodes 72 7084 0 0 129 0 129 129 0 8 0 vnodes 200 7084 0 0 373 0 373 373 0 8 0 namei 1024 161698 0 161698 5 4 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 37 0 37 23 22 1 1 0 8 1 scxspl 192 146752 0 146752 74 73 1 6 0 8 1 plimitpl 152 1487 0 1479 1 0 1 1 0 8 0 sigapl 432 16235 0 16219 3 1 2 3 0 8 0 futexpl 56 201627 0 201624 5 4 1 1 0 8 0 knotepl 112 3465 0 3446 2 1 1 2 0 8 0 kqueuepl 104 3532 0 3530 1 0 1 1 0 8 0 pipepl 112 8846 0 8827 16 15 1 2 0 8 0 fdescpl 488 16236 0 16219 3 0 3 3 0 8 0 filepl 152 95787 0 95682 27 22 5 7 0 8 0 lockfpl 104 5050 0 5050 8 7 1 1 0 8 1 lockfspl 48 1735 0 1735 8 7 1 1 0 8 1 sessionpl 112 70 0 59 1 0 1 1 0 8 0 pgrppl 48 267 0 256 1 0 1 1 0 8 0 ucredpl 96 18687 0 18676 1 0 1 1 0 8 0 zombiepl 144 16226 0 16226 4 3 1 1 0 8 1 processpl 896 16259 0 16226 4 0 4 4 0 8 0 procpl 632 49337 0 49290 6 1 5 5 0 8 0 srpgc 64 98 0 98 42 42 0 1 0 8 0 sosppl 128 192 0 192 40 40 0 1 0 8 0 sockpl 384 13572 0 13552 22 19 3 4 0 8 1 mcl64k 65536 942 0 0 111 78 33 64 0 8 1 mcl16k 16384 29 0 0 4 2 2 3 0 8 0 mcl12k 12288 41 0 0 2 0 2 2 0 8 0 mcl9k 9216 29 0 0 2 0 2 2 0 8 0 mcl8k 8192 33 0 0 4 1 3 3 0 8 0 mcl4k 4096 25 0 0 3 1 2 3 0 8 0 mcl2k2 2112 11 0 0 1 0 1 1 0 8 0 mcl2k 2048 177 0 0 15 6 9 15 0 8 0 mtagpl 80 110 0 0 1 0 1 1 0 8 0 mbufpl 256 1406 0 0 40 12 28 36 0 8 0 bufpl 256 41400 0 34315 443 0 443 443 0 8 0 anonpl 16 1469645 0 1459683 279 218 61 70 0 124 0 amapchunkpl 152 97907 0 97791 142 135 7 19 0 158 0 amappl16 192 78902 0 78188 393 354 39 51 0 8 0 amappl15 184 4537 0 4537 8 8 0 1 0 8 0 amappl14 176 5178 0 5169 1 0 1 1 0 8 0 amappl13 168 3774 0 3772 8 7 1 1 0 8 0 amappl12 160 1499 0 1496 3 2 1 1 0 8 0 amappl11 152 2391 0 2376 1 0 1 1 0 8 0 amappl10 144 1061 0 1054 1 0 1 1 0 8 0 amappl9 136 1857 0 1854 1 0 1 1 0 8 0 amappl8 128 1390 0 1339 2 0 2 2 0 8 0 amappl7 120 1100 0 1091 1 0 1 1 0 8 0 amappl6 112 2299 0 2290 1 0 1 1 0 8 0 amappl5 104 2043 0 2028 1 0 1 1 0 8 0 amappl4 96 13554 0 13516 2 1 1 2 0 8 0 amappl3 88 7212 0 7200 1 0 1 1 0 8 0 amappl2 80 129783 0 129697 3 1 2 3 0 8 0 amappl1 72 354720 0 354251 27 17 10 20 0 8 0 amappl 80 50432 0 50390 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 143 0 14 3 0 3 3 0 8 0 uaddrrnd 24 16236 0 16219 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 16236 0 16219 1 0 1 1 0 8 0 vmmpekpl 168 125264 0 125230 2 0 2 2 0 8 0 vmmpepl 168 1967941 0 1965927 594 482 112 125 0 357 17 vmsppl 368 16235 0 16219 2 0 2 2 0 8 0 pdppl 4096 32479 0 32438 7 1 6 6 0 8 0 pvpl 32 3900118 0 3886796 652 502 150 170 0 265 12 pmappl 232 16235 0 16219 3 2 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 763 0 116 20 0 20 20 0 8 0