witness: lock order reversal: 1st 0xfffffd8067eea4e8 inode (&ip->i_lock) 2nd 0xfffffd807e0e5dc0 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(fffffd807e0e5dc0,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2506 [inline] witness_checkorder(fffffd807e0e5dc0,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1086 rw_enter_write(fffffd807e0e5db0) at rw_enter_write+0x5b sys/kern/kern_rwlock.c:125 diskmapioctl(5a00,c0106477,ffff80002157d2c0,1,ffff800020abe070) at diskmapioctl+0x237 sys/dev/diskmap.c:106 VOP_IOCTL(fffffd806fa84328,c0106477,ffff80002157d2c0,1,fffffd807f7c6720,ffff800020abe070) at VOP_IOCTL+0x88 sys/kern/vfs_vops.c:290 vn_ioctl(fffffd806ca158f8,c0106477,ffff80002157d2c0,ffff800020abe070) at vn_ioctl+0xb7 sys/kern/vfs_vnops.c:524 sys_ioctl(ffff800020abe070,ffff80002157d3d8,ffff80002157d440) at sys_ioctl+0x5b8 syscall(ffff80002157d4b0) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:92 [inline] syscall(ffff80002157d4b0) at syscall+0x552 sys/arch/amd64/amd64/trap.c:555 Xsyscall(6,0,ffffffffffffff1b,0,3,fc440d871b0) at Xsyscall+0x128 end of kernel end trace frame: 0xfc730903220, count: -9 ddb{0}> show registers rdi 0x3 rsi 0x3ffff acpi_pdirpa+0x2be67 rbp 0xffff80002157ce80 rbx 0x3 rdx 0x40000 acpi_pdirpa+0x2be68 rcx 0xffff80002135e000 rax 0xffff800000a431c0 r8 0xffffffff8187b235 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x8e4d2a16857c2697 r12 0xfffffd80029b6c00 r13 0 r14 0xffffffff825b08c0 w_lodata+0x3b4c0 r15 0xffffffff825c9780 w_lodata+0x54380 rip 0xffffffff81b977e8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff80002157ce70 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.1) pid=402588 stat=onproc flags process=0 proc=4000000 pri=32, usrpri=81, nice=20 forw=0xffffffffffffffff, list=0xffff800020abef40,0xffff800020abf1c8 process=0xffff800020a8a010 user=0xffff800021578000, vmspace=0xfffffd807f00c5c0 estcpu=31, cpticks=0, pctcpu=0.0 user=0, sys=0, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 64384 111295 38272 0 2 0 syz-executor.1 64384 291475 38272 0 7 0x4000080 syz-executor.1 64384 162922 38272 0 2 0x4000000 syz-executor.1 *64384 402588 38272 0 7 0x4000000 syz-executor.1 64384 20449 38272 0 3 0x4000080 fsleep syz-executor.1 38272 356980 55019 0 3 0x82 nanosleep syz-executor.1 69091 376841 55019 0 3 0x82 piperd syz-executor.0 91125 347909 1 0 3 0x100083 ttyin getty 90153 84468 0 0 3 0x14200 acct acct 51627 39019 0 0 3 0x14200 bored sosplice 55019 42511 52199 0 3 0x82 thrsleep syz-fuzzer 55019 266340 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 97602 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 24045 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 144069 52199 0 3 0x4000082 kqread syz-fuzzer 55019 513491 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 439212 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 224738 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 458322 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 278648 52199 0 3 0x4000082 thrsleep syz-fuzzer 55019 258789 52199 0 3 0x4000082 thrsleep syz-fuzzer 52199 476225 85664 0 3 0x10008a pause ksh 85664 299292 59261 0 3 0x92 select sshd 59261 472974 1 0 3 0x80 select sshd 78968 5199 22015 74 3 0x100092 bpf pflogd 22015 55117 1 0 3 0x80 netio pflogd 15563 322650 46622 73 3 0x100090 kqread syslogd 46622 252993 1 0 3 0x100082 netio syslogd 42404 402431 1 77 3 0x100090 poll dhclient 385 498269 1 0 3 0x80 poll dhclient 77023 236466 0 0 3 0x14200 pgzero zerothread 36206 117408 0 0 3 0x14200 aiodoned aiodoned 11574 470820 0 0 3 0x14200 syncer update 78456 281190 0 0 3 0x14200 cleaner cleaner 34587 252749 0 0 3 0x14200 reaper reaper 74860 21398 0 0 3 0x14200 pgdaemon pagedaemon 39499 185052 0 0 3 0x14200 bored crynlk 10283 477379 0 0 3 0x14200 bored crypto 42092 106377 0 0 3 0x40014200 acpi0 acpi0 84196 149059 0 0 3 0x40014200 idle1 49666 4912 0 0 3 0x14200 bored softnet 65828 329002 0 0 3 0x14200 bored systqmp 76711 254689 0 0 3 0x14200 bored systq 17603 192694 0 0 3 0x40014200 bored softclock 63412 345453 0 0 3 0x40014200 idle0 28599 343660 0 0 3 0x14200 bored smr 1 240235 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks Process 64384 (syz-executor.1) thread 0xffff800020abe070 (402588) exclusive rrwlock inode r = 0 (0xfffffd8067eea4e8) #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{0}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9593 7098K 7614K 78643K 27313 0 0 pcb 13 8K 8K 78643K 590 0 0 rtable 111 4K 5K 78643K 3703 0 0 ifaddr 85 23K 28K 78643K 1295 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 4K 78643K 1729 0 0 iov 0 0K 28K 78643K 744 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1210 76K 77K 78643K 8861 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 153 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 11 1K 1K 78643K 11 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12765 0 0 file desc 5 13K 25K 78643K 11627 0 0 sigio 0 0K 0K 78643K 113 0 0 proc 54 51K 71K 78643K 2326 0 0 subproc 32 2K 2K 78643K 527 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 716 0 0 in_multi 33 2K 2K 78643K 655 0 0 ether_multi 1 0K 0K 78643K 65 0 0 mrt 0 0K 0K 78643K 51 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 1409 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 97 21K 31K 78643K 32953 0 0 UVM aobj 130 6K 6K 78643K 146 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 413 0 0 NDP 20 0K 1K 78643K 435 0 0 temp 231 3545K 4185K 78643K 166523 0 0 kqueue 0 0K 0K 78643K 42 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 63 0 57 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtpcb 80 357 0 355 1 0 1 1 0 8 0 rtentry 112 364 0 320 4 2 2 2 0 8 0 unpcb 120 2027 0 2017 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 151 0 151 11 11 0 1 0 8 0 tcpcb 544 1284 0 1280 1 0 1 1 0 8 0 inpcb 280 3845 0 3838 11 9 2 2 0 8 1 rttmr 72 1 0 1 1 0 1 1 0 8 1 nd6 48 90 0 84 2 1 1 1 0 8 0 pkpcb 40 20 0 20 8 8 0 1 0 8 0 swfcl 56 2 0 0 1 0 1 1 0 8 0 ppxss 1128 296 0 294 6 5 1 1 0 8 0 pffrag 232 29 0 29 10 10 0 1 0 482 0 pffrnode 88 29 0 29 10 10 0 1 0 8 0 pffrent 40 76 0 76 10 10 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 258 0 239 1 0 1 1 0 8 0 pfstkey 112 258 0 239 2 1 1 2 0 8 0 pfstate 328 258 0 239 10 7 3 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 1496 0 1301 26 13 13 13 0 8 0 art_table 32 1497 0 1301 3 1 2 2 0 8 0 art_node 16 354 0 314 1 0 1 1 0 8 0 sysvmsgpl 40 379 0 379 5 5 0 1 0 8 0 semupl 112 7 0 7 1 1 0 1 0 8 0 semapl 112 9 0 0 1 0 1 1 0 8 0 shmpl 112 144 0 16 4 0 4 4 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 19951 0 18471 48 0 48 48 0 8 0 ffsino 272 19951 0 18471 100 1 99 100 0 8 0 nchpl 144 35306 0 33672 62 1 61 62 0 8 0 uvmvnodes 72 6532 0 0 119 0 119 119 0 8 0 vnodes 200 6532 0 0 344 0 344 344 0 8 0 namei 1024 105318 0 105318 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scsiplug 64 7 0 7 5 5 0 1 0 8 0 scxspl 192 111689 0 111689 35 31 4 7 0 8 4 plimitpl 152 737 0 729 1 0 1 1 0 8 0 sigapl 432 11750 0 11735 4 2 2 3 0 8 0 futexpl 56 99641 0 99640 2 1 1 1 0 8 0 knotepl 112 2586 0 2567 1 0 1 1 0 8 0 kqueuepl 104 1896 0 1894 1 0 1 1 0 8 0 pipepl 112 3560 0 3541 4 3 1 2 0 8 0 fdescpl 488 11751 0 11735 3 0 3 3 0 8 0 filepl 152 51869 0 51763 16 11 5 6 0 8 0 lockfpl 104 3383 0 3383 21 20 1 1 0 8 1 lockfspl 48 1152 0 1152 21 20 1 1 0 8 1 sessionpl 112 56 0 45 1 0 1 1 0 8 0 pgrppl 48 118 0 107 1 0 1 1 0 8 0 ucredpl 96 11594 0 11584 1 0 1 1 0 8 0 zombiepl 144 11735 0 11735 2 1 1 1 0 8 1 processpl 896 11768 0 11735 5 1 4 5 0 8 0 procpl 632 30452 0 30405 15 10 5 5 0 8 0 srpgc 64 57 0 57 24 23 1 1 0 8 1 sosppl 128 108 0 108 16 16 0 1 0 8 0 sockpl 384 6334 0 6315 22 19 3 4 0 8 1 mcl64k 65536 273 0 0 34 4 30 33 0 8 1 mcl16k 16384 20 0 0 3 1 2 3 0 8 0 mcl12k 12288 33 0 0 2 0 2 2 0 8 0 mcl9k 9216 17 0 0 2 0 2 2 0 8 0 mcl8k 8192 17 0 0 3 0 3 3 0 8 0 mcl4k 4096 25 0 0 3 0 3 3 0 8 0 mcl2k2 2112 6 0 0 1 0 1 1 0 8 0 mcl2k 2048 318 0 0 12 2 10 11 0 8 0 mtagpl 80 96 0 0 1 0 1 1 0 8 0 mbufpl 256 1194 0 0 35 1 34 35 0 8 0 bufpl 256 34834 0 27815 439 0 439 439 0 8 0 anonpl 16 1151327 0 1145665 240 203 37 48 0 124 7 amapchunkpl 152 58518 0 58419 54 47 7 12 0 158 2 amappl16 192 70902 0 70645 251 231 20 32 0 8 7 amappl15 184 495 0 495 5 5 0 1 0 8 0 amappl14 176 2291 0 2285 1 0 1 1 0 8 0 amappl13 168 2466 0 2465 6 5 1 1 0 8 0 amappl12 160 1112 0 1108 1 0 1 1 0 8 0 amappl11 152 537 0 522 1 0 1 1 0 8 0 amappl10 144 2027 0 2021 1 0 1 1 0 8 0 amappl9 136 2516 0 2511 1 0 1 1 0 8 0 amappl8 128 2009 0 1988 1 0 1 1 0 8 0 amappl7 120 2031 0 2023 1 0 1 1 0 8 0 amappl6 112 499 0 490 1 0 1 1 0 8 0 amappl5 104 1476 0 1462 1 0 1 1 0 8 0 amappl4 96 11741 0 11712 2 1 1 2 0 8 0 amappl3 88 2890 0 2880 1 0 1 1 0 8 0 amappl2 80 92085 0 92013 3 1 2 3 0 8 0 amappl1 72 235251 0 234812 27 17 10 20 0 8 0 amappl 80 31296 0 31257 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 145 0 16 3 0 3 3 0 8 0 uaddrrnd 24 11751 0 11735 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 11751 0 11735 1 0 1 1 0 8 0 vmmpekpl 168 78773 0 78740 2 0 2 2 0 8 0 vmmpepl 168 1386738 0 1385353 271 199 72 82 0 357 6 vmsppl 368 11750 0 11735 2 0 2 2 0 8 0 pdppl 4096 23509 0 23470 6 0 6 6 0 8 0 pvpl 32 3295962 0 3287002 494 389 105 126 0 265 23 pmappl 232 11750 0 11735 7 6 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 674 0 26 19 0 19 19 0 8 0