witness: lock order reversal: 1st 0xfffffd8074b52d68 inode (&ip->i_lock) 2nd 0xfffffd806e65c438 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(fffffd806e65c438,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd806e65c438,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd806e65c428) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800022badcf0,1,ffff800020abeee8) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa70648,c0106477,ffff800022badcf0,1,fffffd807f7c66c0,ffff800020abeee8) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd807d69eed8,c0106477,ffff800022badcf0,ffff800020abeee8) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020abeee8,ffff800022bade08,ffff800022bade70) at sys_ioctl+0x5b8 syscall(ffff800022badee0) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800022badee0) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,ae8a7c641b0) at Xsyscall+0x128 end of kernel end trace frame: 0xaeb5dc1f4e0, count: -9 ddb{0}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800022bad8b0 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800021b5e000 rax 0xffff800000a87ac0 r8 0xffffffff81ca8c05 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xc4c2a939fa57000b r12 0xfffffd80029b9c00 r13 0 r14 0xffffffff825fc060 w_lodata+0x36920 r15 0xffffffff82619b70 w_lodata+0x54430 rip 0xffffffff81f62b28 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800022bad8a0 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.0) pid=31977 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=80, nice=20 forw=0xffffffffffffffff, list=0xffff800020abf8c8,0xffff800020abe2a0 process=0xffff800020a8ae10 user=0xffff800022ba8000, vmspace=0xfffffd807f00c5c0 estcpu=30, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 97127 499946 20777 0 7 0x1 syz-executor.0 97127 416389 20777 0 3 0x4000080 fsleep syz-executor.0 97127 367167 20777 0 3 0x4000080 fsleep syz-executor.0 *97127 31977 20777 0 7 0x4000000 syz-executor.0 97127 354096 20777 0 2 0x4000080 syz-executor.0 26619 62368 67529 0 3 0x82 piperd syz-executor.1 20777 61482 67529 0 3 0x82 nanosleep syz-executor.0 39366 506781 1 0 3 0x100083 ttyin getty 63859 97576 0 0 3 0x14200 acct acct 62143 171965 0 0 3 0x14200 bored sosplice 67529 292848 59222 0 3 0x82 thrsleep syz-fuzzer 67529 419952 59222 0 3 0x4000082 thrsleep syz-fuzzer 67529 347600 59222 0 3 0x4000082 thrsleep syz-fuzzer 67529 372032 59222 0 3 0x4000082 thrsleep syz-fuzzer 67529 274000 59222 0 3 0x4000082 thrsleep syz-fuzzer 67529 97318 59222 0 3 0x4000082 thrsleep syz-fuzzer 67529 163203 59222 0 3 0x4000082 thrsleep syz-fuzzer 67529 383727 59222 0 3 0x4000082 thrsleep syz-fuzzer 67529 187823 59222 0 3 0x4000082 kqread syz-fuzzer 67529 28864 59222 0 3 0x4000082 thrsleep syz-fuzzer 59222 342858 8555 0 3 0x10008a pause ksh 8555 125030 68919 0 3 0x92 select sshd 68919 324451 1 0 3 0x80 select sshd 8371 432779 28266 74 3 0x100092 bpf pflogd 28266 196190 1 0 3 0x80 netio pflogd 82804 165281 92240 73 3 0x100090 kqread syslogd 92240 252387 1 0 3 0x100082 netio syslogd 61762 156616 1 77 3 0x100090 poll dhclient 60282 429901 1 0 3 0x80 poll dhclient 94849 508985 0 0 3 0x14200 pgzero zerothread 58403 488811 0 0 3 0x14200 aiodoned aiodoned 83986 239144 0 0 3 0x14200 syncer update 59736 510149 0 0 3 0x14200 cleaner cleaner 24858 367969 0 0 3 0x14200 reaper reaper 55316 314906 0 0 3 0x14200 pgdaemon pagedaemon 18309 417867 0 0 3 0x14200 bored crynlk 79991 182199 0 0 3 0x14200 bored crypto 15065 399092 0 0 3 0x40014200 acpi0 acpi0 63197 394265 0 0 3 0x40014200 idle1 46446 20857 0 0 3 0x14200 bored softnet 58394 70686 0 0 3 0x14200 bored systqmp 41946 1607 0 0 3 0x14200 bored systq 68072 475721 0 0 3 0x40014200 bored softclock 80725 278485 0 0 3 0x40014200 idle0 80286 454115 0 0 3 0x14200 bored smr 1 414668 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks Process 97127 (syz-executor.0) thread 0xffff800020abeee8 (31977) exclusive rrwlock inode r = 0 (0xfffffd8074b52d68) #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 (0xffffffff8266bbe8) #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 9639 6491K 14684K 78643K 67915 0 0 pcb 13 8K 8K 78643K 1838 0 0 rtable 119 13K 13K 78643K 7086 0 0 ifaddr 97 29K 37K 78643K 2356 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 2654 0 0 iov 0 0K 32K 78643K 2306 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1196 75K 77K 78643K 22733 0 0 UFS quota 1 32K 32K 78643K 1 0 0 UFS mount 5 36K 36K 78643K 5 0 0 shm 2 1K 9K 78643K 329 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 0K 78643K 2720 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 23386 0 0 sigio 0 0K 0K 78643K 298 0 0 proc 55 51K 83K 78643K 5781 0 0 subproc 32 2K 2K 78643K 1328 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 2057 0 0 in_multi 33 2K 2K 78643K 1605 0 0 ether_multi 1 0K 0K 78643K 99 0 0 mrt 0 0K 0K 78643K 81 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 120 530K 530K 78643K 120 0 0 exec 0 0K 1K 78643K 3099 0 0 pfkey data 0 0K 0K 78643K 7 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 30K 78643K 75408 0 0 UVM aobj 130 7K 7K 78643K 155 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 1751 0 0 NDP 24 0K 1K 78643K 755 0 0 temp 257 3557K 4197K 78643K 326681 0 0 kqueue 0 0K 0K 78643K 173 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 167 0 161 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 964 0 962 1 0 1 1 0 8 0 rtentry 112 918 0 874 3 1 2 2 0 8 0 unpcb 120 7095 0 7085 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 8562 0 8562 1 1 0 1 0 8 0 tcpcb 544 3936 0 3932 1 0 1 1 0 8 0 inpcb 280 11496 0 11489 12 11 1 2 0 8 0 rttmr 72 12 0 12 10 9 1 1 0 8 1 ip6q 72 4 0 4 3 3 0 1 0 8 0 ip6af 48 7 0 7 3 3 0 1 0 8 0 nd6 48 231 0 225 1 0 1 1 0 8 0 pkpcb 40 92 0 92 32 32 0 1 0 8 0 swfcl 56 17 0 0 1 0 1 1 0 8 0 ppxss 1128 411 0 410 40 39 1 1 0 8 0 pffrag 232 46 0 46 25 25 0 1 0 482 0 pffrnode 88 46 0 46 25 25 0 1 0 8 0 pffrent 40 123 0 123 26 26 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 624 0 597 1 0 1 1 0 8 0 pfstkey 112 624 0 597 3 1 2 2 0 8 0 pfstate 328 624 0 597 10 5 5 5 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 3674 0 3476 29 16 13 13 0 8 0 art_table 32 3675 0 3476 2 0 2 2 0 8 0 art_node 16 892 0 852 1 0 1 1 0 8 0 sysvmsgpl 40 28 0 26 2 1 1 1 0 8 0 semupl 112 1 0 1 1 1 0 1 0 8 0 semapl 112 2718 0 2708 1 0 1 1 0 8 0 shmpl 112 153 0 25 4 0 4 4 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 37527 0 36043 50 1 49 49 0 8 0 ffsino 272 37527 0 36043 102 2 100 100 0 8 0 nchpl 144 70063 0 68426 62 0 62 62 0 8 0 uvmvnodes 72 8276 0 0 151 0 151 151 0 8 0 vnodes 200 8276 0 0 436 0 436 436 0 8 0 namei 1024 234927 0 234927 6 5 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 50 0 50 33 32 1 1 0 8 1 scxspl 192 208026 0 208026 100 99 1 7 0 8 1 plimitpl 152 2182 0 2174 1 0 1 1 0 8 0 sigapl 432 23376 0 23361 4 2 2 3 0 8 0 futexpl 56 296836 0 296834 4 3 1 1 0 8 0 knotepl 112 5046 0 5027 1 0 1 1 0 8 0 kqueuepl 104 4593 0 4591 1 0 1 1 0 8 0 pipepl 112 12482 0 12463 20 19 1 2 0 8 0 fdescpl 488 23377 0 23361 3 0 3 3 0 8 0 filepl 152 138516 0 138410 33 28 5 7 0 8 0 lockfpl 104 7542 0 7542 8 7 1 1 0 8 1 lockfspl 48 2543 0 2543 8 7 1 1 0 8 1 sessionpl 112 108 0 97 1 0 1 1 0 8 0 pgrppl 48 350 0 339 1 0 1 1 0 8 0 ucredpl 96 28214 0 28203 1 0 1 1 0 8 0 zombiepl 144 23364 0 23364 5 4 1 1 0 8 1 processpl 896 23397 0 23364 5 1 4 5 0 8 0 procpl 632 70665 0 70619 28 23 5 5 0 8 1 srpgc 64 162 0 162 61 60 1 1 0 8 1 sosppl 128 258 0 258 55 54 1 1 0 8 1 sockpl 384 19891 0 19872 23 20 3 4 0 8 1 mcl64k 65536 473 0 0 57 54 3 34 0 8 0 mcl16k 16384 25 0 0 4 1 3 3 0 8 0 mcl12k 12288 96 0 0 3 1 2 2 0 8 0 mcl9k 9216 89 0 0 4 2 2 2 0 8 0 mcl8k 8192 25 0 0 3 0 3 3 0 8 0 mcl4k 4096 25 0 0 3 0 3 3 0 8 0 mcl2k2 2112 14 0 0 1 0 1 1 0 8 0 mcl2k 2048 174 0 0 15 6 9 15 0 8 0 mtagpl 80 150 0 0 1 0 1 1 0 8 0 mbufpl 256 1356 0 0 34 6 28 29 0 8 2 bufpl 256 66048 0 57770 518 0 518 518 0 8 0 anonpl 16 2074982 0 2064665 393 332 61 68 0 124 0 amapchunkpl 152 136221 0 136108 87 79 8 19 0 158 1 amappl16 192 116505 0 115774 526 485 41 50 0 8 2 amappl15 184 4429 0 4429 10 10 0 1 0 8 0 amappl14 176 3919 0 3914 1 0 1 1 0 8 0 amappl13 168 3707 0 3705 1 0 1 1 0 8 0 amappl12 160 3273 0 3271 9 8 1 1 0 8 0 amappl11 152 4310 0 4295 1 0 1 1 0 8 0 amappl10 144 1316 0 1311 1 0 1 1 0 8 0 amappl9 136 4628 0 4625 1 0 1 1 0 8 0 amappl8 128 3970 0 3937 5 3 2 2 0 8 0 amappl7 120 1442 0 1434 1 0 1 1 0 8 0 amappl6 112 4125 0 4114 1 0 1 1 0 8 0 amappl5 104 4077 0 4061 1 0 1 1 0 8 0 amappl4 96 22211 0 22175 2 1 1 2 0 8 0 amappl3 88 6950 0 6940 1 0 1 1 0 8 0 amappl2 80 186305 0 186234 3 1 2 3 0 8 0 amappl1 72 507385 0 506939 25 15 10 19 0 8 0 amappl 80 72320 0 72280 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 154 0 25 3 0 3 3 0 8 0 uaddrrnd 24 23377 0 23361 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 23377 0 23361 1 0 1 1 0 8 0 vmmpekpl 168 182473 0 182441 2 0 2 2 0 8 0 vmmpepl 168 2833976 0 2832094 841 732 109 123 0 357 20 vmsppl 368 23376 0 23361 2 0 2 2 0 8 0 pdppl 4096 46761 0 46722 7 1 6 6 0 8 0 pvpl 32 5524833 0 5511201 907 761 146 171 0 265 7 pmappl 232 23376 0 23361 6 5 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 789 0 94 20 0 20 20 0 8 0