witness: lock order reversal: 1st 0xfffffd807eac5e78 inode (&ip->i_lock) 2nd 0xfffffd807890a808 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(fffffd807890a808,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807890a808,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807890a7f8) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800020b5f570,1,ffff800020ab0018) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa72260,c0106477,ffff800020b5f570,1,fffffd807f7c63c0,ffff800020ab0018) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd807a0c01c8,c0106477,ffff800020b5f570,ffff800020ab0018) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020ab0018,ffff800020b5f688,ffff800020b5f6f0) at sys_ioctl+0x5b8 syscall(ffff800020b5f760) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800020b5f760) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,a533a05e010) at Xsyscall+0x128 end of kernel end trace frame: 0xa5556f3b740, count: -9 ddb{0}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800020b5f130 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800020b82000 rax 0xffff800000a45d40 r8 0xffffffff82037435 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xd8e50d2c7ba30b51 r12 0xfffffd80029b8c00 r13 0 r14 0xffffffff8260f310 w_lodata+0x4ab90 r15 0xffffffff826189a0 w_lodata+0x54220 rip 0xffffffff81b1dce8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800020b5f120 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.1) pid=63350 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=74, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab13d8,0xffff800020ab0c80 process=0xffff800020add880 user=0xffff800020b5a000, vmspace=0xfffffd807f00c450 estcpu=36, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 66806 42767 98387 0 7 0 syz-executor.1 *66806 63350 98387 0 7 0x4000000 syz-executor.1 66806 268072 98387 0 2 0x4000000 syz-executor.1 66806 192748 98387 0 3 0x4000080 fsleep syz-executor.1 74378 306800 1 0 3 0x100083 ttyin getty 89620 328309 88818 0 3 0x82 nanosleep syz-executor.0 98387 344743 88818 0 3 0x82 nanosleep syz-executor.1 88818 263559 17741 0 3 0x82 thrsleep syz-fuzzer 88818 152634 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 410683 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 200963 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 404225 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 181298 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 229167 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 164774 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 249051 17741 0 3 0x4000082 thrsleep syz-fuzzer 88818 507129 17741 0 3 0x4000082 kqread syz-fuzzer 17741 118345 96211 0 3 0x10008a pause ksh 96211 126872 7939 0 3 0x92 select sshd 7939 471117 1 0 3 0x80 select sshd 85022 7624 25111 74 3 0x100092 bpf pflogd 25111 360980 1 0 3 0x80 netio pflogd 19117 478964 59073 73 3 0x100090 kqread syslogd 59073 397625 1 0 3 0x100082 netio syslogd 11535 410753 1 77 3 0x100090 poll dhclient 16140 174753 1 0 3 0x80 poll dhclient 6832 403758 0 0 3 0x14200 pgzero zerothread 70496 317462 0 0 3 0x14200 aiodoned aiodoned 76357 281951 0 0 3 0x14200 syncer update 8661 84687 0 0 3 0x14200 cleaner cleaner 94807 433926 0 0 3 0x14200 reaper reaper 90552 262261 0 0 3 0x14200 pgdaemon pagedaemon 5490 293110 0 0 3 0x14200 bored crynlk 1265 196737 0 0 3 0x14200 bored crypto 20050 262429 0 0 3 0x40014200 acpi0 acpi0 55473 87238 0 0 3 0x40014200 idle1 61880 419871 0 0 3 0x14200 bored softnet 26657 431968 0 0 3 0x14200 bored systqmp 84917 11666 0 0 3 0x14200 bored systq 54097 275373 0 0 3 0x40014200 bored softclock 97781 380064 0 0 3 0x40014200 idle0 58212 194875 0 0 3 0x14200 bored smr 1 457395 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks Process 66806 (syz-executor.1) thread 0xffff800020ab0018 (63350) exclusive rrwlock inode r = 0 (0xfffffd807eac5e78) #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 (0xffffffff8263fbb8) #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 9500 6541K 6854K 78643K 11321 0 0 pcb 13 8K 8K 78643K 53 0 0 rtable 89 4K 4K 78643K 328 0 0 ifaddr 44 11K 11K 78643K 84 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1482 0 0 iov 0 0K 24K 78643K 26 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1216 76K 77K 78643K 1486 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 10 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 1K 78643K 65 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 332 0 0 sigio 0 0K 0K 78643K 8 0 0 proc 53 50K 71K 78643K 501 0 0 subproc 32 2K 2K 78643K 51 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 7 0 0 in_multi 22 1K 2K 78643K 47 0 0 ether_multi 1 0K 0K 78643K 2 0 0 mrt 0 0K 0K 78643K 1 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 242 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 94 21K 21K 78643K 1946 0 0 UVM aobj 25 2K 2K 78643K 28 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 51 0 0 NDP 8 0K 0K 78643K 23 0 0 temp 129 3547K 3614K 78643K 8149 0 0 kqueue 0 0K 0K 78643K 8 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 8 0 4 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 43 0 41 1 0 1 1 0 8 0 rtentry 112 56 0 23 2 1 1 2 0 8 0 unpcb 120 113 0 103 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 8176 0 8176 1 1 0 1 0 8 0 tcpcb 544 60 0 56 1 0 1 1 0 8 0 inpcb 280 191 0 184 1 0 1 1 0 8 0 nd6 48 9 0 6 1 0 1 1 0 8 0 pkpcb 40 4 0 4 2 1 1 1 0 8 1 ppxss 1128 3 0 3 1 1 0 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 15 0 4 1 0 1 1 0 8 0 pfstkey 112 15 0 4 1 0 1 1 0 8 0 pfstate 328 15 0 4 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 237 0 92 12 2 10 12 0 8 0 art_table 32 238 0 92 2 0 2 2 0 8 0 art_node 16 55 0 25 1 0 1 1 0 8 0 sysvmsgpl 40 5 0 4 2 1 1 1 0 8 0 semupl 112 4 0 4 1 1 0 1 0 8 0 semapl 112 57 0 47 1 0 1 1 0 8 0 shmpl 112 26 0 3 1 0 1 1 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 1912 0 483 47 0 47 47 0 8 0 ffsino 272 1912 0 483 96 0 96 96 0 8 0 nchpl 144 2558 0 923 62 0 62 62 0 8 0 uvmvnodes 72 2143 0 0 39 0 39 39 0 8 0 vnodes 200 2143 0 0 113 0 113 113 0 8 0 namei 1024 7458 0 7458 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scxspl 192 7226 0 7226 9 8 1 7 0 8 1 plimitpl 152 46 0 38 1 0 1 1 0 8 0 sigapl 432 530 0 515 3 1 2 3 0 8 0 futexpl 56 4220 0 4219 1 0 1 1 0 8 0 knotepl 112 132 0 113 1 0 1 1 0 8 0 kqueuepl 104 84 0 82 1 0 1 1 0 8 0 pipepl 112 306 0 287 1 0 1 1 0 8 0 fdescpl 488 531 0 515 3 0 3 3 0 8 0 filepl 152 2926 0 2823 6 1 5 5 0 8 0 lockfpl 104 124 0 124 2 1 1 1 0 8 1 lockfspl 48 43 0 43 2 1 1 1 0 8 1 sessionpl 112 20 0 9 1 0 1 1 0 8 0 pgrppl 48 22 0 11 1 0 1 1 0 8 0 ucredpl 96 407 0 398 1 0 1 1 0 8 0 zombiepl 144 515 0 514 2 1 1 1 0 8 0 processpl 896 546 0 514 4 0 4 4 0 8 0 procpl 632 1133 0 1089 5 1 4 5 0 8 0 srpgc 64 4 0 4 1 1 0 1 0 8 0 sockpl 384 359 0 340 4 1 3 3 0 8 1 mcl64k 65536 3 0 0 1 0 1 1 0 8 0 mcl16k 16384 2 0 0 1 0 1 1 0 8 0 mcl12k 12288 3 0 0 1 0 1 1 0 8 0 mcl9k 9216 3 0 0 1 0 1 1 0 8 0 mcl8k 8192 3 0 0 1 0 1 1 0 8 0 mcl4k 4096 7 0 0 1 0 1 1 0 8 0 mcl2k2 2112 2 0 0 1 0 1 1 0 8 0 mcl2k 2048 169 0 0 21 0 21 21 0 8 0 mtagpl 80 11 0 0 1 0 1 1 0 8 0 mbufpl 256 174 0 0 11 0 11 11 0 8 0 bufpl 256 6510 0 1166 334 0 334 334 0 8 0 anonpl 16 60836 0 48455 66 5 61 65 0 124 10 amapchunkpl 152 2661 0 2550 7 1 6 6 0 158 0 amappl16 192 2159 0 1460 45 6 39 45 0 8 4 amappl15 184 151 0 149 2 1 1 1 0 8 0 amappl14 176 204 0 197 1 0 1 1 0 8 0 amappl13 168 7 0 7 1 1 0 1 0 8 0 amappl12 160 16 0 15 1 0 1 1 0 8 0 amappl11 152 64 0 49 1 0 1 1 0 8 0 amappl10 144 162 0 158 1 0 1 1 0 8 0 amappl9 136 606 0 603 1 0 1 1 0 8 0 amappl8 128 161 0 140 1 0 1 1 0 8 0 amappl7 120 123 0 117 1 0 1 1 0 8 0 amappl6 112 66 0 58 1 0 1 1 0 8 0 amappl5 104 156 0 141 1 0 1 1 0 8 0 amappl4 96 794 0 762 2 1 1 2 0 8 0 amappl3 88 188 0 178 1 0 1 1 0 8 0 amappl2 80 3357 0 3285 3 1 2 3 0 8 0 amappl1 72 21160 0 20712 26 16 10 20 0 8 0 amappl 80 1408 0 1369 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 27 0 3 1 0 1 1 0 8 0 uaddrrnd 24 531 0 515 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 531 0 515 1 0 1 1 0 8 0 vmmpekpl 168 8184 0 8156 3 1 2 2 0 8 0 vmmpepl 168 70732 0 68893 148 35 113 126 0 357 30 vmsppl 368 530 0 515 2 0 2 2 0 8 0 pdppl 4096 1069 0 1030 7 1 6 6 0 8 1 pvpl 32 196511 0 180934 169 13 156 160 0 265 29 pmappl 232 530 0 515 2 1 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 498 0 7 15 0 15 15 0 8 0