witness: lock order reversal: 1st 0xffff800020b3b918 &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 __sanitizer_cov_trace_pc #7 mtx_leave+0x97 sys/kern/kern_lock.c:360 #8 sched_exit+0x112 sys/kern/kern_sched.c:225 #9 exit1+0x8bf sys/kern/kern_exit.c:349 #10 single_thread_check+0x144 sys/kern/kern_sig.c:1938 #11 userret+0x347 sys/kern/kern_sig.c:1907 #12 Xsyscall+0x156 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(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(ffff800020b38018) at schedclock+0x99 sys/kern/sched_bsd.c:547 hardclock(ffff800022bff860) 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,ffffffff81da3e90,0,0,ffffffff82243da0,ffff800020ab0ff0) at Xresume_lapic_ltimer+0x26 __sanitizer_cov_trace_pc() at __sanitizer_cov_trace_pc mtx_leave(ffff800020b3b908) at mtx_leave+0x97 sys/kern/kern_lock.c:360 sched_exit(ffff800020b38018) at sched_exit+0x112 sys/kern/kern_sched.c:225 exit1(ffff800020b38018,0,3) at exit1+0x8bf sys/kern/kern_exit.c:349 single_thread_check(ffff800020b38018,0) at single_thread_check+0x144 sys/kern/kern_sig.c:1938 userret(ffff800020b38018) at userret+0x347 sys/kern/kern_sig.c:1907 Xsyscall(6,0,68efd907c60,53,0,68f1e1f3c00) at Xsyscall+0x156 end of kernel end trace frame: 0x68fdb697b20, count: -14 ddb{1}> show registers rdi 0x3 rsi 0xffffffff82243e20 __sancov_gen_cov_switch_values.122 rbp 0xffff800022bff660 rbx 0x3 rdx 0xffff800020ab0ff0 rcx 0x3 rax 0xffff800020ab0ff0 r8 0xffffffff81da2df5 witness_checkorder+0xfd5 r9 0x5 r10 0x3 r11 0xa5c60ecebf4447ce r12 0xfffffd8002661340 r13 0xc r14 0xffffffff82337aa0 w_lodata+0x48bf0 r15 0xffffffff82346250 w_lodata+0x573a0 rip 0xffffffff819ca3d8 db_enter+0x18 cs 0x8 rflags 0x246 rsp 0xffff800022bff650 ss 0x10 db_enter+0x18: addq $0x8,%rsp ddb{1}> show proc PROC (syz-executor.0) pid=277662 stat=dead flags process=1010 proc=4082000 pri=78, usrpri=78, nice=20 forw=0xffffffffffffffff, list=0xffffffffffffffff,0xffffffffffffffff process=0xffff800020b3b858 user=0xffff800022bfa000, vmspace=0xfffffd807effdca8 estcpu=36, cpticks=1, pctcpu=0.0 user=0, sys=1, intr=0 ddb{1}> ps PID TID PPID UID S FLAGS WAIT COMMAND 25991 299102 78761 32767 3 0x3010 suspend syz-executor.0 25991 333639 78761 32767 7 0x4081090 syz-executor.0 78761 90103 16870 32767 3 0x90 nanosleep syz-executor.0 16870 167516 16638 0 3 0x82 wait syz-executor.0 9021 488385 42826 32767 3 0x10 biowait syz-executor.1 42826 161969 16638 0 3 0x82 wait syz-executor.1 20146 423038 0 0 3 0x14200 bored sosplice 16638 485870 29764 0 3 0x82 thrsleep syz-fuzzer 16638 271609 29764 0 3 0x4000082 nanosleep syz-fuzzer 16638 211032 29764 0 3 0x4000082 thrsleep syz-fuzzer 16638 303382 29764 0 3 0x4000082 thrsleep syz-fuzzer 16638 214341 29764 0 3 0x4000082 thrsleep syz-fuzzer 16638 361237 29764 0 3 0x4000082 kqread syz-fuzzer 16638 169125 29764 0 3 0x4000082 thrsleep syz-fuzzer 16638 18473 29764 0 3 0x4000082 thrsleep syz-fuzzer 16638 109374 29764 0 3 0x4000082 thrsleep syz-fuzzer 16638 131258 29764 0 3 0x4000082 nanosleep syz-fuzzer 29764 335369 99645 0 3 0x10008a pause ksh 99645 127540 93826 0 3 0x92 select sshd 44355 298093 1 0 3 0x100083 ttyin getty 93826 461514 1 0 3 0x80 select sshd 44250 517915 60398 73 2 0x100090 syslogd 60398 111156 1 0 3 0x100082 netio syslogd 2881 270870 1 77 3 0x100090 poll dhclient 75740 14456 1 0 3 0x80 poll dhclient 10878 318258 0 0 2 0x14200 zerothread 77715 230919 0 0 3 0x14200 aiodoned aiodoned 17579 454873 0 0 3 0x14200 syncer update 52804 140761 0 0 3 0x14200 cleaner cleaner 34966 201208 0 0 3 0x14200 reaper reaper 96135 390356 0 0 3 0x14200 pgdaemon pagedaemon 99434 326124 0 0 3 0x14200 bored crynlk 47113 10609 0 0 3 0x14200 bored crypto 70500 278809 0 0 3 0x40014200 acpi0 acpi0 139 303137 0 0 3 0x40014200 idle1 5904 431972 0 0 3 0x14200 bored softnet 50194 453767 0 0 3 0x14200 bored systqmp 10265 406405 0 0 3 0x14200 bored systq 62750 317968 0 0 3 0x40014200 bored softclock 16679 188293 0 0 3 0x40014200 idle0 79410 521024 0 0 3 0x14200 bored smr 1 444943 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 (0xffff800020b3b918) #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 single_thread_check+0x144 sys/kern/kern_sig.c:1938 #6 userret+0x347 sys/kern/kern_sig.c:1907 #7 Xsyscall+0x156 Process 9021 (syz-executor.1) thread 0xffff800020b392d8 (488385) exclusive rrwlock inode r = 0 (0xfffffd8068d5e708) #0 witness_lock+0x52e sys/kern/subr_witness.c:1161 #1 rw_enter+0x46d sys/kern/kern_rwlock.c:306 #2 rrw_enter+0x4f sys/kern/kern_rwlock.c:435 #3 ufs_ihashins+0x45 sys/ufs/ufs/ufs_ihash.c:140 #4 ffs_vget+0x133 sys/ufs/ffs/ffs_vfsops.c:1352 #5 ffs_inode_alloc+0x1cf sys/ufs/ffs/ffs_alloc.c:392 #6 ufs_mkdir+0xf4 sys/ufs/ufs/ufs_vnops.c:1164 #7 VOP_MKDIR+0x6a sys/kern/vfs_vops.c:449 #8 domkdirat+0x121 sys/kern/vfs_syscalls.c:2974 #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 exclusive rrwlock inode r = 0 (0xfffffd8068d5e5f8) #0 witness_lock+0x52e sys/kern/subr_witness.c:1161 #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:549 #5 vfs_lookup+0xe9 sys/kern/vfs_lookup.c:422 #6 namei+0x61c sys/kern/vfs_lookup.c:252 #7 domkdirat+0x75 sys/kern/vfs_syscalls.c:2959 #8 syscall+0x552 mi_syscall sys/sys/syscall_mi.h:99 [inline] #8 syscall+0x552 sys/arch/amd64/amd64/trap.c:574 #9 Xsyscall+0x128 ddb{1}> show malloc Type InUse MemUse HighUse Limit Requests Type Lim Kern Lim devbuf 9460 6321K 6321K 78643K 10767 0 0 pcb 23 9K 11K 78643K 1056 0 0 rtable 105 3K 3K 78643K 2160 0 0 ifaddr 36 11K 11K 78643K 310 0 0 counters 39 33K 33K 78643K 39 0 0 ioctlops 0 0K 2K 78643K 87 0 0 iov 0 0K 28K 78643K 126 0 0 mount 1 1K 1K 78643K 1 0 0 vnodes 1209 76K 76K 78643K 2391 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 22 0 0 VM map 2 1K 1K 78643K 2 0 0 sem 12 0K 1K 78643K 144 0 0 dirhash 12 2K 2K 78643K 12 0 0 ACPI 1808 196K 290K 78643K 12628 0 0 file desc 7 21K 33K 78643K 2264 0 0 sigio 0 0K 0K 78643K 35 0 0 proc 41 38K 70K 78643K 2303 0 0 subproc 34 2K 2K 78643K 782 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 210 0 0 in_multi 33 2K 2K 78643K 580 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 852 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 87 20K 31K 78643K 8266 0 0 UVM aobj 67 3K 3K 78643K 72 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 98 0 0 NDP 5 0K 0K 78643K 141 0 0 temp 121 2734K 2846K 78643K 12724 0 0 kqueue 0 0K 0K 78643K 35 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 94 0 88 1 0 1 1 0 8 0 inpcbpl 280 1041 0 1034 1 0 1 1 0 8 0 plimitpl 152 199 0 190 1 0 1 1 0 8 0 plcache 128 20 0 0 1 0 1 1 0 8 0 rtentry 112 529 0 485 2 0 2 2 0 8 0 syncache 264 4 0 4 1 1 0 1 0 8 0 tcpcb 544 409 0 405 1 0 1 1 0 8 0 ipq 40 1 0 1 1 1 0 1 0 8 0 ipqe 40 2 0 2 1 1 0 1 0 8 0 nd6 48 138 0 132 1 0 1 1 0 8 0 art_heap8 4096 1 0 0 1 0 1 1 0 8 0 art_heap4 256 2180 0 1988 14 1 13 13 0 8 1 art_table 32 2181 0 1988 2 0 2 2 0 8 0 art_node 16 528 0 488 1 0 1 1 0 8 0 sysvmsgpl 40 14 0 5 2 1 1 1 0 8 0 semapl 112 142 0 132 1 0 1 1 0 8 0 shmpl 112 70 0 5 2 0 2 2 0 8 0 dirhash 1024 17 0 0 3 0 3 3 0 8 0 dino1pl 128 3703 0 2255 47 0 47 47 0 8 0 ffsino 272 3703 0 2255 97 0 97 97 0 8 0 nchpl 144 6447 0 4828 61 0 61 61 0 8 0 uvmvnodes 72 4494 0 0 82 0 82 82 0 8 0 vnodes 200 4494 0 0 237 0 237 237 0 8 0 namei 1024 24432 0 24431 2 1 1 1 0 8 0 percpumem 16 30 0 0 1 0 1 1 0 8 0 scxspl 192 17070 0 17069 17 16 1 6 0 8 0 sigapl 432 2303 0 2288 5 3 2 3 0 8 0 futexpl 56 17163 0 17162 1 0 1 1 0 8 0 knotepl 112 1344 0 1325 1 0 1 1 0 8 0 kqueuepl 104 420 0 418 1 0 1 1 0 8 0 pipepl 112 1550 0 1531 6 5 1 2 0 8 0 fdescpl 488 2304 0 2288 3 0 3 3 0 8 1 filepl 152 13452 0 13356 12 7 5 7 0 8 1 lockfpl 104 382 0 382 5 4 1 1 0 8 1 lockfspl 48 125 0 125 5 4 1 1 0 8 1 sessionpl 112 61 0 51 1 0 1 1 0 8 0 pgrppl 48 84 0 74 1 0 1 1 0 8 0 ucredpl 96 4012 0 4003 1 0 1 1 0 8 0 zombiepl 144 2289 0 2288 2 1 1 1 0 8 0 processpl 888 2320 0 2288 4 0 4 4 0 8 0 procpl 600 5752 0 5709 4 0 4 4 0 8 0 srpgc 64 264 0 264 7 6 1 1 0 8 1 sosppl 128 17 0 17 6 6 0 1 0 8 0 sockpl 384 2118 0 2101 6 3 3 4 0 8 1 mcl64k 65536 5 0 0 1 0 1 1 0 8 0 mcl16k 16384 1 0 0 1 0 1 1 0 8 0 mcl12k 12288 6 0 0 1 0 1 1 0 8 0 mcl9k 9216 9 0 0 1 0 1 1 0 8 0 mcl8k 8192 6 0 0 1 0 1 1 0 8 0 mcl4k 4096 9 0 0 2 0 2 2 0 8 0 mcl2k2 2112 3 0 0 1 0 1 1 0 8 0 mcl2k 2048 118 0 0 14 0 14 14 0 8 0 mtagpl 80 1 0 0 1 0 1 1 0 8 0 mbufpl 256 266 0 0 11 0 11 11 0 8 0 bufpl 256 8639 0 1634 438 0 438 438 0 8 0 anonpl 16 252983 0 246952 89 47 42 42 0 125 12 amapchunkpl 152 18791 0 18705 41 36 5 18 0 158 0 amappl16 192 10024 0 9726 74 46 28 29 0 8 8 amappl15 184 327 0 325 4 3 1 1 0 8 0 amappl14 176 656 0 655 2 1 1 1 0 8 0 amappl13 168 351 0 351 4 4 0 1 0 8 0 amappl12 160 248 0 245 1 0 1 1 0 8 0 amappl11 152 388 0 374 1 0 1 1 0 8 0 amappl10 144 326 0 318 2 1 1 1 0 8 0 amappl9 136 1430 0 1426 1 0 1 1 0 8 0 amappl8 128 885 0 866 1 0 1 1 0 8 0 amappl7 120 350 0 337 1 0 1 1 0 8 0 amappl6 112 341 0 331 1 0 1 1 0 8 0 amappl5 104 630 0 620 1 0 1 1 0 8 0 amappl4 96 2287 0 2262 1 0 1 1 0 8 0 amappl3 88 631 0 620 1 0 1 1 0 8 0 amappl2 80 14446 0 14377 4 2 2 3 0 8 0 amappl1 72 69995 0 69551 24 14 10 19 0 8 0 amappl 80 6659 0 6624 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 71 0 5 2 0 2 2 0 8 0 uaddrrnd 24 2304 0 2288 1 0 1 1 0 8 0 uaddrbest 32 2 0 0 1 0 1 1 0 8 0 uaddr 24 2304 0 2288 1 0 1 1 0 8 0 vmmpekpl 168 22602 0 22572 2 0 2 2 0 8 0 vmmpepl 168 263328 0 261940 147 71 76 83 0 357 15 vmsppl 360 2303 0 2288 2 0 2 2 0 8 0 pdppl 4096 4616 0 4576 6 0 6 6 0 8 1 pvpl 32 712920 0 703679 202 88 114 114 0 265 34 pmappl 232 2303 0 2288 9 8 1 2 0 8 0 extentpl 40 41 0 26 1 0 1 1 0 8 0 phpool 112 594 0 4 17 0 17 17 0 8 0