HomeFreeBSD

kthread: Set *tdptr earlier in kproc_kthread_add()

Description

kthread: Set *tdptr earlier in kproc_kthread_add()

See commit ae77041e0714 ("kthread: Set *newtdp earlier in
kthread_add1()") for details. That commit was incomplete since
g_init()'s first call to kproc_kthread_add() will cause
kproc_kthread_add() to take the *procptr == NULL branch, which avoids
kthread_create().

To ensure that the thread pointer is initialized before the thread
starts running, we have to start the kernel process with RFSTOPPED.
We could perhaps go further and use RFSTOPPED only when tdptr != NULL,
but it's probably better to have consistent behaviour.

Reviewed by: olce, kib
Reported by: syzbot+e91e798f3c088215ace6@syzkaller.appspotmail.com
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D44927

Details

Provenance
markjAuthored on Apr 25 2024, 1:35 PM
Reviewer
olce
Differential Revision
D44927: kthread: Set *tdptr earlier in kproc_kthread_add()
Parents
rG42255af64a54: checkstyle9: Allow a space between "*" and _*restrict
Branches
Unknown
Tags
Unknown