From owner-freebsd-current@FreeBSD.ORG Mon Jan 31 13:42:55 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F126E16A4CF; Mon, 31 Jan 2005 13:42:55 +0000 (GMT) Received: from mp2.macomnet.net (mp2.macomnet.net [195.128.64.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 25F5443D46; Mon, 31 Jan 2005 13:42:55 +0000 (GMT) (envelope-from maxim@macomnet.ru) Received-SPF: pass (mp2.macomnet.net: domain of maxim@macomnet.ru designates 127.0.0.1 as permitted sender) receiver=mp2.macomnet.net; client_ip=127.0.0.1; envelope-from=maxim@macomnet.ru; Received: from localhost (localhost [127.0.0.1]) by mp2.macomnet.net (8.12.11/8.12.11) with ESMTP id j0VDgopi007633; Mon, 31 Jan 2005 16:42:50 +0300 (MSK) (envelope-from maxim@macomnet.ru) Date: Mon, 31 Jan 2005 16:42:50 +0300 (MSK) From: Maxim Konovalov To: Robert Watson In-Reply-To: Message-ID: <20050131164220.H7162@mp2.macomnet.net> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SpamTest-Info: Profile: Formal (206/050130) X-SpamTest-Info: Profile: Detect Hard (4/030526) X-SpamTest-Info: Profile: SysLog X-SpamTest-Info: Profile: Marking - Keywords (2/030321) X-SpamTest-Status: Not detected X-SpamTest-Version: SMTP-Filter Version 2.0.0 [0124], SpamtestISP/Release cc: current@FreeBSD.org Subject: Re: OpenBSD's tcpdrop(8) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jan 2005 13:42:56 -0000 On Mon, 31 Jan 2005, 13:14-0000, Robert Watson wrote: > > On Mon, 31 Jan 2005, Maxim Konovalov wrote: > > > > The locking in the 6.x version looked reasonable, although you need to > > > check to see if the (tp) returned by tcp_drop() is NULL or not and then > > > conditionally unlock the inpcb if it's non-NULL -- otherwise you might > > > unlock a free'd inpcb. There doesn't seem to be much validation of the > > > tcp_ident_mapping structure, such as validation that the address lengths, > > > etc, are correct? > > > > I've updated the diff for HEAD. How does it look now? TIA! > > The locking needs slightly more tweaking -- note that you still need to > unlock (inp) if (tp = intotcpcb(inp)) returns NULL, and right now that > won't happen. The "check tp for NULL" unlock case should only occur if > you call tcp_drop(). Perhaps something like this: > > INP_LOCK(inp); > if ((tp = intotcpcb(inp)) && > ((inp->inp_socket->so_options & SO_ACCEPTCONN) == 0)) { > tp = tcp_drop(tp, ECONNABORTED); > if (tp != NULL) > INP_UNLOCK(inp); > } else > INP_UNLOCK(inp); I see, updated. Thanks! -- Maxim Konovalov