Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2012 05:06:39 GMT
From:      Jinjun Gao <gjinjun@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/167727: may missing PROC_UNLOCK() in kproc_suspend() of kern_kthread.c
Message-ID:  <201205090506.q4956dvV004766@red.freebsd.org>
Resent-Message-ID: <201205090510.q495A7Kl099961@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         167727
>Category:       kern
>Synopsis:       may missing PROC_UNLOCK() in kproc_suspend() of kern_kthread.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 09 05:10:07 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Jinjun Gao
>Release:        7-release
>Organization:
>Environment:
FreeBSD 7.0-RELEASE FreeBSD 7-RELEASE #0: Sun Feb 24 10:35:36 UTC 2008     root@driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
In kernel's thread suspend code, maybe miss PROC_UNLOCK call.
kernel code: sys/kern/kern_kthread.c
...
/*
 * Advise a kernel process to suspend (or resume) in its main loop.
 * Participation is voluntary.
 */
int
kproc_suspend(struct proc *p, int timo)
{
	/*
	 * Make sure this is indeed a system process and we can safely
	 * use the p_siglist field.
	 */
	PROC_LOCK(p);
	if ((p->p_flag & P_KTHREAD) == 0) {
		PROC_UNLOCK(p);
		return (EINVAL);
	}
	SIGADDSET(p->p_siglist, SIGSTOP);
	wakeup(p);
	return msleep(&p->p_siglist, &p->p_mtx, PPAUSE | PDROP, "suspkp", timo);
}

We should add PROC_UNLOCK(p) after SIGADDSET(p->p_siglist, SIGSTOP).
>How-To-Repeat:
You can find these code at kernel source code.
>Fix:
add PROC_UNLOCK(p) after SIGADDSET(p->p_siglist, SIGSTOP);

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205090506.q4956dvV004766>