From nobody@FreeBSD.org  Wed May  9 05:06:39 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 72B97106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  9 May 2012 05:06:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 5DF778FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  9 May 2012 05:06:39 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q4956dtX004767
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 9 May 2012 05:06:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q4956dvV004766;
	Wed, 9 May 2012 05:06:39 GMT
	(envelope-from nobody)
Message-Id: <201205090506.q4956dvV004766@red.freebsd.org>
Date: Wed, 9 May 2012 05:06:39 GMT
From: Jinjun Gao <gjinjun@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: may missing PROC_UNLOCK() in kproc_suspend() of kern_kthread.c
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         167727
>Category:       kern
>Synopsis:       [kernel] maybe missing PROC_UNLOCK() in kproc_suspend() of kern_kthread.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 09 05:10:07 UTC 2012
>Closed-Date:    Wed May 09 21:25:12 UTC 2012
>Last-Modified:  Wed May 09 21:25:12 UTC 2012
>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:

From: Ivan Klymenko <fidaj@ukr.net>
To: bug-followup@FreeBSD.org, gjinjun@gmail.com
Cc:  
Subject: Re: kern/167727: [kernel] maybe missing PROC_UNLOCK() in
 kproc_suspend() of kern_kthread.c
Date: Wed, 9 May 2012 20:03:00 +0300

 After applying of these changes when rebooting the system kernel falls
 into panic of the form
 
 http://pazzle.otdux.com.ua/P5090103.JPG
State-Changed-From-To: open->closed 
State-Changed-By: avg 
State-Changed-When: Wed May 9 21:23:15 UTC 2012 
State-Changed-Why:  
Submitter misunderstood the code. 
Note to submitter: code reviews and discussion should be 
done via FreeBSD mailing lists, not the Problem Reports. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=167727 
>Unformatted:
