From owner-freebsd-net@FreeBSD.ORG Fri Nov 3 10:35:30 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D7F9216A417 for ; Fri, 3 Nov 2006 10:35:30 +0000 (UTC) (envelope-from antinvidia@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by mx1.FreeBSD.org (Postfix) with ESMTP id 004E943D46 for ; Fri, 3 Nov 2006 10:35:29 +0000 (GMT) (envelope-from antinvidia@gmail.com) Received: by nf-out-0910.google.com with SMTP id i2so1384478nfe for ; Fri, 03 Nov 2006 02:35:28 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=tJqF8UZopgiOBOTf4y9bjuNQ+KOPXSMjUEEYo3QlJI2ztw7dZRw7JlAhb4rEnq3r9tgFu2TM1VRrlMktD0KpCnAeOi4iKhDZ8oVVMeXSEoFT2Hq0OQJKCPTU3PPUXQE22/Z2xjTYXPH/a3YoeBDstTmYQ2lIfM/XYquot8Gyt68= Received: by 10.49.8.10 with SMTP id l10mr1061387nfi.1162550128463; Fri, 03 Nov 2006 02:35:28 -0800 (PST) Received: by 10.49.37.15 with HTTP; Fri, 3 Nov 2006 02:35:28 -0800 (PST) Message-ID: Date: Fri, 3 Nov 2006 10:35:28 +0000 From: MQ To: "Max Laier" In-Reply-To: <200611021232.45858.max@love2party.net> MIME-Version: 1.0 References: <20061102102807.GA23553@zen.inc> <4549C93A.9080308@delphij.net> <200611021232.45858.max@love2party.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-net@freebsd.org Subject: Re: Reentrant problem with inet_ntoa in the kernel X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Nov 2006 10:35:30 -0000 2006/11/2, Max Laier : > > On Thursday 02 November 2006 11:32, LI Xin wrote: > > VANHULLEBUS Yvan wrote: > > > On Thu, Nov 02, 2006 at 06:19:43PM +0800, LI Xin wrote: > > > [.....] > > > > > >> Sounds like a workaround to me and in theory that is insufficient > > >> for a MPSAFE protection. Here is a patch which reduces the chance > > >> where we get a race. > > > > > > Hi. > > > > > > This patch will allow multiple calls to inet_ntoa int the same > > > function (like printf(....., inet_ntoa(a), inet_ntoa(b))), but won't > > > really solve the race condition if inet_ntoa is called from 2 > > > differents functions at the same time: at least the round should be > > > locked to reduce potential problems, and you're still not sure that > > > no more than 8 "simultaneous" (or at least close enough) calls will > > > be done. > > > > True. That's exactly what I concern about, it just reduced the chance > > we lose a race, not to eliminate it. > > > > Note that the code is similar with what was found in ip6_sprintf, so it > > got same issue I think. > > Just what I was trying to say in my initial, cut-off reply. The question > we have to answer is, how much do we care about logging / console printfs > of IP numbers. AFAIK, console printf isn't (?wasn't?) synchronized > properly, either. In the end the caller has to decide how much it cares > about the result. Security related logging facilities should certainly > use a private buffer (or better yet, do the conversion in userland). All > I'm argueing is, that we should be aware of the sideeffects (substantial > grow in stack size) of the suggested patch and weight it carefully > against the benefit (100% correctness in the unlikeliest of cases). I > think that we can live with a 8 slot ring buffer for most of the cases. > Fixing the race on the round counter seems essential, however. > > -- > /"\ Best regards, | mlaier@freebsd.org > \ / Max Laier | ICQ #67774661 > X http://pf4freebsd.love2party.net/ | mlaier@EFnet > / \ ASCII Ribbon Campaign | Against HTML Mail and News > > > By the way, maybe printf should get better synchronized. When I was addressing some problems in the bge(4), the ill-synchronized printf made my console freezing before I restarted the machine.