witness: lock order reversal: 1st 0xffff800020b8c450 &pr->ps_mtx (&pr->ps_mtx) 2nd 0xffffffff8236e2f8 &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 calcru+0x221 sys/kern/kern_resource.c:423 #7 exit1+0x737 sys/kern/kern_exit.c:301 #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(ffffffff8236e2f8,9,0) at witness_checkorder+0xffc witness_debugger sys/kern/subr_witness.c:2504 [inline] witness_checkorder(ffffffff8236e2f8,9,0) at witness_checkorder+0xffc sys/kern/subr_witness.c:1084 __mp_lock(ffffffff8236e0f0) at __mp_lock+0xa1 schedclock(ffff800020b399e0) at schedclock+0x99 sys/kern/sched_bsd.c:547 hardclock(ffff800022dfda40) 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,fffffd8077926d08,0,0,0,0) at Xresume_lapic_ltimer+0x26 calcru(ffff800020b8c4b8,fffffd8077926cf8,fffffd8077926d08,0) at calcru+0x221 sys/kern/kern_resource.c:423 exit1(ffff800020b399e0,0,1) at exit1+0x737 sys/kern/kern_exit.c:301 sys_exit(ffff800020b399e0,ffff800022dfdc50,ffff800022dfdcc0) at sys_exit+0x17 sys/kern/kern_exit.c:94 syscall(ffff800022dfdd30) at syscall+0x552 mi_syscall sys/sys/syscall_mi.h:99 [inline] syscall(ffff800022dfdd30) at syscall+0x552 sys/arch/amd64/amd64/trap.c:574 Xsyscall(6,1,0,1,0,7f7ffffc8614) at Xsyscall+0x128 end of kernel end trace frame: 0x7f7ffffc85e0, count: -12 ddb{0}> show registers rdi 0x3 rsi 0xffffffff82243e20 __sancov_gen_cov_switch_values.122 rbp 0xffff800022dfd840 rbx 0x3 rdx 0xffffffff821abff0 cpu_info_full_primary+0x1ff0 rcx 0x3 rax 0xffffffff821abff0 cpu_info_full_primary+0x1ff0 r8 0xffffffff81da2df5 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0x8eb2a962b47a8b7d r12 0xfffffd8002661340 r13 0xc r14 0xffffffff82337310 w_lodata+0x48460 r15 0xffffffff82345ee0 w_lodata+0x57030 rip 0xffffffff819ca3d8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800022dfd830 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{0}> show proc PROC (syz-executor.0) pid=46195 stat=dead flags process=1018 proc=2000 pri=50, usrpri=86, nice=20 forw=0xffffffffffffffff, list=0xffffffffffffffff,0xffffffffffffffff process=0xffff800020b8c390 user=0xffff800022df8000, vmspace=0xfffffd807effd2d0 estcpu=36, cpticks=13, pctcpu=0.0 user=0, sys=1, intr=0 ddb{0}> ps PID TID PPID UID S FLAGS WAIT COMMAND 34170 459667 36790 32767 3 0x90 nanosleep syz-executor.0 36790 272082 63203 0 3 0x82 wait syz-executor.0 40525 243910 96092 32767 3 0x90 piperd syz-executor.1 96092 504056 63203 0 3 0x82 wait syz-executor.1 47577 71243 0 0 3 0x14200 bored sosplice 63203 237825 34338 0 3 0x82 thrsleep syz-fuzzer 63203 133596 34338 0 3 0x4000082 thrsleep syz-fuzzer 63203 65753 34338 0 3 0x4000082 thrsleep syz-fuzzer 63203 152340 34338 0 3 0x4000082 thrsleep syz-fuzzer 63203 158849 34338 0 3 0x4000082 thrsleep syz-fuzzer 63203 474105 34338 0 3 0x4000082 thrsleep syz-fuzzer 63203 302937 34338 0 3 0x4000082 thrsleep syz-fuzzer 63203 73270 34338 0 3 0x4000082 kqread syz-fuzzer 63203 7543 34338 0 3 0x4000082 thrsleep syz-fuzzer 63203 305645 34338 0 3 0x4000082 thrsleep syz-fuzzer 34338 176048 4498 0 3 0x10008a pause ksh 4498 174102 39526 0 3 0x92 select sshd 52258 78773 1 0 3 0x100083 ttyin getty 39526 507385 1 0 3 0x80 select sshd 71839 416279 21014 73 2 0x100090 syslogd 21014 496735 1 0 3 0x100082 netio syslogd 77075 365720 1 77 3 0x100090 poll dhclient 67278 134182 1 0 3 0x80 poll dhclient 31870 212798 0 0 3 0x14200 pgzero zerothread 86529 208831 0 0 3 0x14200 aiodoned aiodoned 38420 319888 0 0 3 0x14200 syncer update 84542 357113 0 0 3 0x14200 cleaner cleaner 2415 350750 0 0 7 0x14200 reaper 3354 236904 0 0 3 0x14200 pgdaemon pagedaemon 44301 74216 0 0 3 0x14200 bored crynlk 34665 500496 0 0 3 0x14200 bored crypto 3965 20646 0 0 3 0x40014200 acpi0 acpi0 18173 124688 0 0 3 0x40014200 idle1 60802 335427 0 0 3 0x14200 bored softnet 14887 426905 0 0 3 0x14200 bored systqmp 10678 144905 0 0 3 0x14200 bored systq 51935 447246 0 0 3 0x40014200 bored softclock 55285 382196 0 0 3 0x40014200 idle0 25311 42044 0 0 3 0x14200 bored smr 1 365665 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 (0xffff800020b8c450) #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 exit1+0x722 sys/kern/kern_exit.c:300 #4 sys_exit+0x17 sys/kern/kern_exit.c:94 #5 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:99 [inline] #5 syscall+0x552 sys/arch/amd64/amd64/trap.c:574 #6 Xsyscall+0x128 ddb{0}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9460 6321K 6321K 78643K 10682 0 0 pcb 23 9K 11K 78643K 781 0 0 rtable 105 3K 3K 78643K 1395 0 0 ifaddr 36 11K 11K 78643K 204 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 2K 78643K 73 0 0 iov 0 0K 24K 78643K 94 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1209 76K 76K 78643K 2030 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 23 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 0K 78643K 86 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12628 0 0 file desc 6 17K 33K 78643K 1627 0 0 sigio 0 0K 0K 78643K 23 0 0 proc 41 38K 58K 78643K 1516 0 0 subproc 34 2K 2K 78643K 493 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 194 0 0 in_multi 33 2K 2K 78643K 384 0 0 ether_multi 1 0K 0K 78643K 7 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 590 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 98 21K 30K 78643K 6178 0 0 UVM aobj 74 3K 3K 78643K 85 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 85 0 0 NDP 7 0K 0K 78643K 90 0 0 temp 121 2734K 2801K 78643K 9529 0 0 kqueue 0 0K 0K 78643K 15 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 60 0 54 1 0 1 1 0 8 0 inpcbpl 280 833 0 826 1 0 1 1 0 8 0 plimitpl 152 144 0 135 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtentry 112 342 0 298 2 0 2 2 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpqe 32 25 0 25 1 1 0 1 0 8 0 tcpcb 544 299 0 295 1 0 1 1 0 8 0 nd6 48 87 0 81 1 0 1 1 0 8 0 art_heap8 4096 1 0 0 1 0 1 1 0 8 0 art_heap4 256 1404 0 1209 14 1 13 13 0 8 0 art_table 32 1405 0 1209 2 0 2 2 0 8 0 art_node 16 341 0 301 1 0 1 1 0 8 0 sysvmsgpl 40 18 0 7 1 0 1 1 0 8 0 semapl 112 84 0 74 1 0 1 1 0 8 0 shmpl 112 83 0 11 3 0 3 3 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 3172 0 1736 47 0 47 47 0 8 0 ffsino 272 3172 0 1736 96 0 96 96 0 8 0 nchpl 144 5182 0 3563 61 0 61 61 0 8 0 uvmvnodes 72 3674 0 0 67 0 67 67 0 8 0 vnodes 200 3674 0 0 194 0 194 194 0 8 0 namei 1024 18446 0 18446 2 1 1 1 0 8 1 percpumem 16 30 0 0 1 0 1 1 0 8 0 scxspl 192 12792 0 12792 10 9 1 6 0 8 1 sigapl 432 1717 0 1702 5 3 2 3 0 8 0 futexpl 56 13237 0 13237 1 0 1 1 0 8 1 knotepl 112 948 0 929 1 0 1 1 0 8 0 kqueuepl 104 400 0 398 1 0 1 1 0 8 0 pipepl 112 1144 0 1125 6 5 1 2 0 8 0 fdescpl 488 1718 0 1703 3 0 3 3 0 8 0 filepl 152 10356 0 10260 12 7 5 7 0 8 1 lockfpl 104 272 0 272 6 5 1 1 0 8 1 lockfspl 48 94 0 94 6 5 1 1 0 8 1 sessionpl 112 44 0 34 1 0 1 1 0 8 0 pgrppl 48 62 0 52 1 0 1 1 0 8 0 ucredpl 96 3202 0 3193 1 0 1 1 0 8 0 zombiepl 144 1703 0 1702 2 1 1 1 0 8 0 processpl 888 1734 0 1702 4 0 4 4 0 8 0 procpl 600 4349 0 4307 4 0 4 4 0 8 0 srpgc 64 162 0 162 7 6 1 1 0 8 1 sosppl 128 43 0 43 6 6 0 1 0 8 0 sockpl 384 1629 0 1612 6 3 3 4 0 8 1 mcl64k 65536 3 0 0 1 0 1 1 0 8 0 mcl16k 16384 1 0 0 1 0 1 1 0 8 0 mcl12k 12288 10 0 0 1 0 1 1 0 8 0 mcl9k 9216 5 0 0 1 0 1 1 0 8 0 mcl8k 8192 4 0 0 1 0 1 1 0 8 0 mcl4k 4096 8 0 0 1 0 1 1 0 8 0 mcl2k2 2112 4 0 0 1 0 1 1 0 8 0 mcl2k 2048 113 0 0 14 0 14 14 0 8 0 mtagpl 80 1 0 0 1 0 1 1 0 8 0 mbufpl 256 235 0 0 11 0 11 11 0 8 0 bufpl 256 7177 0 1162 376 0 376 376 0 8 0 anonpl 16 187054 0 181561 68 41 27 42 0 125 1 amapchunkpl 152 12486 0 12396 15 10 5 9 0 158 0 amappl16 192 7585 0 7261 79 62 17 28 0 8 0 amappl15 184 303 0 303 3 2 1 1 0 8 1 amappl14 176 465 0 460 2 1 1 1 0 8 0 amappl13 168 383 0 381 2 1 1 1 0 8 0 amappl12 160 134 0 131 1 0 1 1 0 8 0 amappl11 152 256 0 241 1 0 1 1 0 8 0 amappl10 144 190 0 185 1 0 1 1 0 8 0 amappl9 136 1081 0 1077 1 0 1 1 0 8 0 amappl8 128 569 0 545 1 0 1 1 0 8 0 amappl7 120 174 0 166 1 0 1 1 0 8 0 amappl6 112 185 0 179 1 0 1 1 0 8 0 amappl5 104 401 0 391 1 0 1 1 0 8 0 amappl4 96 1709 0 1683 1 0 1 1 0 8 0 amappl3 88 438 0 427 1 0 1 1 0 8 0 amappl2 80 11099 0 11029 4 2 2 3 0 8 0 amappl1 72 53989 0 53558 23 13 10 19 0 8 0 amappl 80 5010 0 4973 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 84 0 11 2 0 2 2 0 8 0 uaddrrnd 24 1718 0 1702 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 1718 0 1702 1 0 1 1 0 8 0 vmmpekpl 168 17979 0 17952 2 0 2 2 0 8 0 vmmpepl 168 197492 0 196090 125 57 68 77 0 357 2 vmsppl 360 1717 0 1702 2 0 2 2 0 8 0 pdppl 4096 3444 0 3404 6 0 6 6 0 8 0 pvpl 32 524070 0 514849 157 63 94 114 0 265 15 pmappl 232 1717 0 1702 4 3 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 530 0 4 16 0 16 16 0 8 0