witness: lock order reversal: 1st 0xfffffd806e0b6b38 inode (&ip->i_lock) 2nd 0xfffffd806e661bd8 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(fffffd806e661bd8,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd806e661bd8,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd806e661bc8) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800024badcc0,1,ffff800020ab0c70) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa7f648,c0106477,ffff800024badcc0,1,fffffd807f7c6900,ffff800020ab0c70) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd807b8cbc78,c0106477,ffff800024badcc0,ffff800020ab0c70) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020ab0c70,ffff800024baddd8,ffff800024bade40) at sys_ioctl+0x5b8 syscall(ffff800024badeb0) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800024badeb0) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,48ff0cca0e0) at Xsyscall+0x128 end of kernel end trace frame: 0x4922cdd2060, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800024bad880 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800021f94000 rax 0xffff800000ad32c0 r8 0xffffffff8187b235 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xb413d658dfe5aad r12 0xfffffd80029b6c00 r13 0 r14 0xffffffff825b08c0 w_lodata+0x3b4c0 r15 0xffffffff825c9570 w_lodata+0x54170 rip 0xffffffff81b977e8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800024bad870 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.1) pid=110437 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=86, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab09f8,0xffff800020ab13e8 process=0xffff800020a8a390 user=0xffff800024ba8000, vmspace=0xfffffd807f00c450 estcpu=36, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 51034 37950 67553 0 2 0 syz-executor.1 51034 474403 67553 0 3 0x4000080 fsleep syz-executor.1 *51034 110437 67553 0 7 0x4000000 syz-executor.1 51034 89861 67553 0 7 0x4000000 syz-executor.1 85902 322984 99109 0 3 0x82 piperd syz-executor.0 92638 308381 1 0 3 0x100083 ttyin getty 67553 316815 99109 0 3 0x82 nanosleep syz-executor.1 16551 331941 0 0 3 0x14200 bored sosplice 99109 433029 58394 0 3 0x82 thrsleep syz-fuzzer 99109 2576 58394 0 3 0x4000082 nanosleep syz-fuzzer 99109 319 58394 0 3 0x4000082 thrsleep syz-fuzzer 99109 394748 58394 0 3 0x4000082 thrsleep syz-fuzzer 99109 496225 58394 0 3 0x4000082 thrsleep syz-fuzzer 99109 75843 58394 0 3 0x4000082 nanosleep syz-fuzzer 99109 304425 58394 0 3 0x4000082 thrsleep syz-fuzzer 99109 322817 58394 0 3 0x4000082 thrsleep syz-fuzzer 99109 239359 58394 0 3 0x4000082 thrsleep syz-fuzzer 99109 366116 58394 0 3 0x4000082 kqread syz-fuzzer 58394 464325 50624 0 3 0x10008a pause ksh 50624 397559 47734 0 3 0x92 select sshd 47734 217283 1 0 3 0x80 select sshd 79803 14858 21253 74 3 0x100092 bpf pflogd 21253 250386 1 0 3 0x80 netio pflogd 32091 103363 51538 73 3 0x100090 kqread syslogd 51538 16327 1 0 3 0x100082 netio syslogd 67266 297045 1 77 3 0x100090 poll dhclient 63717 503267 1 0 3 0x80 poll dhclient 62234 95336 0 0 3 0x14200 pgzero zerothread 62995 216910 0 0 3 0x14200 aiodoned aiodoned 49148 518209 0 0 3 0x14200 syncer update 99918 276246 0 0 3 0x14200 cleaner cleaner 83017 117306 0 0 3 0x14200 reaper reaper 16124 41483 0 0 3 0x14200 pgdaemon pagedaemon 44010 414411 0 0 3 0x14200 bored crynlk 76027 68328 0 0 3 0x14200 bored crypto 74151 172172 0 0 3 0x40014200 acpi0 acpi0 22465 242021 0 0 3 0x40014200 idle1 24486 325801 0 0 3 0x14200 bored softnet 90173 273246 0 0 3 0x14200 bored systqmp 40132 447699 0 0 3 0x14200 bored systq 52680 360286 0 0 3 0x40014200 bored softclock 41972 78560 0 0 3 0x40014200 idle0 72961 81705 0 0 3 0x14200 bored smr 1 403414 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 51034 (syz-executor.1) thread 0xffff800020ab0c70 (110437) exclusive rrwlock inode r = 0 (0xfffffd806e0b6b38) #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 (0xffffffff826648e0) #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 9664 6624K 14791K 78643K 40696 0 0 pcb 13 8K 8K 78643K 825 0 0 rtable 111 4K 5K 78643K 4215 0 0 ifaddr 100 25K 29K 78643K 1498 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 2064 0 0 iov 0 0K 32K 78643K 1195 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1201 75K 77K 78643K 12209 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 174 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 1K 78643K 1418 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 12070 0 0 sigio 0 0K 0K 78643K 153 0 0 proc 55 51K 83K 78643K 3483 0 0 subproc 32 2K 2K 78643K 767 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 1049 0 0 in_multi 33 2K 2K 78643K 917 0 0 ether_multi 1 0K 0K 78643K 62 0 0 mrt 0 0K 0K 78643K 21 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 162 715K 715K 78643K 162 0 0 exec 0 0K 1K 78643K 1757 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 122 23K 31K 78643K 39579 0 0 UVM aobj 130 5K 5K 78643K 146 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 625 0 0 NDP 25 0K 1K 78643K 464 0 0 temp 263 3545K 4185K 78643K 168657 0 0 kqueue 0 0K 0K 78643K 117 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 96 0 90 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 527 0 525 1 0 1 1 0 8 0 rtentry 112 532 0 488 2 0 2 2 0 8 0 unpcb 120 4028 0 4018 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 10180 0 10180 3 3 0 2 0 8 0 tcpcb 544 1898 0 1894 1 0 1 1 0 8 0 inpcb 280 5626 0 5618 11 10 1 2 0 8 0 rttmr 72 2 0 2 2 2 0 1 0 8 0 nd6 48 135 0 129 1 0 1 1 0 8 0 pkpcb 40 71 0 71 25 25 0 1 0 8 0 swfcl 56 7 0 0 1 0 1 1 0 8 0 ppxss 1128 252 0 252 28 28 0 1 0 8 0 pffrag 232 38 0 38 17 17 0 1 0 482 0 pffrnode 88 38 0 38 17 17 0 1 0 8 0 pffrent 40 105 0 105 18 18 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 336 0 312 1 0 1 1 0 8 0 pfstkey 112 337 0 313 2 0 2 2 0 8 0 pfstate 328 337 0 313 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 2178 0 1981 20 7 13 13 0 8 0 art_table 32 2179 0 1981 2 0 2 2 0 8 0 art_node 16 523 0 483 1 0 1 1 0 8 0 sysvmsgpl 40 26 0 14 1 0 1 1 0 8 0 semupl 112 1 0 1 1 1 0 1 0 8 0 semapl 112 1416 0 1406 1 0 1 1 0 8 0 shmpl 112 144 0 16 4 0 4 4 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 19927 0 18482 47 0 47 47 0 8 0 ffsino 272 19927 0 18482 97 0 97 97 0 8 0 nchpl 144 36651 0 35016 62 0 62 62 0 8 0 uvmvnodes 72 6774 0 0 124 0 124 124 0 8 0 vnodes 200 6774 0 0 357 0 357 357 0 8 0 namei 1024 122114 0 122114 3 2 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 31 0 31 17 17 0 1 0 8 0 scxspl 192 110580 0 110580 47 46 1 7 0 8 1 plimitpl 152 1184 0 1176 1 0 1 1 0 8 0 sigapl 432 12158 0 12143 3 1 2 3 0 8 0 futexpl 56 150546 0 150545 1 0 1 1 0 8 0 knotepl 112 2785 0 2766 1 0 1 1 0 8 0 kqueuepl 104 2539 0 2537 1 0 1 1 0 8 0 pipepl 112 6696 0 6677 14 13 1 2 0 8 0 fdescpl 488 12159 0 12143 3 0 3 3 0 8 0 filepl 152 71648 0 71543 24 19 5 7 0 8 0 lockfpl 104 3844 0 3844 4 3 1 1 0 8 1 lockfspl 48 1308 0 1308 4 3 1 1 0 8 1 sessionpl 112 78 0 67 1 0 1 1 0 8 0 pgrppl 48 202 0 191 1 0 1 1 0 8 0 ucredpl 96 13763 0 13754 1 0 1 1 0 8 0 zombiepl 144 12147 0 12147 3 2 1 1 0 8 1 processpl 896 12179 0 12147 4 0 4 4 0 8 0 procpl 632 36590 0 36546 10 5 5 5 0 8 1 srpgc 64 88 0 88 37 37 0 1 0 8 0 sosppl 128 146 0 146 30 29 1 1 0 8 1 sockpl 384 10383 0 10364 14 11 3 4 0 8 1 mcl64k 65536 769 0 0 95 40 55 66 0 8 1 mcl16k 16384 32 0 0 4 1 3 3 0 8 0 mcl12k 12288 35 0 0 2 0 2 2 0 8 0 mcl9k 9216 22 0 0 2 0 2 2 0 8 0 mcl8k 8192 28 0 0 4 2 2 3 0 8 0 mcl4k 4096 17 0 0 3 0 3 3 0 8 0 mcl2k2 2112 11 0 0 1 0 1 1 0 8 0 mcl2k 2048 231 0 0 26 5 21 26 0 8 1 mtagpl 80 103 0 0 1 0 1 1 0 8 0 mbufpl 256 1272 0 0 36 0 36 36 0 8 0 bufpl 256 41466 0 34447 439 0 439 439 0 8 0 anonpl 16 1109118 0 1097986 242 182 60 67 0 124 3 amapchunkpl 152 72690 0 72579 101 93 8 19 0 158 2 amappl16 192 59554 0 58859 315 272 43 47 0 8 7 amappl15 184 2585 0 2584 6 5 1 1 0 8 0 amappl14 176 2915 0 2910 1 0 1 1 0 8 0 amappl13 168 3102 0 3102 10 10 0 1 0 8 0 amappl12 160 1788 0 1784 1 0 1 1 0 8 0 amappl11 152 952 0 935 1 0 1 1 0 8 0 amappl10 144 1017 0 1012 1 0 1 1 0 8 0 amappl9 136 2239 0 2235 1 0 1 1 0 8 0 amappl8 128 1731 0 1691 4 2 2 2 0 8 0 amappl7 120 1035 0 1027 1 0 1 1 0 8 0 amappl6 112 874 0 859 1 0 1 1 0 8 0 amappl5 104 2237 0 2222 1 0 1 1 0 8 0 amappl4 96 11539 0 11505 2 1 1 2 0 8 0 amappl3 88 4460 0 4449 1 0 1 1 0 8 0 amappl2 80 95830 0 95759 3 1 2 3 0 8 0 amappl1 72 271372 0 270927 26 16 10 20 0 8 0 amappl 80 37615 0 37576 2 0 2 2 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 145 0 16 3 0 3 3 0 8 0 uaddrrnd 24 12159 0 12143 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 12159 0 12143 1 0 1 1 0 8 0 vmmpekpl 168 89611 0 89577 2 0 2 2 0 8 0 vmmpepl 168 1481934 0 1480076 526 425 101 111 0 357 11 vmsppl 368 12158 0 12143 2 0 2 2 0 8 0 pdppl 4096 24325 0 24286 7 1 6 6 0 8 0 pvpl 32 2997758 0 2983379 588 434 154 167 0 265 18 pmappl 232 12158 0 12143 3 2 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 745 0 61 20 0 20 20 0 8 0