witness: lock order reversal: 1st 0xffff800020b8d230 &pr->ps_mtx (&pr->ps_mtx) 2nd 0xffffffff8236c9d8 &sched_lock (&sched_lock) lock order "&sched_lock"(sched_lock) -> "&pr->ps_mtx"(mutex) first seen at: #0 witness_checkorder+0x6a7 sys/kern/subr_witness.c:877 #1 mtx_enter+0x3a sys/kern/kern_lock.c:265 #2 tuagg+0x32 sys/kern/kern_resource.c:360 #3 mi_switch+0x1c7 x86_atomic_clearbits_u32 sys/arch/amd64/compile/SYZKALLER/obj/machine/atomic.h:298 [inline] #3 mi_switch+0x1c7 sys/kern/sched_bsd.c:392 #4 sleep_finish+0x110 sys/kern/kern_synch.c:303 #5 msleep+0x1af sleep_finish_timeout sys/kern/kern_synch.c:327 [inline] #5 msleep+0x1af sleep_finish_all sys/kern/kern_synch.c:157 [inline] #5 msleep+0x1af sys/kern/kern_synch.c:220 #6 scsi_xs_sync+0x14f sys/scsi/scsi_base.c:1339 #7 scsi_start+0x86 sys/scsi/scsi_base.c:938 #8 sdopen+0x22b sys/scsi/sd.c:400 #9 spec_open+0x41c sys/kern/spec_vnops.c:158 #10 VOP_OPEN+0x6a sys/kern/vfs_vops.c:153 #11 sr_meta_native_bootprobe+0xd3 sys/dev/softraid.c:1038 #12 sr_boot_assembly+0x1aa sys/dev/softraid.c:1202 #13 sr_attach+0x183 sys/dev/softraid.c:1822 #14 config_attach+0x347 sys/kern/subr_autoconf.c:404 #15 main+0x6de sys/kern/init_main.c:483 #16 longmode_hi+0x95 lock order "&pr->ps_mtx"(mutex) -> "&sched_lock"(sched_lock) first seen at: #0 witness_checkorder+0x6a7 sys/kern/subr_witness.c:877 #1 __mp_lock+0xa1 #2 schedclock+0x99 sys/kern/sched_bsd.c:547 #3 hardclock+0x1d8 sys/kern/kern_clock.c:174 #4 lapic_clockintr+0x44 sys/arch/amd64/amd64/lapic.c:425 #5 Xresume_lapic_ltimer+0x26 #6 __sanitizer_cov_trace_pc+0x7 sys/dev/kcov.c:86 #7 exit1+0x8bf sys/kern/kern_exit.c:349 #8 sys_exit+0x17 sys/kern/kern_exit.c:94 #9 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:99 [inline] #9 syscall+0x552 sys/arch/amd64/amd64/trap.c:574 #10 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(ffffffff8236c9d8,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2504 [inline] witness_checkorder(ffffffff8236c9d8,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1084 __mp_lock(ffffffff8236c7d0) at __mp_lock+0xa1 schedclock(ffff800020b392d8) at schedclock+0x99 sys/kern/sched_bsd.c:547 hardclock(ffff800025023a80) at hardclock+0x1d8 sys/kern/kern_clock.c:174 lapic_clockintr(0,0) at lapic_clockintr+0x44 sys/arch/amd64/amd64/lapic.c:425 Xresume_lapic_ltimer(9,ffffffff819f9bf6,0,0,ffff800020b8d220,ffff800020b392d8) at Xresume_lapic_ltimer+0x26 __sanitizer_cov_trace_pc() at __sanitizer_cov_trace_pc+0x7 sys/dev/kcov.c:86 exit1(ffff800020b392d8,0,1) at exit1+0x8bf sys/kern/kern_exit.c:349 sys_exit(ffff800020b392d8,ffff800025023c70,ffff800025023ce0) at sys_exit+0x17 sys/kern/kern_exit.c:94 syscall(ffff800025023d50) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:99 [inline] syscall(ffff800025023d50) at syscall+0x552 sys/arch/amd64/amd64/trap.c:574 Xsyscall(6,1,0,1,0,7f7ffffc4e74) at Xsyscall+0x128 end of kernel end trace frame: 0x7f7ffffc4e40, count: -12 ddb{1}> show registers rdi 0x3 rsi 0xffffffff821c7a20 __sancov_gen_cov_switch_values.122 rbp 0xffff800025023880 rbx 0x3 rdx 0xffff800020ab0ff0 rcx 0x3 rax 0xffff800020ab0ff0 r8 0xffffffff813b9985 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xc03ef5ca9ace45e9 r12 0xfffffd8002662340 r13 0xc r14 0xffffffff823086b0 w_lodata+0x47070 r15 0xffffffff82318670 w_lodata+0x57030 rip 0xffffffff81e8beb8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800025023870 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.1) pid=473596 stat=dead flags process=1018 proc=2000 pri=50, usrpri=86, nice=20 forw=0xffffffffffffffff, list=0xffffffffffffffff,0xffffffffffffffff process=0xffff800020b8d170 user=0xffff80002501e000, vmspace=0xfffffd806e8da710 estcpu=36, cpticks=1, pctcpu=0.0 user=0, sys=1, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 21679 334888 22364 32767 3 0x90 nanosleep syz-executor.1 22364 63863 70504 0 3 0x82 wait syz-executor.1 10108 362152 34121 32767 3 0x90 nanosleep syz-executor.0 34121 339507 70504 0 3 0x82 wait syz-executor.0 53072 345340 0 0 3 0x14200 bored sosplice 70504 396137 30167 0 3 0x82 kqread syz-fuzzer 70504 384906 30167 0 3 0x4000082 nanosleep syz-fuzzer 70504 327697 30167 0 3 0x4000082 thrsleep syz-fuzzer 70504 19436 30167 0 3 0x4000082 thrsleep syz-fuzzer 70504 492699 30167 0 3 0x4000082 thrsleep syz-fuzzer 70504 157112 30167 0 3 0x4000082 thrsleep syz-fuzzer 70504 341455 30167 0 3 0x4000082 thrsleep syz-fuzzer 70504 72393 30167 0 3 0x4000082 thrsleep syz-fuzzer 70504 100421 30167 0 3 0x4000082 thrsleep syz-fuzzer 70504 483074 30167 0 3 0x4000082 thrsleep syz-fuzzer 30167 40333 36331 0 3 0x10008a pause ksh 36331 35566 84364 0 3 0x92 select sshd 89314 488196 1 0 3 0x100083 ttyin getty 84364 416406 1 0 3 0x80 select sshd 38787 470984 68189 73 2 0x100090 syslogd 68189 422918 1 0 3 0x100082 netio syslogd 26463 198796 1 77 3 0x100090 poll dhclient 38688 513179 1 0 3 0x80 poll dhclient 86396 325721 0 0 3 0x14200 pgzero zerothread 89408 258797 0 0 3 0x14200 aiodoned aiodoned 88452 423460 0 0 3 0x14200 syncer update 69914 238755 0 0 3 0x14200 cleaner cleaner 66879 451006 0 0 7 0x14200 reaper 69346 127266 0 0 3 0x14200 pgdaemon pagedaemon 80804 299445 0 0 3 0x14200 bored crynlk 95562 16477 0 0 3 0x14200 bored crypto 69088 227472 0 0 3 0x40014200 acpi0 acpi0 98737 351783 0 0 3 0x40014200 idle1 60476 183100 0 0 3 0x14200 bored softnet 56783 203062 0 0 3 0x14200 bored systqmp 73120 151207 0 0 3 0x14200 bored systq 51387 88913 0 0 3 0x40014200 bored softclock 23755 266237 0 0 3 0x40014200 idle0 75287 358247 0 0 3 0x14200 bored smr 1 492606 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{1}> show all locks CPU 1: exclusive mutex &pr->ps_mtx r = 0 (0xffff800020b8d230) #0 witness_lock+0x52e sys/kern/subr_witness.c:1161 #1 mtx_enter_try+0x102 #2 mtx_enter+0x4b sys/kern/kern_lock.c:266 #3 sched_exit+0xa5 sys/kern/kern_sched.c:224 #4 exit1+0x8bf sys/kern/kern_exit.c:349 #5 sys_exit+0x17 sys/kern/kern_exit.c:94 #6 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:99 [inline] #6 syscall+0x552 sys/arch/amd64/amd64/trap.c:574 #7 Xsyscall+0x128 ddb{1}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9460 6321K 6321K 78643K 10837 0 0 pcb 23 9K 11K 78643K 1486 0 0 rtable 105 3K 3K 78643K 2787 0 0 ifaddr 36 11K 11K 78643K 396 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 2K 78643K 116 0 0 iov 0 0K 32K 78643K 167 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1209 76K 76K 78643K 2758 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 25 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 0K 78643K 183 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12628 0 0 file desc 6 17K 33K 78643K 2970 0 0 sigio 0 0K 0K 78643K 28 0 0 proc 41 38K 70K 78643K 2964 0 0 subproc 34 2K 2K 78643K 1020 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 274 0 0 in_multi 33 2K 2K 78643K 744 0 0 ether_multi 1 0K 0K 78643K 17 0 0 ISOFS mount 1 32K 32K 78643K 1 0 0 MSDOSFS mount 1 16K 16K 78643K 1 0 0 ttys 60 265K 265K 78643K 60 0 0 exec 0 0K 1K 78643K 1064 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 90 21K 31K 78643K 10553 0 0 UVM aobj 72 3K 3K 78643K 82 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 131 0 0 NDP 7 0K 0K 78643K 183 0 0 temp 120 2730K 2798K 78643K 15785 0 0 kqueue 0 0K 0K 78643K 26 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 122 0 116 1 0 1 1 0 8 0 inpcbpl 280 1348 0 1341 1 0 1 1 0 8 0 plimitpl 152 241 0 232 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtentry 112 683 0 639 2 0 2 2 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpcb 544 475 0 469 1 0 1 1 0 8 0 nd6 48 180 0 174 1 0 1 1 0 8 0 art_heap8 4096 1 0 0 1 0 1 1 0 8 0 art_heap4 256 2809 0 2618 14 2 12 13 0 8 0 art_table 32 2810 0 2618 2 0 2 2 0 8 0 art_node 16 682 0 642 1 0 1 1 0 8 0 sysvmsgpl 40 44 0 28 1 0 1 1 0 8 0 semupl 112 1 0 1 1 1 0 1 0 8 0 semapl 112 179 0 169 1 0 1 1 0 8 0 shmpl 112 80 0 10 2 0 2 2 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 4427 0 2966 48 0 48 48 0 8 0 ffsino 272 4427 0 2966 98 0 98 98 0 8 0 nchpl 144 7899 0 6277 61 0 61 61 0 8 0 uvmvnodes 72 5456 0 0 100 0 100 100 0 8 0 vnodes 200 5456 0 0 288 0 288 288 0 8 0 namei 1024 31096 0 31096 3 2 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scxspl 192 19773 0 19773 12 11 1 6 0 8 1 sigapl 432 2967 0 2953 7 5 2 3 0 8 0 futexpl 56 23002 0 23002 2 1 1 1 0 8 1 knotepl 112 1739 0 1720 1 0 1 1 0 8 0 kqueuepl 104 545 0 543 1 0 1 1 0 8 0 pipepl 112 1816 0 1797 6 5 1 2 0 8 0 fdescpl 488 2968 0 2953 3 0 3 3 0 8 1 filepl 152 17156 0 17060 10 5 5 7 0 8 1 lockfpl 104 501 0 501 4 3 1 1 0 8 1 lockfspl 48 162 0 162 4 3 1 1 0 8 1 sessionpl 112 75 0 65 1 0 1 1 0 8 0 pgrppl 48 108 0 98 1 0 1 1 0 8 0 ucredpl 96 5068 0 5059 1 0 1 1 0 8 0 zombiepl 144 2953 0 2951 2 1 1 1 0 8 0 processpl 888 2984 0 2951 4 0 4 4 0 8 0 procpl 600 7426 0 7383 5 1 4 5 0 8 0 srpgc 64 348 0 348 4 3 1 1 0 8 1 sosppl 128 36 0 36 10 10 0 1 0 8 0 sockpl 384 2885 0 2868 5 2 3 4 0 8 1 mcl64k 65536 4 0 0 1 0 1 1 0 8 0 mcl16k 16384 2 0 0 1 0 1 1 0 8 0 mcl12k 12288 17 0 0 2 0 2 2 0 8 0 mcl9k 9216 10 0 0 1 0 1 1 0 8 0 mcl8k 8192 7 0 0 1 0 1 1 0 8 0 mcl4k 4096 17 0 0 3 0 3 3 0 8 0 mcl2k2 2112 4 0 0 1 0 1 1 0 8 0 mcl2k 2048 117 0 0 14 0 14 14 0 8 0 mtagpl 80 1 0 0 1 0 1 1 0 8 0 mbufpl 256 264 0 0 12 0 12 12 0 8 0 bufpl 256 8507 0 1502 438 0 438 438 0 8 0 anonpl 16 270980 0 265612 78 48 30 42 0 125 2 amapchunkpl 152 24310 0 24219 43 34 9 11 0 158 5 amappl16 192 10022 0 9714 49 31 18 28 0 8 2 amappl15 184 306 0 305 1 0 1 1 0 8 0 amappl14 176 700 0 697 2 1 1 1 0 8 0 amappl13 168 457 0 457 6 5 1 1 0 8 1 amappl12 160 428 0 425 1 0 1 1 0 8 0 amappl11 152 572 0 553 1 0 1 1 0 8 0 amappl10 144 747 0 744 2 1 1 1 0 8 0 amappl9 136 1505 0 1502 1 0 1 1 0 8 0 amappl8 128 870 0 850 1 0 1 1 0 8 0 amappl7 120 722 0 712 1 0 1 1 0 8 0 amappl6 112 387 0 375 1 0 1 1 0 8 0 amappl5 104 839 0 829 1 0 1 1 0 8 0 amappl4 96 3111 0 3086 1 0 1 1 0 8 0 amappl3 88 617 0 607 1 0 1 1 0 8 0 amappl2 80 18574 0 18506 4 2 2 3 0 8 0 amappl1 72 87421 0 86975 23 13 10 19 0 8 0 amappl 80 8586 0 8549 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 81 0 10 2 0 2 2 0 8 0 uaddrrnd 24 2968 0 2952 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 2968 0 2952 1 0 1 1 0 8 0 vmmpekpl 168 27848 0 27819 2 0 2 2 0 8 0 vmmpepl 168 334107 0 332701 129 56 73 76 0 357 8 vmsppl 360 2967 0 2952 2 0 2 2 0 8 0 pdppl 4096 5944 0 5904 6 0 6 6 0 8 1 pvpl 32 823355 0 814790 194 105 89 109 0 265 12 pmappl 232 2967 0 2952 8 6 2 2 0 8 1 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 598 0 6 17 0 17 17 0 8 0