witness: lock order reversal: 1st 0xfffffd80645fef88 inode (&ip->i_lock) 2nd 0xfffffd807b0e3438 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(fffffd807b0e3438,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807b0e3438,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807b0e3428) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800022d79220,1,ffff800020ab1650) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa7d0d0,c0106477,ffff800022d79220,1,fffffd807f7c6a20,ffff800020ab1650) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd8067c643a8,c0106477,ffff800022d79220,ffff800020ab1650) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020ab1650,ffff800022d79338,ffff800022d793a0) at sys_ioctl+0x5b8 syscall(ffff800022d79410) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800022d79410) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,9a6435cd010) at Xsyscall+0x128 end of kernel end trace frame: 0x9a8a68af960, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800022d78de0 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800021b86000 rax 0xffff800000a8cf80 r8 0xffffffff81944fb5 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x4ea068b9856e5696 r12 0xfffffd80029b8c00 r13 0 r14 0xffffffff82606790 w_lodata+0x449f0 r15 0xffffffff82615d00 w_lodata+0x53f60 rip 0xffffffff81ae7518 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800022d78dd0 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.0) pid=33889 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=82, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab09f8,0xffff800020ab02a0 process=0xffff800020addc00 user=0xffff800022d74000, vmspace=0xfffffd807f00ca10 estcpu=36, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 17782 85050 44218 0 2 0 syz-executor.1 17782 487086 44218 0 3 0x4000080 ttyout syz-executor.1 17782 281935 44218 0 7 0x4000000 syz-executor.1 69873 233622 76128 0 2 0 syz-executor.0 *69873 33889 76128 0 7 0x4000000 syz-executor.0 69873 99235 76128 0 2 0x4000000 syz-executor.0 44218 435932 1650 0 3 0x82 nanosleep syz-executor.1 87564 328092 1 0 3 0x100083 ttyin getty 76128 425990 1650 0 3 0x82 nanosleep syz-executor.0 16971 455027 0 0 3 0x14200 bored sosplice 1650 521682 44244 0 3 0x82 thrsleep syz-fuzzer 1650 302438 44244 0 3 0x4000082 thrsleep syz-fuzzer 1650 445178 44244 0 3 0x4000082 thrsleep syz-fuzzer 1650 245286 44244 0 3 0x4000082 kqread syz-fuzzer 1650 27841 44244 0 3 0x4000082 thrsleep syz-fuzzer 1650 271224 44244 0 3 0x4000082 thrsleep syz-fuzzer 1650 262011 44244 0 3 0x4000082 thrsleep syz-fuzzer 1650 87880 44244 0 3 0x4000082 thrsleep syz-fuzzer 1650 67708 44244 0 3 0x4000082 thrsleep syz-fuzzer 1650 400142 44244 0 3 0x4000082 thrsleep syz-fuzzer 44244 9613 54932 0 3 0x10008a pause ksh 54932 256416 47949 0 3 0x92 select sshd 47949 137093 1 0 3 0x80 select sshd 65916 372318 69974 74 3 0x100092 bpf pflogd 69974 201971 1 0 3 0x80 netio pflogd 24846 93731 6859 73 3 0x100090 kqread syslogd 6859 394792 1 0 3 0x100082 netio syslogd 606 373111 1 77 3 0x100090 poll dhclient 4341 340866 1 0 3 0x80 poll dhclient 67447 49560 0 0 2 0x14200 zerothread 8778 431817 0 0 3 0x14200 aiodoned aiodoned 55157 83568 0 0 3 0x14200 syncer update 52131 478582 0 0 3 0x14200 cleaner cleaner 415 228980 0 0 3 0x14200 reaper reaper 7748 301328 0 0 3 0x14200 pgdaemon pagedaemon 72760 210493 0 0 3 0x14200 bored crynlk 93185 9954 0 0 3 0x14200 bored crypto 44001 10863 0 0 3 0x40014200 acpi0 acpi0 81030 501988 0 0 3 0x40014200 idle1 94796 193830 0 0 3 0x14200 bored softnet 4846 39429 0 0 3 0x14200 bored systqmp 63927 388575 0 0 3 0x14200 bored systq 69726 508434 0 0 3 0x40014200 bored softclock 89736 483736 0 0 3 0x40014200 idle0 23496 37223 0 0 3 0x14200 bored smr 1 332139 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 69873 (syz-executor.0) thread 0xffff800020ab1650 (33889) exclusive rrwlock inode r = 0 (0xfffffd80645fef88) #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 (0xffffffff8262c5a8) #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 9560 6455K 7221K 78643K 15773 0 0 pcb 13 8K 8K 78643K 278 0 0 rtable 113 4K 5K 78643K 867 0 0 ifaddr 71 16K 16K 78643K 309 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1554 0 0 iov 0 0K 32K 78643K 189 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1210 76K 77K 78643K 3124 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 31 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 1K 78643K 246 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 6 17K 25K 78643K 2138 0 0 sigio 0 0K 0K 78643K 19 0 0 proc 54 51K 71K 78643K 904 0 0 subproc 32 2K 2K 78643K 136 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 155 0 0 in_multi 33 2K 2K 78643K 154 0 0 ether_multi 1 0K 0K 78643K 8 0 0 mrt 0 0K 0K 78643K 4 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 72 318K 318K 78643K 72 0 0 exec 0 0K 1K 78643K 424 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 107 21K 31K 78643K 7798 0 0 UVM aobj 98 5K 5K 78643K 108 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 315 0 0 NDP 16 0K 0K 78643K 92 0 0 temp 200 3556K 3624K 78643K 49811 0 0 kqueue 0 0K 0K 78643K 23 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 19 0 12 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 119 0 117 1 0 1 1 0 8 0 rtentry 112 112 0 67 2 0 2 2 0 8 0 unpcb 120 579 0 569 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 8575 0 8575 1 1 0 1 0 8 0 tcpcb 544 447 0 443 1 0 1 1 0 8 0 inpcb 280 1261 0 1253 5 4 1 2 0 8 0 ip6q 72 1 0 1 1 1 0 1 0 8 0 ip6af 48 2 0 2 1 1 0 1 0 8 0 nd6 48 24 0 18 1 0 1 1 0 8 0 pkpcb 40 7 0 7 2 2 0 1 0 8 0 swfcl 56 1 0 0 1 0 1 1 0 8 0 ppxss 1128 45 0 45 7 7 0 1 0 8 0 pffrag 232 6 0 6 3 3 0 1 0 482 0 pffrnode 88 6 0 6 3 3 0 1 0 8 0 pffrent 40 14 0 14 3 3 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 70 0 48 1 0 1 1 0 8 0 pfstkey 112 70 0 48 1 0 1 1 0 8 0 pfstate 328 70 0 48 3 0 3 3 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 468 0 273 13 0 13 13 0 8 0 art_table 32 469 0 273 2 0 2 2 0 8 0 art_node 16 111 0 70 1 0 1 1 0 8 0 sysvmsgpl 40 15 0 9 1 0 1 1 0 8 0 semupl 112 2 0 2 1 1 0 1 0 8 0 semapl 112 242 0 232 1 0 1 1 0 8 0 shmpl 112 106 0 10 3 0 3 3 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 4698 0 3267 47 0 47 47 0 8 0 ffsino 272 4698 0 3267 96 0 96 96 0 8 0 nchpl 144 7857 0 6224 62 0 62 62 0 8 0 uvmvnodes 72 5926 0 0 108 0 108 108 0 8 0 vnodes 200 5926 0 0 312 0 312 312 0 8 0 namei 1024 24760 0 24760 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 2 0 2 2 2 0 1 0 8 0 scxspl 192 23043 0 23043 15 14 1 7 0 8 1 plimitpl 152 235 0 227 1 0 1 1 0 8 0 sigapl 432 2322 0 2306 3 1 2 3 0 8 0 futexpl 56 26973 0 26973 1 0 1 1 0 8 1 knotepl 112 485 0 466 1 0 1 1 0 8 0 kqueuepl 104 436 0 434 1 0 1 1 0 8 0 pipepl 112 1260 0 1241 3 2 1 2 0 8 0 fdescpl 488 2323 0 2306 3 0 3 3 0 8 0 filepl 152 13580 0 13475 9 4 5 7 0 8 0 lockfpl 104 609 0 609 2 1 1 1 0 8 1 lockfspl 48 203 0 203 2 1 1 1 0 8 1 sessionpl 112 26 0 15 1 0 1 1 0 8 0 pgrppl 48 39 0 28 1 0 1 1 0 8 0 ucredpl 96 2625 0 2616 1 0 1 1 0 8 0 zombiepl 144 2306 0 2306 2 1 1 1 0 8 1 processpl 896 2339 0 2306 4 0 4 4 0 8 0 procpl 632 6712 0 6666 12 8 4 5 0 8 0 srpgc 64 12 0 12 5 5 0 1 0 8 0 sosppl 128 17 0 17 4 4 0 1 0 8 0 sockpl 384 2002 0 1983 5 2 3 4 0 8 1 mcl64k 65536 12 0 0 2 0 2 2 0 8 0 mcl16k 16384 2 0 0 1 0 1 1 0 8 0 mcl12k 12288 25 0 0 2 0 2 2 0 8 0 mcl9k 9216 11 0 0 1 0 1 1 0 8 0 mcl8k 8192 13 0 0 2 0 2 2 0 8 0 mcl4k 4096 18 0 0 3 0 3 3 0 8 1 mcl2k2 2112 11 0 0 1 0 1 1 0 8 0 mcl2k 2048 164 0 0 20 3 17 20 0 8 0 mtagpl 80 33 0 0 1 0 1 1 0 8 0 mbufpl 256 268 0 0 13 0 13 13 0 8 0 bufpl 256 10687 0 3668 439 0 439 439 0 8 0 anonpl 16 246001 0 233153 115 58 57 69 0 124 0 amapchunkpl 152 14023 0 13909 27 21 6 10 0 158 0 amappl16 192 10896 0 10188 96 60 36 48 0 8 0 amappl15 184 1170 0 1167 1 0 1 1 0 8 0 amappl14 176 1271 0 1262 1 0 1 1 0 8 0 amappl13 168 6 0 6 1 1 0 1 0 8 0 amappl12 160 481 0 479 3 2 1 1 0 8 0 amappl11 152 79 0 64 1 0 1 1 0 8 0 amappl10 144 353 0 349 1 0 1 1 0 8 0 amappl9 136 680 0 676 1 0 1 1 0 8 0 amappl8 128 228 0 201 1 0 1 1 0 8 0 amappl7 120 327 0 321 1 0 1 1 0 8 0 amappl6 112 64 0 56 1 0 1 1 0 8 0 amappl5 104 657 0 641 1 0 1 1 0 8 0 amappl4 96 1284 0 1252 2 1 1 2 0 8 0 amappl3 88 2757 0 2740 1 0 1 1 0 8 0 amappl2 80 17414 0 17334 3 0 3 3 0 8 0 amappl1 72 59477 0 59017 25 15 10 19 0 8 0 amappl 80 7065 0 7024 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 107 0 10 2 0 2 2 0 8 0 uaddrrnd 24 2323 0 2306 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 2323 0 2306 1 0 1 1 0 8 0 vmmpekpl 168 18044 0 18008 2 0 2 2 0 8 0 vmmpepl 168 289221 0 287263 173 87 86 105 0 357 0 vmsppl 368 2322 0 2306 2 0 2 2 0 8 0 pdppl 4096 4653 0 4612 7 1 6 6 0 8 0 pvpl 32 660481 0 644323 238 91 147 168 0 265 11 pmappl 232 2322 0 2306 2 1 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 609 0 8 18 0 18 18 0 8 0