witness: lock order reversal: 1st 0xfffffd806e4bd808 inode (&ip->i_lock) 2nd 0xfffffd807d11e808 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(fffffd807d11e808,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807d11e808,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807d11e7f8) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800024db5780,1,ffff800020acf678) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa7c710,c0106477,ffff800024db5780,1,fffffd807f7c6b40,ffff800020acf678) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd806e88f268,c0106477,ffff800024db5780,ffff800020acf678) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020acf678,ffff800024db5898,ffff800024db5900) at sys_ioctl+0x5b8 syscall(ffff800024db5970) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800024db5970) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,21267fcf010) at Xsyscall+0x128 end of kernel end trace frame: 0x2154b50ec50, count: -9 ddb{0}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800024db5340 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff80002337c000 rax 0xffff800000a48b40 r8 0xffffffff81944fb5 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x3f5f338553970f38 r12 0xfffffd80029b8c00 r13 0 r14 0xffffffff82605be0 w_lodata+0x43e40 r15 0xffffffff826161d0 w_lodata+0x54430 rip 0xffffffff81ae7518 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800024db5330 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.0) pid=26574 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=76, nice=20 forw=0xffffffffffffffff, list=0xffff800020acfb68,0xffff800020acef20 process=0xffff800020a8b510 user=0xffff800024db0000, vmspace=0xfffffd807f00c000 estcpu=36, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 36217 339396 94711 0 7 0 syz-executor.0 *36217 26574 94711 0 7 0x4000000 syz-executor.0 36217 448093 94711 0 2 0x4000000 syz-executor.0 94145 118235 88918 0 2 0 syz-executor.1 94145 400726 88918 0 3 0x4000080 lockf syz-executor.1 94145 72044 88918 0 3 0x4000080 lockf syz-executor.1 94145 78842 88918 0 3 0x4000080 fsleep syz-executor.1 88918 333557 40147 0 3 0x82 nanosleep syz-executor.1 80684 78774 0 0 3 0x14200 acct acct 78541 626 1 0 3 0x100083 ttyin getty 94711 57917 40147 0 3 0x82 nanosleep syz-executor.0 9433 416185 0 0 3 0x14200 bored sosplice 40147 262931 43283 0 3 0x82 thrsleep syz-fuzzer 40147 442271 43283 0 3 0x4000082 thrsleep syz-fuzzer 40147 319292 43283 0 3 0x4000082 thrsleep syz-fuzzer 40147 316995 43283 0 3 0x4000082 thrsleep syz-fuzzer 40147 374401 43283 0 3 0x4000082 kqread syz-fuzzer 40147 66344 43283 0 3 0x4000082 thrsleep syz-fuzzer 40147 315273 43283 0 3 0x4000082 thrsleep syz-fuzzer 40147 165829 43283 0 3 0x4000082 thrsleep syz-fuzzer 40147 5811 43283 0 3 0x4000082 thrsleep syz-fuzzer 40147 461899 43283 0 3 0x4000082 thrsleep syz-fuzzer 43283 494947 72784 0 3 0x10008a pause ksh 72784 306807 63283 0 3 0x92 select sshd 63283 294315 1 0 3 0x80 select sshd 15951 90474 37493 74 3 0x100092 bpf pflogd 37493 354157 1 0 3 0x80 netio pflogd 57422 14197 73287 73 3 0x100090 kqread syslogd 73287 221732 1 0 3 0x100082 netio syslogd 94908 218103 1 77 3 0x100090 poll dhclient 59375 236951 1 0 3 0x80 poll dhclient 27058 10710 0 0 2 0x14200 zerothread 16781 81340 0 0 3 0x14200 aiodoned aiodoned 57432 500813 0 0 3 0x14200 syncer update 5235 397276 0 0 3 0x14200 cleaner cleaner 79988 131748 0 0 3 0x14200 reaper reaper 98879 286251 0 0 3 0x14200 pgdaemon pagedaemon 98387 96526 0 0 3 0x14200 bored crynlk 62508 105140 0 0 3 0x14200 bored crypto 83028 190094 0 0 3 0x40014200 acpi0 acpi0 47998 96826 0 0 3 0x40014200 idle1 99044 127482 0 0 3 0x14200 bored softnet 53317 185620 0 0 3 0x14200 bored systqmp 18825 233242 0 0 3 0x14200 bored systq 22872 365463 0 0 3 0x40014200 bored softclock 84782 447396 0 0 3 0x40014200 idle0 15077 163355 0 0 3 0x14200 bored smr 1 225169 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks Process 36217 (syz-executor.0) thread 0xffff800020acf678 (26574) exclusive rrwlock inode r = 0 (0xfffffd806e4bd808) #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 9561 7095K 14651K 78643K 17474 0 0 pcb 13 8K 8K 78643K 288 0 0 rtable 111 4K 5K 78643K 1020 0 0 ifaddr 71 16K 17K 78643K 331 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1631 0 0 iov 0 0K 16K 78643K 231 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1213 76K 77K 78643K 3804 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 45 0 0 VM map 2 1K 1K 78643K 4 0 0 sem 12 0K 1K 78643K 299 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 6 17K 25K 78643K 2842 0 0 sigio 0 0K 0K 78643K 15 0 0 proc 54 51K 83K 78643K 1108 0 0 subproc 32 2K 2K 78643K 187 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 225 0 0 in_multi 33 2K 2K 78643K 205 0 0 ether_multi 1 0K 0K 78643K 7 0 0 mrt 0 0K 0K 78643K 8 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 546 0 0 pfkey data 0 0K 4K 78643K 2 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 113 22K 31K 78643K 9958 0 0 UVM aobj 116 6K 6K 78643K 128 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 285 0 0 NDP 16 0K 0K 78643K 102 0 0 temp 201 3556K 4196K 78643K 41960 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 24 0 18 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 159 0 157 1 0 1 1 0 8 0 rtentry 112 146 0 102 2 0 2 2 0 8 0 unpcb 120 875 0 865 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 9700 0 9700 1 1 0 1 0 8 0 tcpcb 544 547 0 543 1 0 1 1 0 8 0 inpcb 280 1562 0 1555 2 1 1 2 0 8 0 ip6q 72 2 0 1 2 1 1 1 0 8 0 ip6af 48 1 0 0 1 0 1 1 0 8 0 nd6 48 33 0 27 1 0 1 1 0 8 0 pkpcb 40 12 0 12 5 4 1 1 0 8 1 ppxss 1128 41 0 41 8 7 1 1 0 8 1 pffrag 232 1 0 1 1 1 0 1 0 482 0 pffrnode 88 1 0 1 1 1 0 1 0 8 0 pffrent 40 2 0 2 1 1 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 91 0 62 1 0 1 1 0 8 0 pfstkey 112 92 0 63 2 0 2 2 0 8 0 pfstate 328 92 0 63 4 0 4 4 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 608 0 414 13 0 13 13 0 8 0 art_table 32 609 0 414 2 0 2 2 0 8 0 art_node 16 143 0 103 1 0 1 1 0 8 0 sysvmsgpl 40 18 0 13 3 2 1 1 0 8 0 semapl 112 297 0 287 1 0 1 1 0 8 0 shmpl 112 126 0 12 4 0 4 4 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 5947 0 4521 47 0 47 47 0 8 0 ffsino 272 5947 0 4521 96 0 96 96 0 8 0 nchpl 144 10067 0 8430 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 32214 0 32214 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 vmpool 552 2 0 2 1 1 0 1 0 8 0 scsiplug 64 3 0 3 2 2 0 1 0 8 0 scxspl 192 28172 0 28172 11 10 1 6 0 8 1 plimitpl 152 284 0 276 1 0 1 1 0 8 0 sigapl 432 3019 0 3003 3 1 2 3 0 8 0 futexpl 56 35402 0 35401 1 0 1 1 0 8 0 knotepl 112 586 0 567 1 0 1 1 0 8 0 kqueuepl 104 482 0 480 1 0 1 1 0 8 0 pipepl 112 1604 0 1585 3 2 1 2 0 8 0 fdescpl 488 3020 0 3003 3 0 3 3 0 8 0 filepl 152 17241 0 17138 8 3 5 6 0 8 0 lockfpl 104 1132 0 1128 3 2 1 1 0 8 0 lockfspl 48 365 0 364 3 2 1 1 0 8 0 sessionpl 112 31 0 20 1 0 1 1 0 8 0 pgrppl 48 58 0 47 1 0 1 1 0 8 0 ucredpl 96 3137 0 3128 1 0 1 1 0 8 0 zombiepl 144 3003 0 3003 2 1 1 1 0 8 1 processpl 896 3037 0 3003 4 0 4 4 0 8 0 procpl 632 8723 0 8675 9 4 5 5 0 8 0 srpgc 64 18 0 18 6 5 1 1 0 8 1 sosppl 128 33 0 33 9 8 1 1 0 8 1 sockpl 384 2643 0 2624 7 4 3 4 0 8 1 mcl64k 65536 17 0 0 3 0 3 3 0 8 0 mcl16k 16384 6 0 0 1 0 1 1 0 8 0 mcl12k 12288 17 0 0 2 0 2 2 0 8 0 mcl9k 9216 16 0 0 2 0 2 2 0 8 0 mcl8k 8192 16 0 0 2 0 2 2 0 8 0 mcl4k 4096 12 0 0 2 0 2 2 0 8 0 mcl2k2 2112 6 0 0 1 0 1 1 0 8 0 mcl2k 2048 163 0 0 20 2 18 20 0 8 0 mtagpl 80 44 0 0 1 0 1 1 0 8 0 mbufpl 256 275 0 0 13 1 12 13 0 8 0 bufpl 256 12222 0 5203 439 0 439 439 0 8 0 anonpl 16 273916 0 261882 119 65 54 68 0 124 0 amapchunkpl 152 17477 0 17344 25 19 6 10 0 158 0 amappl16 192 13952 0 13258 82 45 37 47 0 8 1 amappl15 184 198 0 198 2 2 0 1 0 8 0 amappl14 176 562 0 557 1 0 1 1 0 8 0 amappl13 168 934 0 930 2 1 1 1 0 8 0 amappl12 160 11 0 9 2 1 1 1 0 8 0 amappl11 152 251 0 236 1 0 1 1 0 8 0 amappl10 144 108 0 102 1 0 1 1 0 8 0 amappl9 136 1867 0 1864 1 0 1 1 0 8 0 amappl8 128 1431 0 1404 2 0 2 2 0 8 0 amappl7 120 75 0 67 1 0 1 1 0 8 0 amappl6 112 219 0 211 1 0 1 1 0 8 0 amappl5 104 218 0 202 1 0 1 1 0 8 0 amappl4 96 3111 0 3078 2 1 1 2 0 8 0 amappl3 88 945 0 935 1 0 1 1 0 8 0 amappl2 80 22862 0 22780 3 1 2 3 0 8 0 amappl1 72 74296 0 73828 25 15 10 20 0 8 0 amappl 80 9128 0 9081 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 127 0 12 2 0 2 2 0 8 0 uaddrrnd 24 3022 0 3003 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 3022 0 3003 1 0 1 1 0 8 0 vmmpekpl 168 23118 0 23082 2 0 2 2 0 8 0 vmmpepl 168 370319 0 368365 190 85 105 105 0 357 20 vmsppl 368 3019 0 3003 2 0 2 2 0 8 0 pdppl 4096 6051 0 6010 7 1 6 6 0 8 0 pvpl 32 760548 0 745227 267 135 132 170 0 265 0 pmappl 232 3021 0 3005 3 2 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