Subject: Re: kauth sleepability (Re: CVS commit: src/share/man/man9)
To: None <elad@NetBSD.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-kern
Date: 07/22/2006 15:32:08
--NextPart-20060722153113-1341000
Content-Type: Text/Plain; charset=us-ascii

> > do you have a backtrace?
> 
> as a picture. :/
> 
> ftp.netbsd.org/pub/NetBSD/misc/elad/sleepable.jpg

comioctl() calls kauth_authorize_action with a spinlock (COM_LOCK) held,
thus not safe to sleep.  it's what we wanted to detect.

YAMAMOTO Takashi

--NextPart-20060722153113-1341000
Content-Type: Text/Plain; charset=us-ascii
Content-Disposition: attachment; filename="a.diff"

Index: com.c
===================================================================
--- com.c	(revision 1733)
+++ com.c	(working copy)
@@ -1022,6 +1022,18 @@ comioctl(dev_t dev, u_long cmd, caddr_t 
 		return (error);
 
 	error = 0;
+	switch (cmd) {
+	case TIOCSFLAGS:
+		error = kauth_authorize_generic(p->p_cred,
+		    KAUTH_GENERIC_ISSUSER, &p->p_acflag);
+		break;
+	default:
+		/* nothing */
+		break;
+	}
+	if (error) {
+		return error;
+	}
 
 	s = splserial();
 	COM_LOCK(sc);
@@ -1048,11 +1060,6 @@ comioctl(dev_t dev, u_long cmd, caddr_t 
 		break;
 
 	case TIOCSFLAGS:
-		error = kauth_authorize_generic(p->p_cred,
-					  KAUTH_GENERIC_ISSUSER,
-					  &p->p_acflag);
-		if (error)
-			break;
 		sc->sc_swflags = *(int *)data;
 		break;
 

--NextPart-20060722153113-1341000--