witness: lock order reversal: 1st 0xfffffd8065db5818 inode (&ip->i_lock) 2nd 0xfffffd806eaa8068 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(fffffd806eaa8068,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd806eaa8068,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd806eaa8058) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800022ba7c40,1,ffff800020a5f8b8) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa7a260,c0106477,ffff800022ba7c40,1,fffffd807f7c6960,ffff800020a5f8b8) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd8068281e58,c0106477,ffff800022ba7c40,ffff800020a5f8b8) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020a5f8b8,ffff800022ba7d58,ffff800022ba7dc0) at sys_ioctl+0x5b8 syscall(ffff800022ba7e30) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800022ba7e30) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(0,0,ffffffffffffff1b,0,3,40bae8701b0) at Xsyscall+0x128 end of kernel end trace frame: 0x40e2c2f34d0, count: -9 ddb{0}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800022ba7800 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800022790000 rax 0xffff800000022dc0 r8 0xffffffff81944fb5 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x8eb6a54c4054e94e r12 0xfffffd80029b8c00 r13 0 r14 0xffffffff82606bb0 w_lodata+0x44e10 r15 0xffffffff826161d0 w_lodata+0x54430 rip 0xffffffff81ae7518 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800022ba77f0 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.0) pid=489866 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=83, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab0ee8,0xffff800020ab1170 process=0xffff800020a4b888 user=0xffff800022ba2000, vmspace=0xfffffd807f00c8a0 estcpu=33, cpticks=0, pctcpu=0.1 user=0, sys=0, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 40963 263190 42231 0 2 0 syz-executor.0 40963 84674 42231 0 7 0x4000000 syz-executor.0 40963 2745 42231 0 2 0x4000000 syz-executor.0 *40963 489866 42231 0 7 0x4000000 syz-executor.0 40963 20381 42231 0 2 0x4000000 syz-executor.0 40963 258997 42231 0 2 0x4000000 syz-executor.0 40963 118102 42231 0 3 0x4000080 fsleep syz-executor.0 40963 499243 42231 0 2 0x4000000 syz-executor.0 42231 510640 31685 0 3 0x82 nanosleep syz-executor.0 4858 9839 0 0 3 0x14200 acct acct 66291 417614 31685 0 3 0x82 piperd syz-executor.1 58574 233495 0 0 3 0x14200 bored sosplice 31685 469249 62141 0 3 0x82 thrsleep syz-fuzzer 31685 474049 62141 0 3 0x4000082 thrsleep syz-fuzzer 31685 459236 62141 0 3 0x4000082 thrsleep syz-fuzzer 31685 352648 62141 0 3 0x4000082 thrsleep syz-fuzzer 31685 452941 62141 0 3 0x4000082 thrsleep syz-fuzzer 31685 473496 62141 0 3 0x4000082 thrsleep syz-fuzzer 31685 134945 62141 0 3 0x4000082 kqread syz-fuzzer 31685 396359 62141 0 3 0x4000082 thrsleep syz-fuzzer 31685 144456 62141 0 3 0x4000082 thrsleep syz-fuzzer 31685 88953 62141 0 3 0x4000082 thrsleep syz-fuzzer 62141 158962 46187 0 3 0x10008a pause ksh 46187 71145 54367 0 3 0x92 select sshd 84242 144431 1 0 3 0x100083 ttyin getty 54367 461466 1 0 3 0x80 select sshd 29886 408766 6026 74 3 0x100092 bpf pflogd 6026 178194 1 0 3 0x80 netio pflogd 90689 142382 76803 73 3 0x100090 kqread syslogd 76803 140986 1 0 3 0x100082 netio syslogd 76734 151374 1 77 3 0x100090 poll dhclient 49803 409151 1 0 3 0x80 poll dhclient 17797 89917 0 0 3 0x14200 pgzero zerothread 66811 88212 0 0 3 0x14200 aiodoned aiodoned 98691 53968 0 0 3 0x14200 syncer update 99474 259652 0 0 3 0x14200 cleaner cleaner 18059 100547 0 0 3 0x14200 reaper reaper 47479 118725 0 0 3 0x14200 pgdaemon pagedaemon 26654 280662 0 0 3 0x14200 bored crynlk 3844 218921 0 0 3 0x14200 bored crypto 99224 343934 0 0 3 0x40014200 acpi0 acpi0 56111 119026 0 0 3 0x40014200 idle1 17202 457586 0 0 3 0x14200 bored softnet 60406 101587 0 0 3 0x14200 bored systqmp 4957 4595 0 0 3 0x14200 bored systq 97379 132456 0 0 3 0x40014200 bored softclock 88433 244139 0 0 3 0x40014200 idle0 65946 277766 0 0 3 0x14200 bored smr 1 512815 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks Process 40963 (syz-executor.0) thread 0xffff800020a5f8b8 (489866) exclusive rrwlock inode r = 0 (0xfffffd8065db5818) #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{0}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9573 6429K 7073K 78643K 15520 0 0 pcb 13 8K 8K 78643K 195 0 0 rtable 111 4K 4K 78643K 807 0 0 ifaddr 78 15K 16K 78643K 255 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1560 0 0 iov 0 0K 28K 78643K 164 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1208 76K 77K 78643K 2980 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 21 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 0K 78643K 210 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 1803 0 0 sigio 0 0K 0K 78643K 18 0 0 proc 54 51K 83K 78643K 817 0 0 subproc 32 2K 2K 78643K 153 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 166 0 0 in_multi 33 2K 2K 78643K 175 0 0 ether_multi 1 0K 0K 78643K 11 0 0 mrt 1 0K 0K 78643K 16 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 84 371K 371K 78643K 84 0 0 exec 0 0K 1K 78643K 430 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 112 22K 31K 78643K 6735 0 0 UVM aobj 68 3K 3K 78643K 74 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 184 0 0 NDP 18 0K 0K 78643K 78 0 0 temp 214 3556K 3625K 78643K 33267 0 0 kqueue 0 0K 0K 78643K 12 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 20 0 14 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 83 0 81 1 0 1 1 0 8 0 rtentry 112 128 0 84 2 0 2 2 0 8 0 unpcb 120 555 0 545 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 7461 0 7461 2 2 0 2 0 8 0 tcpcb 544 345 0 341 1 0 1 1 0 8 0 inpcb 280 977 0 970 1 0 1 1 0 8 0 rttmr 72 6 0 6 3 2 1 1 0 8 1 nd6 48 27 0 21 1 0 1 1 0 8 0 pkpcb 40 4 0 4 2 2 0 1 0 8 0 swfcl 56 2 0 0 1 0 1 1 0 8 0 ppxss 1128 27 0 27 5 5 0 1 0 8 0 pffrag 232 5 0 5 3 3 0 1 0 482 0 pffrnode 88 5 0 5 3 3 0 1 0 8 0 pffrent 40 10 0 10 3 3 0 1 0 8 0 pfosfp 40 846 0 846 5 0 5 5 0 8 5 pfosfpen 112 1428 0 1428 21 0 21 21 0 8 21 pfstitem 24 54 0 40 1 0 1 1 0 8 0 pfstkey 112 54 0 40 1 0 1 1 0 8 0 pfstate 328 54 0 40 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 562 0 370 14 1 13 13 0 8 1 art_table 32 563 0 370 2 0 2 2 0 8 0 art_node 16 127 0 87 1 0 1 1 0 8 0 sysvmsgpl 40 13 0 2 1 0 1 1 0 8 0 semapl 112 208 0 198 1 0 1 1 0 8 0 shmpl 112 72 0 6 2 0 2 2 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 4137 0 2722 47 0 47 47 0 8 0 ffsino 272 4137 0 2722 96 0 96 96 0 8 0 nchpl 144 6779 0 5141 62 0 62 62 0 8 0 uvmvnodes 72 5441 0 0 99 0 99 99 0 8 0 vnodes 200 5441 0 0 287 0 287 287 0 8 0 namei 1024 21370 0 21370 3 2 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 1 0 1 1 1 0 1 0 8 0 scxspl 192 19394 0 19394 9 8 1 6 0 8 1 plimitpl 152 180 0 172 1 0 1 1 0 8 0 sigapl 432 1982 0 1967 3 1 2 3 0 8 0 futexpl 56 22420 0 22419 2 1 1 1 0 8 0 knotepl 112 446 0 427 1 0 1 1 0 8 0 kqueuepl 104 343 0 341 1 0 1 1 0 8 0 pipepl 112 1078 0 1059 3 2 1 2 0 8 0 fdescpl 488 1983 0 1967 3 0 3 3 0 8 0 filepl 152 11591 0 11479 9 4 5 7 0 8 0 lockfpl 104 426 0 426 3 2 1 1 0 8 1 lockfspl 48 153 0 153 3 2 1 1 0 8 1 sessionpl 112 25 0 14 1 0 1 1 0 8 0 pgrppl 48 35 0 24 1 0 1 1 0 8 0 ucredpl 96 2218 0 2209 1 0 1 1 0 8 0 zombiepl 144 1969 0 1969 3 2 1 1 0 8 1 processpl 896 2002 0 1969 4 0 4 4 0 8 0 procpl 632 5616 0 5567 7 2 5 5 0 8 0 srpgc 64 20 0 20 7 6 1 1 0 8 1 sosppl 128 32 0 32 6 6 0 1 0 8 0 sockpl 384 1637 0 1618 6 3 3 4 0 8 1 mcl64k 65536 583 0 0 71 10 61 64 0 8 1 mcl16k 16384 3 0 0 1 0 1 1 0 8 0 mcl12k 12288 11 0 0 2 0 2 2 0 8 0 mcl9k 9216 15 0 0 2 0 2 2 0 8 0 mcl8k 8192 13 0 0 2 0 2 2 0 8 0 mcl4k 4096 19 0 0 3 1 2 3 0 8 0 mcl2k2 2112 4 0 0 1 0 1 1 0 8 0 mcl2k 2048 189 0 0 23 1 22 23 0 8 0 mtagpl 80 22 0 0 1 0 1 1 0 8 0 mbufpl 256 695 0 0 37 0 37 37 0 8 0 bufpl 256 10604 0 3585 439 0 439 439 0 8 0 anonpl 16 212255 0 201675 112 44 68 69 0 124 15 amapchunkpl 152 12237 0 12094 20 13 7 11 0 158 0 amappl16 192 10753 0 10064 88 44 44 47 0 8 8 amappl14 176 97 0 91 1 0 1 1 0 8 0 amappl13 168 849 0 848 2 1 1 1 0 8 0 amappl12 160 290 0 288 1 0 1 1 0 8 0 amappl11 152 201 0 185 1 0 1 1 0 8 0 amappl10 144 90 0 86 1 0 1 1 0 8 0 amappl9 136 691 0 688 1 0 1 1 0 8 0 amappl8 128 233 0 209 1 0 1 1 0 8 0 amappl7 120 66 0 59 1 0 1 1 0 8 0 amappl6 112 206 0 196 1 0 1 1 0 8 0 amappl5 104 480 0 466 1 0 1 1 0 8 0 amappl4 96 1977 0 1944 2 1 1 2 0 8 0 amappl3 88 531 0 520 1 0 1 1 0 8 0 amappl2 80 14892 0 14819 3 0 3 3 0 8 0 amappl1 72 53842 0 53390 27 16 11 20 0 8 0 amappl 80 5999 0 5949 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 73 0 6 2 0 2 2 0 8 0 uaddrrnd 24 1983 0 1967 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 1983 0 1967 1 0 1 1 0 8 0 vmmpekpl 168 16744 0 16710 2 0 2 2 0 8 0 vmmpepl 168 248172 0 246325 197 92 105 105 0 357 20 vmsppl 368 1982 0 1967 2 0 2 2 0 8 0 pdppl 4096 3973 0 3934 7 1 6 6 0 8 1 pvpl 32 576196 0 562360 250 85 165 172 0 265 33 pmappl 232 1982 0 1967 2 1 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 707 0 19 20 0 20 20 0 8 0