witness: lock order reversal: 1st 0xfffffd806e69a808 inode (&ip->i_lock) 2nd 0xfffffd807a1229f0 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+0xd1 sys/kern/kern_rwlock.c:247 #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(fffffd807a1229f0,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807a1229f0,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter(fffffd807a1229e0,1) at rw_enter+0xd1 sys/kern/kern_rwlock.c:247 diskmapioctl(5a00,c0106477,ffff800021b57850,1,ffff800020ab0780) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa7c260,c0106477,ffff800021b57850,1,fffffd807f7c6900,ffff800020ab0780) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd8065d01ef8,c0106477,ffff800021b57850,ffff800020ab0780) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020ab0780,ffff800021b57968,ffff800021b579d0) at sys_ioctl+0x5b8 syscall(ffff800021b57a40) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800021b57a40) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,b5996274010) at Xsyscall+0x128 end of kernel end trace frame: 0xb5b97f824b0, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800021b57390 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff800022570000 rax 0xffff800000a8f3c0 r8 0xffffffff8157a035 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x4a9629e157bf7cc5 r12 0xfffffd80029bac00 r13 0 r14 0xffffffff825ac600 w_lodata+0x3fc40 r15 0xffffffff825c0a80 w_lodata+0x540c0 rip 0xffffffff810d7398 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800021b57380 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.1) pid=188641 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=78, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab0018,0xffff800020ab1170 process=0xffff800020a8b890 user=0xffff800021b52000, vmspace=0xfffffd807f00b000 estcpu=36, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 89826 465424 85862 0 2 0 syz-executor.0 89826 56482 85862 0 7 0x4000000 syz-executor.0 89826 306674 85862 0 3 0x4000080 fsleep syz-executor.0 16136 442352 31841 0 2 0 syz-executor.1 *16136 188641 31841 0 7 0x4000000 syz-executor.1 16136 509046 31841 0 3 0x4000080 fsleep syz-executor.1 16136 40698 31841 0 3 0x4000000 inode syz-executor.1 31841 142667 21949 0 3 0x82 nanosleep syz-executor.1 85862 513873 21949 0 3 0x82 nanosleep syz-executor.0 71730 439697 0 0 3 0x14200 acct acct 92857 361844 1 0 3 0x100083 ttyin getty 24864 412469 0 0 3 0x14200 bored sosplice 21949 58014 22132 0 3 0x82 thrsleep syz-fuzzer 21949 283452 22132 0 3 0x4000082 thrsleep syz-fuzzer 21949 142636 22132 0 3 0x4000082 thrsleep syz-fuzzer 21949 488486 22132 0 3 0x4000082 kqread syz-fuzzer 21949 133597 22132 0 3 0x4000082 thrsleep syz-fuzzer 21949 231007 22132 0 3 0x4000082 thrsleep syz-fuzzer 21949 44067 22132 0 3 0x4000082 thrsleep syz-fuzzer 21949 70275 22132 0 3 0x4000082 thrsleep syz-fuzzer 21949 369408 22132 0 3 0x4000082 thrsleep syz-fuzzer 21949 181263 22132 0 3 0x4000082 thrsleep syz-fuzzer 22132 357793 38113 0 3 0x10008a pause ksh 38113 163461 88317 0 3 0x92 select sshd 88317 73724 1 0 3 0x80 select sshd 33199 285655 15145 74 3 0x100092 bpf pflogd 15145 302596 1 0 3 0x80 netio pflogd 93063 199382 81486 73 3 0x100090 kqread syslogd 81486 296264 1 0 3 0x100082 netio syslogd 5188 445862 1 77 3 0x100090 poll dhclient 56549 426021 1 0 3 0x80 poll dhclient 38758 414918 0 0 2 0x14200 zerothread 95748 84346 0 0 3 0x14200 aiodoned aiodoned 43104 324146 0 0 3 0x14200 syncer update 62361 27436 0 0 3 0x14200 cleaner cleaner 97833 376753 0 0 3 0x14200 reaper reaper 36825 245271 0 0 3 0x14200 pgdaemon pagedaemon 16222 470420 0 0 3 0x14200 bored crynlk 23501 4853 0 0 3 0x14200 bored crypto 80452 432637 0 0 3 0x40014200 acpi0 acpi0 82879 36711 0 0 3 0x40014200 idle1 93545 42238 0 0 3 0x14200 bored softnet 82868 462750 0 0 3 0x14200 bored systqmp 81882 144738 0 0 3 0x14200 bored systq 84724 363776 0 0 3 0x40014200 bored softclock 34187 116932 0 0 3 0x40014200 idle0 90421 107842 0 0 3 0x14200 bored smr 1 94837 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 89826 (syz-executor.0) thread 0xffff800020ab0c70 (56482) exclusive rrwlock inode r = 0 (0xfffffd807ec52e68) #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 vfs_lookup+0xec sys/kern/vfs_lookup.c:418 #6 namei+0x61c sys/kern/vfs_lookup.c:248 #7 vn_open+0xb8 sys/kern/vfs_vnops.c:137 #8 doopenat+0x28e sys/kern/vfs_syscalls.c:1157 #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 Process 16136 (syz-executor.1) thread 0xffff800020ab0780 (188641) exclusive rrwlock inode r = 0 (0xfffffd806e69a808) #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 (0xffffffff8262ca18) #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 Process 16136 (syz-executor.1) thread 0xffff800020a5fb30 (40698) exclusive rwlock fdlock r = 0 (0xfffffd807a1229f0) #0 witness_lock+0x52e sys/kern/subr_witness.c:1163 #1 ptmioctl+0xe7 sys/kern/tty_pty.c:1071 #2 VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 #3 vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 #4 sys_ioctl+0x5b8 #5 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] #5 syscall+0x552 sys/arch/amd64/amd64/trap.c:555 #6 Xsyscall+0x128 ddb{1}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9602 6468K 7290K 78643K 23116 0 0 pcb 13 8K 8K 78643K 501 0 0 rtable 111 4K 5K 78643K 2057 0 0 ifaddr 84 19K 20K 78643K 726 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1719 0 0 iov 0 0K 28K 78643K 518 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1201 75K 77K 78643K 5962 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 84 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 1K 1K 78643K 570 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 6 17K 25K 78643K 5359 0 0 sigio 0 0K 0K 78643K 52 0 0 proc 55 51K 83K 78643K 1671 0 0 subproc 32 2K 2K 78643K 361 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 453 0 0 in_multi 33 2K 2K 78643K 396 0 0 ether_multi 1 0K 0K 78643K 28 0 0 mrt 0 0K 0K 78643K 19 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 108 477K 477K 78643K 108 0 0 exec 0 0K 1K 78643K 870 0 0 pfkey data 0 0K 0K 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 120 22K 31K 78643K 18105 0 0 UVM aobj 130 7K 7K 78643K 144 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 436 0 0 NDP 20 0K 0K 78643K 224 0 0 temp 229 3557K 3629K 78643K 63999 0 0 kqueue 0 0K 0K 78643K 49 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 49 0 43 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 244 0 242 1 0 1 1 0 8 0 rtentry 112 265 0 221 2 0 2 2 0 8 0 unpcb 120 1828 0 1818 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 10022 0 10022 2 2 0 1 0 8 0 tcpcb 544 930 0 926 1 0 1 1 0 8 0 inpcb 280 2720 0 2713 5 4 1 2 0 8 0 rttmr 72 3 0 3 2 2 0 1 0 8 0 ip6q 72 1 0 0 1 0 1 1 0 8 0 ip6af 48 1 0 0 1 0 1 1 0 8 0 nd6 48 63 0 57 1 0 1 1 0 8 0 pkpcb 40 22 0 22 10 10 0 1 0 8 0 swfcl 56 4 0 0 1 0 1 1 0 8 0 ppxss 1128 116 0 116 12 11 1 1 0 8 1 pffrag 232 9 0 9 5 5 0 1 0 482 0 pffrnode 88 9 0 9 5 5 0 1 0 8 0 pffrent 40 20 0 20 5 5 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 137 0 118 1 0 1 1 0 8 0 pfstkey 112 137 0 118 1 0 1 1 0 8 0 pfstate 328 137 0 118 3 1 2 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 1098 0 907 16 3 13 13 0 8 0 art_table 32 1099 0 907 2 0 2 2 0 8 0 art_node 16 261 0 221 1 0 1 1 0 8 0 sysvmsgpl 40 12 0 6 2 1 1 1 0 8 0 semupl 112 5 0 5 1 1 0 1 0 8 0 semapl 112 564 0 554 1 0 1 1 0 8 0 shmpl 112 142 0 14 4 0 4 4 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 9544 0 8123 47 0 47 47 0 8 0 ffsino 272 9544 0 8123 96 0 96 96 0 8 0 nchpl 144 17062 0 15429 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 56080 0 56078 4 3 1 1 0 8 0 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 14 0 14 9 8 1 1 0 8 1 scxspl 192 49658 0 49658 28 27 1 7 0 8 1 plimitpl 152 540 0 531 1 0 1 1 0 8 0 sigapl 432 5504 0 5488 3 1 2 3 0 8 0 futexpl 56 65869 0 65867 1 0 1 1 0 8 0 knotepl 112 1242 0 1223 1 0 1 1 0 8 0 kqueuepl 104 1067 0 1065 1 0 1 1 0 8 0 pipepl 112 3028 0 3009 6 5 1 2 0 8 0 fdescpl 488 5505 0 5488 3 0 3 3 0 8 0 filepl 152 32450 0 32345 14 9 5 7 0 8 0 lockfpl 104 1757 0 1756 3 2 1 1 0 8 0 lockfspl 48 582 0 581 3 2 1 1 0 8 0 sessionpl 112 39 0 28 1 0 1 1 0 8 0 pgrppl 48 99 0 88 1 0 1 1 0 8 0 ucredpl 96 6607 0 6597 1 0 1 1 0 8 0 zombiepl 144 5488 0 5488 3 2 1 1 0 8 1 processpl 896 5522 0 5488 4 0 4 4 0 8 0 procpl 632 16360 0 16312 9 4 5 5 0 8 1 srpgc 64 41 0 41 14 14 0 1 0 8 0 sosppl 128 62 0 62 16 15 1 1 0 8 1 sockpl 384 4889 0 4870 11 8 3 4 0 8 1 mcl64k 65536 265 0 0 33 0 33 33 0 8 1 mcl16k 16384 7 0 0 1 0 1 1 0 8 0 mcl12k 12288 19 0 0 2 0 2 2 0 8 0 mcl9k 9216 29 0 0 2 1 1 2 0 8 0 mcl8k 8192 25 0 0 4 1 3 3 0 8 0 mcl4k 4096 23 0 0 3 1 2 3 0 8 0 mcl2k2 2112 12 0 0 1 0 1 1 0 8 0 mcl2k 2048 128 0 0 15 0 15 15 0 8 0 mtagpl 80 41 0 0 1 0 1 1 0 8 0 mbufpl 256 576 0 0 23 0 23 23 0 8 0 bufpl 256 20630 0 13611 439 0 439 439 0 8 0 anonpl 16 502940 0 490392 152 86 66 67 0 124 9 amapchunkpl 152 34061 0 33921 65 56 9 20 0 158 1 amappl16 192 26041 0 25371 146 104 42 46 0 8 8 amappl15 184 1450 0 1450 1 1 0 1 0 8 0 amappl14 176 1113 0 1109 1 0 1 1 0 8 0 amappl13 168 854 0 854 4 4 0 1 0 8 0 amappl12 160 296 0 291 1 0 1 1 0 8 0 amappl11 152 474 0 459 1 0 1 1 0 8 0 amappl10 144 665 0 659 1 0 1 1 0 8 0 amappl9 136 1940 0 1936 1 0 1 1 0 8 0 amappl8 128 1460 0 1426 3 1 2 2 0 8 0 amappl7 120 661 0 652 1 0 1 1 0 8 0 amappl6 112 424 0 414 1 0 1 1 0 8 0 amappl5 104 561 0 545 1 0 1 1 0 8 0 amappl4 96 5764 0 5732 2 1 1 2 0 8 0 amappl3 88 1726 0 1716 1 0 1 1 0 8 0 amappl2 80 43258 0 43177 3 1 2 3 0 8 0 amappl1 72 126832 0 126366 25 15 10 20 0 8 0 amappl 80 16960 0 16911 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 143 0 14 3 0 3 3 0 8 0 uaddrrnd 24 5505 0 5488 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 5505 0 5488 1 0 1 1 0 8 0 vmmpekpl 168 46024 0 45988 2 0 2 2 0 8 0 vmmpepl 168 674154 0 672210 265 167 98 104 0 357 12 vmsppl 368 5504 0 5488 2 0 2 2 0 8 0 pdppl 4096 11017 0 10976 7 1 6 6 0 8 0 pvpl 32 1362242 0 1346357 342 179 163 167 0 265 31 pmappl 232 5504 0 5488 2 1 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 652 0 12 19 0 19 19 0 8 0