witness: lock order reversal: 1st 0xfffffd807b14e0a8 inode (&ip->i_lock) 2nd 0xfffffd807a386620 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(fffffd807a386620,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807a386620,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807a386610) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800023ba59c0,1,ffff800020ab0508) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa707d8,c0106477,ffff800023ba59c0,1,fffffd807f7c69c0,ffff800020ab0508) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd8007e0cdc8,c0106477,ffff800023ba59c0,ffff800020ab0508) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020ab0508,ffff800023ba5ad8,ffff800023ba5b40) at sys_ioctl+0x5b8 syscall(ffff800023ba5bb0) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800023ba5bb0) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,c54522551b0) at Xsyscall+0x128 end of kernel end trace frame: 0xc56f31e2910, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800023ba5580 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800022f90000 rax 0xffff800000a8f080 r8 0xffffffff81c43405 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xaa2357ec9498ae6b r12 0xfffffd80029b9c00 r13 0 r14 0xffffffff825dbf90 w_lodata+0x4d160 r15 0xffffffff825e31b0 w_lodata+0x54380 rip 0xffffffff8195cff8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800023ba5570 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.1) pid=253288 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=51, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab0c70,0xffff800020ab1170 process=0xffff800020adc000 user=0xffff800023ba0000, vmspace=0xfffffd807f00c170 estcpu=1, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 83938 408784 5483 0 7 0 syz-executor.1 83938 460406 5483 0 2 0x4000000 syz-executor.1 83938 99640 5483 0 2 0x4000000 syz-executor.1 *83938 253288 5483 0 7 0x4000000 syz-executor.1 83938 196898 5483 0 3 0x4000080 fsleep syz-executor.1 83938 326699 5483 0 2 0x4000000 syz-executor.1 5483 165897 34788 0 3 0x82 nanosleep syz-executor.1 49858 313305 34788 0 3 0x82 piperd syz-executor.0 34788 166346 5604 0 3 0x82 thrsleep syz-fuzzer 34788 307700 5604 0 3 0x4000082 thrsleep syz-fuzzer 34788 411336 5604 0 3 0x4000082 thrsleep syz-fuzzer 34788 479249 5604 0 3 0x4000082 thrsleep syz-fuzzer 34788 296131 5604 0 3 0x4000082 thrsleep syz-fuzzer 34788 417095 5604 0 3 0x4000082 kqread syz-fuzzer 34788 154293 5604 0 3 0x4000082 thrsleep syz-fuzzer 34788 188512 5604 0 3 0x4000082 thrsleep syz-fuzzer 34788 124943 5604 0 3 0x4000082 thrsleep syz-fuzzer 34788 265365 5604 0 3 0x4000082 thrsleep syz-fuzzer 5604 312700 82420 0 3 0x10008a pause ksh 82420 330796 8247 0 3 0x92 select sshd 98819 507517 1 0 3 0x100083 ttyin getty 8247 63107 1 0 3 0x80 select sshd 98382 58850 79570 74 3 0x100092 bpf pflogd 79570 118220 1 0 3 0x80 netio pflogd 39991 385742 35354 73 3 0x100090 kqread syslogd 35354 7642 1 0 3 0x100082 netio syslogd 8710 481956 1 77 3 0x100090 poll dhclient 5815 143216 1 0 3 0x80 poll dhclient 38747 365850 0 0 3 0x14200 pgzero zerothread 97364 242800 0 0 3 0x14200 aiodoned aiodoned 57549 22386 0 0 3 0x14200 syncer update 62073 204223 0 0 3 0x14200 cleaner cleaner 52350 493015 0 0 3 0x14200 reaper reaper 33708 477035 0 0 3 0x14200 pgdaemon pagedaemon 52579 456047 0 0 3 0x14200 bored crynlk 99212 209490 0 0 3 0x14200 bored crypto 71376 82514 0 0 3 0x40014200 acpi0 acpi0 38271 439694 0 0 3 0x40014200 idle1 91804 482358 0 0 3 0x14200 bored softnet 70250 26756 0 0 3 0x14200 bored systqmp 51991 521883 0 0 3 0x14200 bored systq 40859 181547 0 0 3 0x40014200 bored softclock 55071 426387 0 0 3 0x40014200 idle0 34831 443880 0 0 3 0x14200 bored smr 1 373814 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 83938 (syz-executor.1) thread 0xffff800020ab0508 (253288) exclusive rrwlock inode r = 0 (0xfffffd807b14e0a8) #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 (0xffffffff826445e0) #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 9495 6407K 6981K 78643K 10888 0 0 pcb 13 8K 8K 78643K 43 0 0 rtable 105 3K 3K 78643K 217 0 0 ifaddr 48 11K 11K 78643K 50 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1479 0 0 iov 0 0K 12K 78643K 16 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1223 77K 77K 78643K 1319 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 4 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 0K 78643K 18 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 135 0 0 sigio 0 0K 0K 78643K 10 0 0 proc 53 50K 83K 78643K 427 0 0 subproc 32 2K 2K 78643K 34 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 14 0 0 in_multi 33 2K 2K 78643K 33 0 0 ether_multi 1 0K 0K 78643K 1 0 0 mrt 0 0K 0K 78643K 2 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 54 238K 238K 78643K 54 0 0 exec 0 0K 1K 78643K 223 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 102 21K 22K 78643K 1374 0 0 UVM aobj 4 2K 2K 78643K 6 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 8 0 0 NDP 9 0K 0K 78643K 13 0 0 temp 115 3542K 3606K 78643K 3629 0 0 kqueue 0 0K 0K 78643K 4 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 6 0 0 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 23 0 21 1 0 1 1 0 8 0 rtentry 112 46 0 2 2 0 2 2 0 8 0 unpcb 120 53 0 43 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 9821 0 9821 1 0 1 1 0 8 1 tcpcb 544 30 0 26 1 0 1 1 0 8 0 inpcb 280 97 0 90 1 0 1 1 0 8 0 rttmr 72 1 0 1 1 0 1 1 0 8 1 nd6 48 6 0 0 1 0 1 1 0 8 0 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 12 0 2 1 0 1 1 0 8 0 pfstkey 112 12 0 2 1 0 1 1 0 8 0 pfstate 328 12 0 2 1 0 1 1 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 203 0 14 13 0 13 13 0 8 1 art_table 32 204 0 14 2 0 2 2 0 8 0 art_node 16 45 0 5 1 0 1 1 0 8 0 sysvmsgpl 40 2 0 0 1 0 1 1 0 8 0 semapl 112 16 0 6 1 0 1 1 0 8 0 shmpl 112 4 0 2 1 0 1 1 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 1617 0 189 47 0 47 47 0 8 0 ffsino 272 1617 0 189 96 0 96 96 0 8 0 nchpl 144 2010 0 364 62 0 62 62 0 8 0 uvmvnodes 72 1733 0 0 32 0 32 32 0 8 0 vnodes 200 1733 0 0 92 0 92 92 0 8 0 namei 1024 5532 0 5532 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scxspl 192 5632 0 5632 9 8 1 7 0 8 1 plimitpl 152 23 0 15 1 0 1 1 0 8 0 sigapl 432 335 0 320 3 0 3 3 0 8 1 futexpl 56 1560 0 1559 1 0 1 1 0 8 0 knotepl 112 71 0 52 1 0 1 1 0 8 0 kqueuepl 104 28 0 26 1 0 1 1 0 8 0 pipepl 112 200 0 181 1 0 1 1 0 8 0 fdescpl 488 336 0 320 3 0 3 3 0 8 0 filepl 152 1771 0 1664 6 1 5 5 0 8 0 lockfpl 104 92 0 92 2 1 1 1 0 8 1 lockfspl 48 27 0 27 2 1 1 1 0 8 1 sessionpl 112 18 0 7 1 0 1 1 0 8 0 pgrppl 48 26 0 15 1 0 1 1 0 8 0 ucredpl 96 172 0 163 1 0 1 1 0 8 0 zombiepl 144 320 0 320 2 1 1 1 0 8 1 processpl 896 351 0 320 4 0 4 4 0 8 0 procpl 632 601 0 556 4 0 4 4 0 8 0 srpgc 64 1 0 1 1 0 1 1 0 8 1 sockpl 384 173 0 154 4 1 3 3 0 8 1 mcl64k 65536 7 0 0 1 0 1 1 0 8 0 mcl12k 12288 2 0 0 1 0 1 1 0 8 0 mcl8k 8192 2 0 0 1 0 1 1 0 8 0 mcl4k 4096 3 0 0 1 0 1 1 0 8 0 mcl2k 2048 176 0 0 21 0 21 21 0 8 0 mtagpl 80 4 0 0 1 0 1 1 0 8 0 mbufpl 256 206 0 0 13 0 13 13 0 8 0 bufpl 256 6137 0 1166 311 0 311 311 0 8 0 anonpl 16 41817 0 30067 49 1 48 48 0 124 0 amapchunkpl 152 1708 0 1586 8 1 7 7 0 158 1 amappl16 192 1184 0 550 33 0 33 33 0 8 1 amappl15 184 54 0 53 2 1 1 1 0 8 0 amappl14 176 104 0 97 1 0 1 1 0 8 0 amappl13 168 6 0 6 1 1 0 1 0 8 0 amappl12 160 16 0 12 1 0 1 1 0 8 0 amappl11 152 119 0 101 1 0 1 1 0 8 0 amappl10 144 72 0 68 1 0 1 1 0 8 0 amappl9 136 599 0 596 1 0 1 1 0 8 0 amappl8 128 158 0 138 1 0 1 1 0 8 0 amappl7 120 38 0 34 1 0 1 1 0 8 0 amappl6 112 109 0 101 1 0 1 1 0 8 0 amappl5 104 146 0 131 1 0 1 1 0 8 0 amappl4 96 551 0 515 2 1 1 2 0 8 0 amappl3 88 285 0 273 1 0 1 1 0 8 0 amappl2 80 1769 0 1697 3 1 2 3 0 8 0 amappl1 72 17003 0 16555 26 16 10 20 0 8 0 amappl 80 863 0 820 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 5 0 2 1 0 1 1 0 8 0 uaddrrnd 24 336 0 320 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 336 0 320 1 0 1 1 0 8 0 vmmpekpl 168 6782 0 6755 2 0 2 2 0 8 0 vmmpepl 168 47555 0 45767 129 26 103 103 0 357 23 vmsppl 368 335 0 320 2 0 2 2 0 8 0 pdppl 4096 679 0 640 7 1 6 6 0 8 0 pvpl 32 147140 0 132201 141 15 126 126 0 265 4 pmappl 232 335 0 320 2 0 2 2 0 8 1 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 477 0 5 14 0 14 14 0 8 0