witness: lock order reversal: 1st 0xffff800020b8dc98 &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+0x50 sys/dev/kcov.c:102 #7 exit1+0x6e5 sys/kern/kern_exit.c:292 #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{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(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(ffff80002503d510) 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,ffff800020b392d8,0,0,ffff800020b392d8,ffff800020b8dc88) at Xresume_lapic_ltimer+0x26 __sanitizer_cov_trace_pc() at __sanitizer_cov_trace_pc+0x50 sys/dev/kcov.c:102 exit1(ffff800020b392d8,0,1) at exit1+0x6e5 sys/kern/kern_exit.c:292 sys_exit(ffff800020b392d8,ffff80002503d6e0,ffff80002503d750) at sys_exit+0x17 sys/kern/kern_exit.c:94 syscall(ffff80002503d7c0) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:99 [inline] syscall(ffff80002503d7c0) at syscall+0x552 sys/arch/amd64/amd64/trap.c:574 Xsyscall(0,1,0,1,0,7f7ffffd4834) at Xsyscall+0x128 end of kernel end trace frame: 0x7f7ffffd4800, count: -12 ddb{0}> show registers rdi 0x3 rsi 0xffffffff821c7a20 __sancov_gen_cov_switch_values.122 rbp 0xffff80002503d310 rbx 0x3 rdx 0xffffffff821cdff0 cpu_info_full_primary+0x1ff0 rcx 0x3 rax 0xffffffff821cdff0 cpu_info_full_primary+0x1ff0 r8 0xffffffff813b9985 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xd2f4ea9f8c7919c3 r12 0xfffffd8002662340 r13 0xc r14 0xffffffff8230a2e0 w_lodata+0x48ca0 r15 0xffffffff82318670 w_lodata+0x57030 rip 0xffffffff81e8beb8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff80002503d300 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.1) pid=125140 stat=dead flags process=1018 proc=2000 pri=50, usrpri=86, nice=20 forw=0xffffffffffffffff, list=0xffffffffffffffff,0xffffffffffffffff process=0xffff800020b8dbd8 user=0xffff800025038000, vmspace=0xfffffd807effe168 estcpu=36, cpticks=5, pctcpu=0.0 user=0, sys=1, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 38841 365085 45801 32767 3 0x90 nanosleep syz-executor.0 38841 68017 45801 32767 3 0x4000090 ttyout syz-executor.0 38841 360292 45801 32767 3 0x4000090 fsleep syz-executor.0 45801 169828 5507 32767 3 0x90 nanosleep syz-executor.0 5507 334726 9950 0 3 0x82 wait syz-executor.0 29908 452236 67835 32767 3 0x90 nanosleep syz-executor.1 67835 10777 9950 0 3 0x82 wait syz-executor.1 72586 233090 0 0 3 0x14200 bored sosplice 9950 308677 15142 0 3 0x82 thrsleep syz-fuzzer 9950 475345 15142 0 3 0x4000082 thrsleep syz-fuzzer 9950 267624 15142 0 3 0x4000082 thrsleep syz-fuzzer 9950 92407 15142 0 3 0x4000082 thrsleep syz-fuzzer 9950 145802 15142 0 3 0x4000082 kqread syz-fuzzer 9950 495044 15142 0 3 0x4000082 thrsleep syz-fuzzer 9950 412343 15142 0 3 0x4000082 thrsleep syz-fuzzer 9950 472137 15142 0 3 0x4000082 thrsleep syz-fuzzer 9950 107474 15142 0 3 0x4000082 thrsleep syz-fuzzer 9950 472239 15142 0 3 0x4000082 thrsleep syz-fuzzer 15142 175655 93391 0 3 0x10008a pause ksh 93391 159708 85244 0 3 0x92 select sshd 6215 109974 1 0 3 0x100083 ttyin getty 85244 255057 1 0 3 0x80 select sshd 80884 249997 84624 73 2 0x100090 syslogd 84624 35160 1 0 3 0x100082 netio syslogd 99408 139436 1 77 3 0x100090 poll dhclient 86671 75830 1 0 3 0x80 poll dhclient 90269 467538 0 0 3 0x14200 pgzero zerothread 5021 37119 0 0 3 0x14200 aiodoned aiodoned 10039 434150 0 0 3 0x14200 syncer update 46213 413047 0 0 3 0x14200 cleaner cleaner 62418 314377 0 0 7 0x14200 reaper 33092 225883 0 0 3 0x14200 pgdaemon pagedaemon 39045 313821 0 0 3 0x14200 bored crynlk 10018 479355 0 0 3 0x14200 bored crypto 62095 299660 0 0 3 0x40014200 acpi0 acpi0 69505 167163 0 0 3 0x40014200 idle1 10883 324791 0 0 3 0x14200 bored softnet 34933 367089 0 0 3 0x14200 bored systqmp 34591 445586 0 0 3 0x14200 bored systq 4430 187933 0 0 3 0x40014200 bored softclock 46406 424801 0 0 3 0x40014200 idle0 13016 402234 0 0 3 0x14200 bored smr 1 453388 0 0 3 0x82 wait init 0 0 -1 0 3 0x10200 scheduler swapper ddb{0}> show all locks CPU 0: exclusive mutex &pr->ps_mtx r = 0 (0xffff800020b8dc98) #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 tuagg+0x32 sys/kern/kern_resource.c:360 #4 exit1+0x6e5 sys/kern/kern_exit.c:292 #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{0}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9460 6321K 6321K 78643K 10707 0 0 pcb 23 9K 10K 78643K 903 0 0 rtable 105 3K 3K 78643K 1617 0 0 ifaddr 35 10K 10K 78643K 231 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 2K 78643K 86 0 0 iov 0 0K 32K 78643K 103 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1209 76K 76K 78643K 2077 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 13 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 1K 78643K 118 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12628 0 0 file desc 7 21K 33K 78643K 1812 0 0 sigio 0 0K 0K 78643K 19 0 0 proc 41 38K 70K 78643K 1778 0 0 subproc 34 2K 2K 78643K 578 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 179 0 0 in_multi 33 2K 2K 78643K 421 0 0 ether_multi 1 0K 0K 78643K 6 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 655 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 99 21K 22K 78643K 6781 0 0 UVM aobj 52 3K 3K 78643K 63 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 78 0 0 NDP 5 0K 0K 78643K 105 0 0 temp 121 2732K 2798K 78643K 10456 0 0 kqueue 0 0K 0K 78643K 29 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 70 0 64 1 0 1 1 0 8 0 inpcbpl 280 821 0 814 1 0 1 1 0 8 0 plimitpl 152 151 0 142 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtentry 112 397 0 353 2 0 2 2 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpcb 544 279 0 275 1 0 1 1 0 8 0 nd6 48 102 0 96 1 0 1 1 0 8 0 art_heap8 4096 1 0 0 1 0 1 1 0 8 0 art_heap4 256 1615 0 1424 13 1 12 13 0 8 0 art_table 32 1616 0 1424 2 0 2 2 0 8 0 art_node 16 396 0 356 1 0 1 1 0 8 0 sysvmsgpl 40 8 0 4 2 1 1 1 0 8 0 semupl 112 3 0 3 1 1 0 1 0 8 0 semapl 112 116 0 106 1 0 1 1 0 8 0 shmpl 112 61 0 11 2 0 2 2 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 3286 0 1847 47 0 47 47 0 8 0 ffsino 272 3286 0 1847 97 0 97 97 0 8 0 nchpl 144 5593 0 3973 61 0 61 61 0 8 0 uvmvnodes 72 3873 0 0 71 0 71 71 0 8 0 vnodes 200 3873 0 0 204 0 204 204 0 8 0 namei 1024 19986 0 19986 3 2 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scxspl 192 14762 0 14762 12 11 1 5 0 8 1 sigapl 432 1887 0 1871 3 1 2 3 0 8 0 futexpl 56 14166 0 14165 2 1 1 1 0 8 0 knotepl 112 1044 0 1024 1 0 1 1 0 8 0 kqueuepl 104 368 0 365 1 0 1 1 0 8 0 pipepl 112 1060 0 1041 2 1 1 1 0 8 0 fdescpl 488 1888 0 1872 3 0 3 3 0 8 0 filepl 152 10682 0 10583 6 1 5 5 0 8 1 lockfpl 104 366 0 366 3 2 1 1 0 8 1 lockfspl 48 115 0 115 3 2 1 1 0 8 1 sessionpl 112 49 0 39 1 0 1 1 0 8 0 pgrppl 48 71 0 61 1 0 1 1 0 8 0 ucredpl 96 2995 0 2986 1 0 1 1 0 8 0 zombiepl 144 1872 0 1871 2 1 1 1 0 8 0 processpl 888 1904 0 1871 4 0 4 4 0 8 0 procpl 600 4770 0 4725 4 0 4 4 0 8 0 srpgc 64 192 0 192 6 5 1 1 0 8 1 sosppl 128 31 0 31 5 5 0 1 0 8 0 sockpl 384 1744 0 1727 6 3 3 3 0 8 1 mcl64k 65536 3 0 0 1 0 1 1 0 8 0 mcl16k 16384 2 0 0 1 0 1 1 0 8 0 mcl12k 12288 15 0 0 2 0 2 2 0 8 0 mcl9k 9216 4 0 0 1 0 1 1 0 8 0 mcl8k 8192 6 0 0 1 0 1 1 0 8 0 mcl4k 4096 7 0 0 1 0 1 1 0 8 0 mcl2k2 2112 2 0 0 1 0 1 1 0 8 0 mcl2k 2048 128 0 0 15 0 15 15 0 8 0 mtagpl 80 1 0 0 1 0 1 1 0 8 0 mbufpl 256 259 0 0 13 1 12 12 0 8 0 bufpl 256 7731 0 1159 411 0 411 411 0 8 0 anonpl 16 207616 0 201820 89 60 29 41 0 125 1 amapchunkpl 152 13633 0 13540 6 1 5 6 0 158 1 amappl16 192 9042 0 8724 94 76 18 30 0 8 2 amappl15 184 226 0 222 5 4 1 1 0 8 0 amappl14 176 449 0 447 2 1 1 1 0 8 0 amappl13 168 192 0 191 1 0 1 1 0 8 0 amappl12 160 422 0 420 1 0 1 1 0 8 0 amappl11 152 338 0 324 1 0 1 1 0 8 0 amappl10 144 207 0 207 7 6 1 1 0 8 1 amappl9 136 1189 0 1186 1 0 1 1 0 8 0 amappl8 128 715 0 692 1 0 1 1 0 8 0 amappl7 120 218 0 204 1 0 1 1 0 8 0 amappl6 112 250 0 240 1 0 1 1 0 8 0 amappl5 104 693 0 682 1 0 1 1 0 8 0 amappl4 96 1773 0 1744 1 0 1 1 0 8 0 amappl3 88 501 0 491 1 0 1 1 0 8 0 amappl2 80 11907 0 11833 4 2 2 3 0 8 0 amappl1 72 57986 0 57528 23 13 10 19 0 8 0 amappl 80 5499 0 5460 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 62 0 11 1 0 1 1 0 8 0 uaddrrnd 24 1888 0 1871 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 1888 0 1871 1 0 1 1 0 8 0 vmmpekpl 168 18204 0 18176 2 0 2 2 0 8 0 vmmpepl 168 217440 0 215932 134 65 69 78 0 357 3 vmsppl 360 1887 0 1871 2 0 2 2 0 8 0 pdppl 4096 3784 0 3742 6 0 6 6 0 8 0 pvpl 32 574819 0 565709 185 86 99 117 0 265 20 pmappl 232 1887 0 1871 3 2 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 569 0 6 17 0 17 17 0 8 0