Module Name:    src
Committed By:   riastradh
Date:           Wed Jun 29 22:10:43 UTC 2022

Modified Files:
        src/sys/kern: kern_ktrace.c kern_sleepq.c
        src/sys/sys: ktrace.h

Log Message:
ktrace(9): Fix mutex detection in ktrcsw.

On _entry_ to sleepq_block, l->l_syncobj is set so that ktrcsw
(ktr_csw) has the opportunity to detect whether it's a mutex or
rwlock.  It is critical to avoid ktealloc when we're sleeping on a
mutex because we may be in softint context where ktealloc is
forbidden.

But after mi_switch, on _exit_ from sleepq_block, l->l_syncobj may
have been changed back to &sched_syncobj or something by
sleepq_remove, and so ktrcsw can no longer rely on l->l_syncobj to
determine whether we _were_ sleeping on a mutex or not.

Instead, save the syncobj in sleepq_block and pass it through as an
argument to ktrcsw.

Reported-by: syzbot+414edba9d161b7502...@syzkaller.appspotmail.com
Reported-by: syzbot+4425c97ac717b1249...@syzkaller.appspotmail.com
Reported-by: syzbot+5812565b926ee8eb5...@syzkaller.appspotmail.com
Reported-by: syzbot+8b9d7b066c32dbcdc...@syzkaller.appspotmail.com
Reported-by: syzbot+909a8e743c967d97f...@syzkaller.appspotmail.com
Reported-by: syzbot+e2a34bb5509bea0bb...@syzkaller.appspotmail.com
Reported-by: syzbot+faaea3aad6c9d0829...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/sys/kern/kern_ktrace.c
cvs rdiff -u -r1.71 -r1.72 src/sys/kern/kern_sleepq.c
cvs rdiff -u -r1.67 -r1.68 src/sys/sys/ktrace.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Reply via email to