From owner-svn-src-all@FreeBSD.ORG Sat Nov 8 14:07:56 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C9F5E1065676; Sat, 8 Nov 2008 14:07:56 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 64BBC8FC17; Sat, 8 Nov 2008 14:07:56 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1KyoTj-0007ur-Cj; Sat, 08 Nov 2008 16:07:55 +0200 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id mA8E7p7S075098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 8 Nov 2008 16:07:51 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id mA8E7p6O040537; Sat, 8 Nov 2008 16:07:51 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id mA8E7p8u040536; Sat, 8 Nov 2008 16:07:51 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 8 Nov 2008 16:07:50 +0200 From: Kostik Belousov To: Attilio Rao Message-ID: <20081108140750.GI18100@deviant.kiev.zoral.com.ua> References: <200811080625.mA86Pvhw003486@svn.freebsd.org> <3bbf2fe10811080513x2b8bd201gcf24562360374494@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0ne7FPUD+ABQNzTq" Content-Disposition: inline In-Reply-To: <3bbf2fe10811080513x2b8bd201gcf24562360374494@mail.gmail.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1KyoTj-0007ur-Cj c1bec0b5b9a363ef23bfe4e91dc135df X-Terabit: YES Cc: svn-src-head@freebsd.org, Alexander Motin , src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r184762 - head/sys/netgraph X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Nov 2008 14:07:57 -0000 --0ne7FPUD+ABQNzTq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 08, 2008 at 02:13:46PM +0100, Attilio Rao wrote: > 2008/11/8, Alexander Motin : > > Author: mav > > Date: Sat Nov 8 06:25:57 2008 > > New Revision: 184762 > > URL: http://svn.freebsd.org/changeset/base/184762 > > > > Log: > > Don't use curthread to resolve file descriptor. Request may be queued= , so > > thread will be different. Instead require sender to send process ID > > together with file descriptor. > > > > Modified: > > head/sys/netgraph/ng_tty.c > > > > Modified: head/sys/netgraph/ng_tty.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/sys/netgraph/ng_tty.c Sat Nov 8 04:43:24 2008 (r1847= 61) > > +++ head/sys/netgraph/ng_tty.c Sat Nov 8 06:25:57 2008 (r1847= 62) > > @@ -73,6 +73,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -250,7 +251,8 @@ ngt_shutdown(node_p node) > > static int > > ngt_rcvmsg(node_p node, item_p item, hook_p lasthook) > > { > > - struct thread *td =3D curthread; /* XXX */ > > + struct proc *p; > > + struct thread *td; > > const sc_p sc =3D NG_NODE_PRIVATE(node); > > struct ng_mesg *msg, *resp =3D NULL; > > int error =3D 0; > > @@ -262,8 +264,14 @@ ngt_rcvmsg(node_p node, item_p item, hoo > > case NGM_TTY_SET_TTY: > > if (sc->tp !=3D NULL) > > return (EBUSY); > > - error =3D ttyhook_register(&sc->tp, td, *(int = *)msg->data, > > + > > + p =3D pfind(((int *)msg->data)[0]); > > + if (p =3D=3D NULL) > > + return (ESRCH); > > + td =3D FIRST_THREAD_IN_PROC(p); > > + error =3D ttyhook_register(&sc->tp, td, ((int = *)msg->data)[1], > > &ngt_hook, sc); > > + PROC_UNLOCK(p); > > if (error !=3D 0) > > return (error); > > break; >=20 > The threads iterator in strcut proc should be proc_slock protected, so > you need to grab/release it around FIRST_THREAD_IN_PROC(). I do not believe that process slock is needed there, since code just dereference a pointer. The process lock seems to be taken to guarantee that td is alive. On the other hand, ttyhook_register locks filedesc sx, that causes sleepable lock acquition after non-sleepable. I believe this is an actual problem with the change. Probably, this is even the problem with KPI of ttyhook_register, since caller need to somehow protect td from going away, and proc lock is a right lock to held. --0ne7FPUD+ABQNzTq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkkVnTYACgkQC3+MBN1Mb4iSpACgicliFnkeSuGSowkg1mkmfg7Z tVUAn3A4KqCxgaQafJj5XDS9wXCAzKcY =+bB6 -----END PGP SIGNATURE----- --0ne7FPUD+ABQNzTq--