From owner-svn-src-head@FreeBSD.ORG Wed Jul 29 05:10:00 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9F13106564A; Wed, 29 Jul 2009 05:10:00 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (chello087206049004.chello.pl [87.206.49.4]) by mx1.freebsd.org (Postfix) with ESMTP id 117B18FC2E; Wed, 29 Jul 2009 05:09:58 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id C88FC456B1; Wed, 29 Jul 2009 07:09:56 +0200 (CEST) Received: from localhost (chello087206049004.chello.pl [87.206.49.4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 8AD6345684; Wed, 29 Jul 2009 07:09:51 +0200 (CEST) Date: Wed, 29 Jul 2009 07:10:16 +0200 From: Pawel Jakub Dawidek To: Randall Stewart Message-ID: <20090729051016.GB3550@garage.freebsd.pl> References: <200907281409.n6SE971u034585@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yEPQxsgoJgBvi8ip" Content-Disposition: inline In-Reply-To: <200907281409.n6SE971u034585@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 8.0-CURRENT i386 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r195918 - head/sys/netinet X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2009 05:10:01 -0000 --yEPQxsgoJgBvi8ip Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jul 28, 2009 at 02:09:07PM +0000, Randall Stewart wrote: > Author: rrs > Date: Tue Jul 28 14:09:06 2009 > New Revision: 195918 > URL: http://svn.freebsd.org/changeset/base/195918 >=20 > Log: > Turns out that when a receiver forwards through its TNS's the > processing code holds the read lock (when processing a > FWD-TSN for pr-sctp). If it finds stranded data that > can be given to the application, it calls sctp_add_to_readq(). > The readq function also grabs this lock. So if INVAR is on > we get a double recurse on a non-recursive lock and panic. > =20 > This fix will change it so that readq() function gets a > flag to tell if the lock is held, if so then it does not > get the lock. > =20 > Approved by: re@freebsd.org (Kostik Belousov) > MFC after: 1 week [...] > sctp_add_to_readq(stcb->sctp_ep, stcb, control, > - &stcb->sctp_socket->so_rcv, 1, so_locked); > + &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD, so_locked); [...] > @@ -4301,6 +4306,7 @@ sctp_add_to_readq(struct sctp_inpcb *inp > struct sctp_queued_to_read *control, > struct sockbuf *sb, > int end, > + int inp_read_lock_held, > int so_locked > #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) > SCTP_UNUSED > @@ -4321,7 +4327,8 @@ sctp_add_to_readq(struct sctp_inpcb *inp > #endif > return; > } > - SCTP_INP_READ_LOCK(inp); > + if (inp_read_lock_held =3D=3D 0) It would be a bit cleaner to compare with SCTP_READ_LOCK_NOT_HELD here, instead of 0. > + SCTP_INP_READ_LOCK(inp); > if (!(control->spec_flags & M_NOTIFICATION)) { > atomic_add_int(&inp->total_recvs, 1); > if (!control->do_not_ref_stcb) { > @@ -4362,14 +4369,16 @@ sctp_add_to_readq(struct sctp_inpcb *inp > control->tail_mbuf =3D prev; > } else { > /* Everything got collapsed out?? */ > - SCTP_INP_READ_UNLOCK(inp); > + if (inp_read_lock_held =3D=3D 0) > + SCTP_INP_READ_UNLOCK(inp); > return; > } > if (end) { > control->end_added =3D 1; > } > TAILQ_INSERT_TAIL(&inp->read_queue, control, next); > - SCTP_INP_READ_UNLOCK(inp); > + if (inp_read_lock_held =3D=3D 0) > + SCTP_INP_READ_UNLOCK(inp); > if (inp && inp->sctp_socket) { > if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_ZERO_COPY_ACTIVE)) { > SCTP_ZERO_COPY_EVENT(inp, inp->sctp_socket); Instead of using additional argument to the sctp_add_to_readq() function, wouldn't it be sufficient to just check with mtx_owned(9) if the lock is already held? --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --yEPQxsgoJgBvi8ip Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFKb9m4ForvXbEpPzQRAh/FAJ0Uc/bklivoexP+BYV0cx6dFI69fwCgs6in SiImPQCzfLDftrdDiobxcDg= =W5Wi -----END PGP SIGNATURE----- --yEPQxsgoJgBvi8ip--