witness: lock order reversal: 1st 0xfffffd807e88e3d8 inode (&ip->i_lock) 2nd 0xfffffd807e14fbd8 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(fffffd807e14fbd8,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807e14fbd8,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807e14fbc8) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff800021da1650,1,ffff800020ab13d8) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa82580,c0106477,ffff800021da1650,1,fffffd807f7c66c0,ffff800020ab13d8) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd807e937e58,c0106477,ffff800021da1650,ffff800020ab13d8) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020ab13d8,ffff800021da1768,ffff800021da17d0) at sys_ioctl+0x5b8 syscall(ffff800021da1840) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff800021da1840) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,5e27227f010) at Xsyscall+0x128 end of kernel end trace frame: 0x5e55a464700, count: -9 ddb{1}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff800021da1210 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff80002117e000 rax 0xffff800000a44980 r8 0xffffffff8187b235 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x27d273ab366942bf r12 0xfffffd80029b6c00 r13 0 r14 0xffffffff825b72a0 w_lodata+0x41ea0 r15 0xffffffff825c9990 w_lodata+0x54590 rip 0xffffffff81b977e8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800021da1200 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.0) pid=192851 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=83, nice=20 forw=0xffffffffffffffff, list=0xffff800020ab09f8,0xffff800020ab1170 process=0xffff800020a4bc08 user=0xffff800021d9c000, vmspace=0xfffffd807f00cb80 estcpu=36, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 74541 162275 94187 0 7 0 syz-executor.0 *74541 192851 94187 0 7 0x4000000 syz-executor.0 74541 216433 94187 0 2 0x4000000 syz-executor.0 61049 49276 49888 0 2 0 syz-executor.1 61049 117276 49888 0 3 0x4000080 ttyout syz-executor.1 61049 225796 49888 0 3 0x4000080 fsleep syz-executor.1 94187 120615 19218 0 3 0x82 nanosleep syz-executor.0 49888 305670 19218 0 3 0x82 nanosleep syz-executor.1 62858 41358 1 0 3 0x100083 ttyopn getty 30278 44695 0 0 3 0x14200 bored sosplice 19218 314829 66787 0 3 0x82 thrsleep syz-fuzzer 19218 79967 66787 0 3 0x4000082 thrsleep syz-fuzzer 19218 228617 66787 0 3 0x4000082 thrsleep syz-fuzzer 19218 313867 66787 0 3 0x4000082 thrsleep syz-fuzzer 19218 354892 66787 0 3 0x4000082 thrsleep syz-fuzzer 19218 20479 66787 0 3 0x4000082 thrsleep syz-fuzzer 19218 152967 66787 0 3 0x4000082 thrsleep syz-fuzzer 19218 374932 66787 0 3 0x4000082 thrsleep syz-fuzzer 19218 27608 66787 0 3 0x4000082 kqread syz-fuzzer 19218 332286 66787 0 3 0x4000082 thrsleep syz-fuzzer 66787 211620 76113 0 3 0x10008a pause ksh 76113 406846 52418 0 3 0x92 select sshd 52418 90423 1 0 3 0x80 select sshd 87674 79905 95407 74 3 0x100092 bpf pflogd 95407 332894 1 0 3 0x80 netio pflogd 8861 295419 12592 73 3 0x100090 kqread syslogd 12592 101226 1 0 3 0x100082 netio syslogd 92242 374897 1 77 3 0x100090 poll dhclient 35723 215043 1 0 3 0x80 poll dhclient 90514 35936 0 0 2 0x14200 zerothread 16392 55028 0 0 3 0x14200 aiodoned aiodoned 16589 224036 0 0 3 0x14200 syncer update 6247 401763 0 0 3 0x14200 cleaner cleaner 77863 336511 0 0 3 0x14200 reaper reaper 2762 311146 0 0 3 0x14200 pgdaemon pagedaemon 68602 282760 0 0 3 0x14200 bored crynlk 31933 177419 0 0 3 0x14200 bored crypto 70874 431374 0 0 3 0x40014200 acpi0 acpi0 65839 229226 0 0 3 0x40014200 idle1 7344 509014 0 0 3 0x14200 bored softnet 95097 266830 0 0 3 0x14200 bored systqmp 4954 478223 0 0 3 0x14200 bored systq 23901 67885 0 0 3 0x40014200 bored softclock 57310 369266 0 0 3 0x40014200 idle0 657 79109 0 0 3 0x14200 bored smr 1 278214 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks Process 74541 (syz-executor.0) thread 0xffff800020ab13d8 (192851) exclusive rrwlock inode r = 0 (0xfffffd807e88e3d8) #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 (0xffffffff826648e0) #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 9569 7076K 7728K 78643K 19989 0 0 pcb 13 8K 8K 78643K 240 0 0 rtable 115 12K 13K 78643K 1326 0 0 ifaddr 79 19K 21K 78643K 476 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1553 0 0 iov 0 0K 28K 78643K 267 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1211 76K 77K 78643K 5225 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 61 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 1K 1K 78643K 12 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 6 17K 25K 78643K 5230 0 0 sigio 0 0K 0K 78643K 101 0 0 proc 54 51K 83K 78643K 1084 0 0 subproc 32 2K 2K 78643K 172 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 471 0 0 in_multi 33 2K 2K 78643K 360 0 0 ether_multi 1 0K 0K 78643K 21 0 0 mrt 0 0K 0K 78643K 20 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 648 0 0 pfkey data 0 0K 4K 78643K 5 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 111 22K 39K 78643K 14222 0 0 UVM aobj 86 3K 3K 78643K 88 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 240 0 0 NDP 18 0K 0K 78643K 149 0 0 temp 216 3544K 4180K 78643K 28572 0 0 kqueue 0 0K 0K 78643K 29 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 22 0 16 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 157 0 155 1 0 1 1 0 8 0 rtentry 112 142 0 98 3 1 2 2 0 8 0 unpcb 120 921 0 911 1 0 1 1 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 sackhl 24 1 0 1 1 1 0 1 0 8 0 tcpqe 32 16 0 16 3 3 0 1 0 8 0 tcpcb 544 732 0 728 1 0 1 1 0 8 0 inpcb 280 1852 0 1845 1 0 1 1 0 8 0 rttmr 72 6 0 6 1 1 0 1 0 8 0 nd6 48 30 0 24 1 0 1 1 0 8 0 pkpcb 40 46 0 46 8 7 1 1 0 8 1 swfcl 56 12 0 0 1 0 1 1 0 8 0 ppxss 1128 90 0 89 2 1 1 1 0 8 0 pffrag 232 11 0 11 5 5 0 1 0 482 0 pffrnode 88 11 0 11 5 5 0 1 0 8 0 pffrent 40 37 0 37 6 5 1 1 0 8 1 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 145 0 122 1 0 1 1 0 8 0 pfstkey 112 145 0 122 2 0 2 2 0 8 0 pfstate 328 145 0 122 7 3 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 650 0 455 18 5 13 14 0 8 0 art_table 32 651 0 455 2 0 2 2 0 8 0 art_node 16 138 0 98 1 0 1 1 0 8 0 sysvmsgpl 40 28 0 28 1 1 0 1 0 8 0 semapl 112 10 0 0 1 0 1 1 0 8 0 shmpl 112 86 0 2 3 0 3 3 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 9569 0 8142 47 0 47 47 0 8 0 ffsino 272 9569 0 8142 96 0 96 96 0 8 0 nchpl 144 15926 0 14292 62 1 61 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 45612 0 45612 1 0 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 8 0 8 4 3 1 1 0 8 1 scxspl 192 48881 0 48881 21 18 3 7 0 8 3 plimitpl 152 310 0 302 1 0 1 1 0 8 0 sigapl 432 5409 0 5393 3 1 2 3 0 8 0 futexpl 56 38161 0 38160 1 0 1 1 0 8 0 knotepl 112 889 0 870 1 0 1 1 0 8 0 kqueuepl 104 666 0 664 1 0 1 1 0 8 0 pipepl 112 784 0 765 2 1 1 1 0 8 0 fdescpl 488 5410 0 5393 3 0 3 3 0 8 0 filepl 152 21942 0 21839 9 4 5 5 0 8 0 lockfpl 104 970 0 970 11 10 1 1 0 8 1 lockfspl 48 325 0 325 11 10 1 1 0 8 1 sessionpl 112 29 0 18 1 0 1 1 0 8 0 pgrppl 48 45 0 34 1 0 1 1 0 8 0 ucredpl 96 5955 0 5946 1 0 1 1 0 8 0 zombiepl 144 5393 0 5393 2 1 1 1 0 8 1 processpl 896 5426 0 5393 4 0 4 4 0 8 0 procpl 632 12836 0 12790 16 11 5 5 0 8 1 srpgc 64 22 0 22 8 8 0 1 0 8 0 sosppl 128 37 0 37 6 6 0 1 0 8 0 sockpl 384 2988 0 2969 7 4 3 3 0 8 1 mcl64k 65536 18 0 0 3 0 3 3 0 8 0 mcl16k 16384 2 0 0 1 0 1 1 0 8 0 mcl12k 12288 8 0 0 1 0 1 1 0 8 0 mcl9k 9216 10 0 0 1 0 1 1 0 8 0 mcl8k 8192 8 0 0 1 0 1 1 0 8 0 mcl4k 4096 17 0 0 3 0 3 3 0 8 0 mcl2k2 2112 3 0 0 1 0 1 1 0 8 0 mcl2k 2048 131 0 0 10 0 10 10 0 8 0 mtagpl 80 47 0 0 1 0 1 1 0 8 0 mbufpl 256 376 0 0 15 0 15 15 0 8 0 bufpl 256 16768 0 9749 439 0 439 439 0 8 0 anonpl 16 544218 0 539629 96 61 35 35 0 124 14 amapchunkpl 152 29279 0 29175 46 37 9 18 0 158 3 amappl16 192 28378 0 28189 81 63 18 22 0 8 8 amappl15 184 601 0 600 1 0 1 1 0 8 0 amappl14 176 1983 0 1978 1 0 1 1 0 8 0 amappl13 168 1985 0 1981 2 1 1 1 0 8 0 amappl12 160 13 0 11 1 0 1 1 0 8 0 amappl11 152 83 0 68 1 0 1 1 0 8 0 amappl10 144 1027 0 1024 1 0 1 1 0 8 0 amappl9 136 619 0 616 1 0 1 1 0 8 0 amappl8 128 570 0 535 2 0 2 2 0 8 0 amappl7 120 1007 0 1001 1 0 1 1 0 8 0 amappl6 112 63 0 55 1 0 1 1 0 8 0 amappl5 104 928 0 913 1 0 1 1 0 8 0 amappl4 96 5132 0 5097 2 1 1 2 0 8 0 amappl3 88 2719 0 2709 1 0 1 1 0 8 0 amappl2 80 43560 0 43474 4 2 2 3 0 8 0 amappl1 72 105375 0 104905 26 15 11 20 0 8 0 amappl 80 13354 0 13312 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 87 0 2 2 0 2 2 0 8 0 uaddrrnd 24 5410 0 5393 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 5410 0 5393 1 0 1 1 0 8 0 vmmpekpl 168 30716 0 30676 2 0 2 2 0 8 0 vmmpepl 168 626994 0 625539 150 80 70 78 0 357 6 vmsppl 368 5409 0 5393 2 0 2 2 0 8 0 pdppl 4096 10827 0 10786 6 0 6 6 0 8 0 pvpl 32 1554947 0 1547031 257 157 100 104 0 265 29 pmappl 232 5409 0 5393 2 1 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 604 0 8 19 1 18 18 0 8 0