witness: lock order reversal: 1st 0xfffffd806e6262b8 inode (&ip->i_lock) 2nd 0xfffffd806eb76620 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{0}> ddb{0}> set $lines = 0 ddb{0}> set $maxwidth = 0 ddb{0}> show panic the kernel did not panic ddb{0}> trace db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:398 witness_checkorder(fffffd806eb76620,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd806eb76620,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd806eb76610) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800023d8f260,1,ffff800020ab0780) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa76260,c0106477,ffff800023d8f260,1,fffffd807f7c6900,ffff800020ab0780) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd806d8d4440,c0106477,ffff800023d8f260,ffff800020ab0780) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020ab0780,ffff800023d8f378,ffff800023d8f3e0) at sys_ioctl+0x5b8 syscall(ffff800023d8f450) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800023d8f450) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,36dce9b2010) at Xsyscall+0x128 end of kernel end trace frame: 0x36ffd572fa0, count: -9 ddb{0}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800023d8ee20 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800020f3a000 rax 0xffff800000ab8600 r8 0xffffffff81552515 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x25eae958ddc12626 r12 0xfffffd80029b4c00 r13 0 r14 0xffffffff825a4570 w_lodata+0x3a910 r15 0xffffffff825be090 w_lodata+0x54430 rip 0xffffffff81f8aae8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800023d8ee10 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.1) pid=318449 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=81, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab0508,0xffff800020ab02a0 process=0xffff800020adc700 user=0xffff800023d8a000, vmspace=0xfffffd807f00c5c0 estcpu=36, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 91980 476820 597 0 7 0 syz-executor.0 91980 96652 597 0 3 0x4000080 fsleep syz-executor.0 79069 108481 29898 0 2 0 syz-executor.1 *79069 318449 29898 0 7 0x4000000 syz-executor.1 79069 235491 29898 0 2 0x4000000 syz-executor.1 29898 191134 78248 0 3 0x82 nanosleep syz-executor.1 597 479710 78248 0 3 0x82 nanosleep syz-executor.0 79689 428129 0 0 3 0x14200 acct acct 38010 438209 1 0 3 0x100083 ttyin getty 14512 210406 0 0 3 0x14200 bored sosplice 78248 408923 26521 0 3 0x82 thrsleep syz-fuzzer 78248 334481 26521 0 3 0x4000082 thrsleep syz-fuzzer 78248 334471 26521 0 3 0x4000082 thrsleep syz-fuzzer 78248 150271 26521 0 3 0x4000082 thrsleep syz-fuzzer 78248 445392 26521 0 3 0x4000082 thrsleep syz-fuzzer 78248 3052 26521 0 3 0x4000082 thrsleep syz-fuzzer 78248 367148 26521 0 3 0x4000082 thrsleep syz-fuzzer 78248 38408 26521 0 3 0x4000082 kqread syz-fuzzer 78248 436835 26521 0 3 0x4000082 thrsleep syz-fuzzer 78248 239276 26521 0 3 0x4000082 thrsleep syz-fuzzer 26521 247429 21720 0 3 0x10008a pause ksh 21720 380241 78840 0 3 0x92 select sshd 78840 390237 1 0 3 0x80 select sshd 77495 284995 50362 74 3 0x100092 bpf pflogd 50362 402980 1 0 3 0x80 netio pflogd 11816 20950 24787 73 3 0x100090 kqread syslogd 24787 486177 1 0 3 0x100082 netio syslogd 692 288914 1 77 3 0x100090 poll dhclient 34208 283047 1 0 3 0x80 poll dhclient 49519 75390 0 0 2 0x14200 zerothread 44498 170128 0 0 3 0x14200 aiodoned aiodoned 42092 468398 0 0 3 0x14200 syncer update 81703 355222 0 0 3 0x14200 cleaner cleaner 87679 394897 0 0 3 0x14200 reaper reaper 19426 188296 0 0 3 0x14200 pgdaemon pagedaemon 95170 316429 0 0 3 0x14200 bored crynlk 7272 156120 0 0 3 0x14200 bored crypto 97239 147832 0 0 3 0x40014200 acpi0 acpi0 6823 516187 0 0 3 0x40014200 idle1 96640 447393 0 0 3 0x14200 bored softnet 54060 488677 0 0 3 0x14200 bored systqmp 87628 101352 0 0 3 0x14200 bored systq 76448 272006 0 0 3 0x40014200 bored softclock 13374 161804 0 0 3 0x40014200 idle0 73115 20327 0 0 3 0x14200 bored smr 1 160621 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks Process 79069 (syz-executor.1) thread 0xffff800020ab0780 (318449) exclusive rrwlock inode r = 0 (0xfffffd806e6262b8) #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{0}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9638 6610K 7386K 78643K 48297 0 0 pcb 13 8K 8K 78643K 1002 0 0 rtable 125 13K 13K 78643K 4826 0 0 ifaddr 93 24K 28K 78643K 1745 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 2173 0 0 iov 0 0K 32K 78643K 1466 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1199 75K 77K 78643K 14585 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 203 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 1K 78643K 1454 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 6 17K 25K 78643K 14860 0 0 sigio 0 0K 0K 78643K 193 0 0 proc 54 51K 83K 78643K 3659 0 0 subproc 32 2K 2K 78643K 826 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 1384 0 0 in_multi 33 2K 2K 78643K 928 0 0 ether_multi 1 0K 0K 78643K 66 0 0 mrt 0 0K 0K 78643K 50 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 120 530K 530K 78643K 120 0 0 exec 0 0K 1K 78643K 1972 0 0 pfkey data 0 0K 4K 78643K 6 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 117 22K 32K 78643K 48294 0 0 UVM aobj 130 4K 4K 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 767 0 0 NDP 23 0K 1K 78643K 530 0 0 temp 249 3549K 4189K 78643K 195694 0 0 kqueue 0 0K 0K 78643K 162 0 0 SYN cache 2 16K 16K 78643K 2 0 0 ddb{0}> show all pools Name Size Requests Fail Releases Pgreq Pgrel Npage Hiwat Minpg Maxpg Idle arp 64 104 0 98 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 663 0 661 1 0 1 1 0 8 0 rtentry 112 578 0 534 2 0 2 2 0 8 0 unpcb 120 4404 0 4394 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 10017 0 10017 5 5 0 2 0 8 0 tcpcb 544 2353 0 2349 1 0 1 1 0 8 0 inpcb 280 6968 0 6959 35 33 2 2 0 8 1 rttmr 72 6 0 6 6 6 0 1 0 8 0 nd6 48 141 0 135 1 0 1 1 0 8 0 pkpcb 40 72 0 72 31 31 0 1 0 8 0 swfcl 56 3 0 0 1 0 1 1 0 8 0 ppxss 1128 305 0 305 40 39 1 1 0 8 1 pffrag 232 26 0 26 17 17 0 1 0 482 0 pffrnode 88 26 0 26 17 17 0 1 0 8 0 pffrent 40 72 0 72 19 19 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 394 0 353 1 0 1 1 0 8 0 pfstkey 112 395 0 354 2 0 2 2 0 8 0 pfstate 328 395 0 354 6 2 4 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 2283 0 2088 15 2 13 13 0 8 0 art_table 32 2284 0 2088 2 0 2 2 0 8 0 art_node 16 553 0 513 1 0 1 1 0 8 0 semapl 112 1452 0 1442 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 24038 0 22567 48 0 48 48 0 8 0 ffsino 272 24038 0 22567 101 2 99 99 0 8 0 nchpl 144 44718 0 43087 62 0 62 62 0 8 0 uvmvnodes 72 6632 0 0 121 0 121 121 0 8 0 vnodes 200 6632 0 0 350 0 350 350 0 8 0 namei 1024 145532 0 145532 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 33 0 33 20 20 0 1 0 8 0 scxspl 192 129762 0 129762 48 47 1 7 0 8 1 plimitpl 152 1293 0 1284 1 0 1 1 0 8 0 sigapl 432 14928 0 14912 3 1 2 3 0 8 0 futexpl 56 180139 0 180138 1 0 1 1 0 8 0 knotepl 112 3239 0 3220 2 1 1 2 0 8 0 kqueuepl 104 3078 0 3076 1 0 1 1 0 8 0 pipepl 112 7822 0 7803 11 10 1 2 0 8 0 fdescpl 488 14929 0 14912 3 0 3 3 0 8 0 filepl 152 85151 0 85048 17 12 5 7 0 8 1 lockfpl 104 4725 0 4724 2 1 1 1 0 8 0 lockfspl 48 1620 0 1619 2 1 1 1 0 8 0 sessionpl 112 66 0 55 1 0 1 1 0 8 0 pgrppl 48 232 0 221 1 0 1 1 0 8 0 ucredpl 96 15770 0 15760 1 0 1 1 0 8 0 zombiepl 144 14918 0 14918 2 1 1 1 0 8 1 processpl 896 14952 0 14918 4 0 4 4 0 8 0 procpl 632 45186 0 45140 21 16 5 5 0 8 1 srpgc 64 96 0 96 37 37 0 1 0 8 0 sosppl 128 138 0 138 37 36 1 1 0 8 1 sockpl 384 12222 0 12203 12 9 3 4 0 8 1 mcl64k 65536 519 0 0 64 16 48 64 0 8 1 mcl16k 16384 23 0 0 3 1 2 3 0 8 0 mcl12k 12288 65 0 0 3 1 2 2 0 8 0 mcl9k 9216 52 0 0 3 1 2 2 0 8 0 mcl8k 8192 22 0 0 3 0 3 3 0 8 0 mcl4k 4096 41 0 0 4 1 3 3 0 8 0 mcl2k2 2112 11 0 0 1 0 1 1 0 8 0 mcl2k 2048 288 0 0 24 11 13 24 0 8 0 mtagpl 80 112 0 0 2 1 1 2 0 8 0 mbufpl 256 1304 0 0 38 2 36 36 0 8 0 bufpl 256 39599 0 32580 439 0 439 439 0 8 0 anonpl 16 1318319 0 1306938 215 156 59 67 0 124 0 amapchunkpl 152 88723 0 88614 107 102 5 12 0 158 0 amappl16 192 72531 0 71841 278 238 40 48 0 8 3 amappl15 184 1974 0 1972 5 4 1 1 0 8 0 amappl14 176 1350 0 1340 1 0 1 1 0 8 0 amappl13 168 3642 0 3642 8 8 0 1 0 8 0 amappl12 160 2247 0 2246 3 2 1 1 0 8 0 amappl11 152 1378 0 1363 1 0 1 1 0 8 0 amappl10 144 2409 0 2405 1 0 1 1 0 8 0 amappl9 136 3472 0 3469 1 0 1 1 0 8 0 amappl8 128 3022 0 2979 3 1 2 2 0 8 0 amappl7 120 2457 0 2448 1 0 1 1 0 8 0 amappl6 112 1249 0 1242 1 0 1 1 0 8 0 amappl5 104 2768 0 2753 1 0 1 1 0 8 0 amappl4 96 14286 0 14246 4 2 2 2 0 8 0 amappl3 88 3464 0 3447 1 0 1 1 0 8 0 amappl2 80 118546 0 118463 3 1 2 3 0 8 0 amappl1 72 326694 0 326246 27 17 10 20 0 8 0 amappl 80 46221 0 46182 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 14929 0 14912 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 14929 0 14912 1 0 1 1 0 8 0 vmmpekpl 168 111348 0 111314 2 0 2 2 0 8 0 vmmpepl 168 1807705 0 1805754 591 485 106 120 0 357 14 vmsppl 368 14928 0 14912 2 0 2 2 0 8 0 pdppl 4096 29865 0 29824 7 1 6 6 0 8 0 pvpl 32 3536257 0 3521536 545 407 138 167 0 265 2 pmappl 232 14928 0 14912 3 2 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 711 0 40 20 0 20 20 0 8 0