From owner-freebsd-audit@FreeBSD.ORG Mon Apr 5 10:34:27 2004 Return-Path: Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C208916A4D3; Mon, 5 Apr 2004 10:34:27 -0700 (PDT) Received: from smtp2.enst.fr (reloaded.enst.fr [137.194.2.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6CFE43D62; Mon, 5 Apr 2004 10:34:26 -0700 (PDT) (envelope-from beyssac@enst.fr) Received: from bofh.enst.fr (bofh.enst.fr [137.194.32.191]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "bofh.enst.fr", Issuer "ENST CA" (verified OK)) by smtp2.enst.fr (Postfix) with ESMTP id 5EF5D21B; Mon, 5 Apr 2004 19:34:22 +0200 (CEST) Received: from enst.fr (localhost [127.0.0.1]) by bofh.enst.fr (8.12.11/8.12.11) with ESMTP id i35HYOAo003053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 5 Apr 2004 19:34:25 +0200 (CEST) (envelope-from beyssac@enst.fr) Received: (from beyssac@localhost) by enst.fr (8.12.11/8.12.11/Submit) id i35HYOlk003052; Mon, 5 Apr 2004 19:34:24 +0200 (CEST) (envelope-from beyssac) Date: Mon, 5 Apr 2004 19:34:24 +0200 From: Pierre Beyssac To: audit@FreeBSD.org Message-ID: <20040405173424.GA2440@bofh.enst.fr> References: <20040217161920.GB712@straylight.m.ringlet.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040217161920.GB712@straylight.m.ringlet.net> User-Agent: Mutt/1.4.2.1i X-message-flag: Warning! Use of Microsoft Outlook makes your system susceptible to worms and viruses cc: green@FreeBSD.org Subject: fix for getipnodebyname(3) X-BeenThere: freebsd-audit@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD Security Audit List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2004 17:34:27 -0000 getipnodebyname(3) as it stands in FreeBSD 4 and 5 has a problem with nameserver timeouts or misconfiguration. Symptom: getipnodebyname(3) lookups in unreachable/unconfigured zones return h_errno=HOST_NOT_FOUND instead of h_errno=TRY_AGAIN. It causes email to bounce at least with sendmail, which is quite annoying. Unless someone objects to it, I'd like to commit the following fix to current later today. Since FreeBSD 4 is impacted too, the patch will have to be adapted and MFC'd some day. The only potential problem I see with my patch is that it accesses h_errno, which is possibly not thread-safe. Could someone please shed some light on this for me? Pierre --- name6.c.old Wed Feb 25 23:27:17 2004 +++ name6.c Mon Apr 5 14:19:31 2004 @@ -1565,7 +1565,8 @@ continue; hp = _hpcopy(&hpbuf, errp); hp0 = _hpmerge(hp0, hp, errp); - } + } else + *errp = h_errno; } if (hp0 != NULL) { free(buf); @@ -1604,7 +1605,8 @@ continue; hp = _hpcopy(&hpbuf, errp); hp0 = _hpmerge(hp0, hp, errp); - } + } else + *errp = h_errno; } if (hp0 != NULL) { free(buf); @@ -1677,7 +1679,8 @@ continue; hp = _hpcopy(&hpbuf, errp); hp0 = _hpmerge(hp0, hp, errp); - } + } else + *errp = h_errno; } if (hp0 != NULL) { free(buf); @@ -1739,7 +1742,12 @@ rtl = &rtl4; #endif *(struct hostent **)rval = _res_search_multi(name, rtl, errp); - return (*(struct hostent **)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND; + if (*(struct hostent **)rval != NULL) + return NS_SUCCESS; + else if (*errp == TRY_AGAIN) + return NS_TRYAGAIN; + else + return NS_NOTFOUND; } static int -- Pierre Beyssac pb@freebsd.org From owner-freebsd-audit@FreeBSD.ORG Mon Apr 5 13:41:51 2004 Return-Path: Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B536216A4CE; Mon, 5 Apr 2004 13:41:51 -0700 (PDT) Received: from gw.celabo.org (gw.celabo.org [208.42.49.153]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BEDB43D1D; Mon, 5 Apr 2004 13:41:51 -0700 (PDT) (envelope-from nectar@celabo.org) Received: from localhost (localhost [127.0.0.1]) by gw.celabo.org (Postfix) with ESMTP id CA8815486E; Mon, 5 Apr 2004 15:41:50 -0500 (CDT) Received: from gw.celabo.org ([127.0.0.1]) by localhost (hellblazer.celabo.org [127.0.0.1]) (amavisd-new, port 10024) with SMTP id 73059-06; Mon, 5 Apr 2004 15:41:40 -0500 (CDT) Received: from lum.celabo.org (dhcp-207.celabo.org [10.0.1.207]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "lum.celabo.org", Issuer "celabo.org CA" (verified OK)) by gw.celabo.org (Postfix) with ESMTP id 21D1C54846; Mon, 5 Apr 2004 15:41:40 -0500 (CDT) Received: by lum.celabo.org (Postfix, from userid 501) id 4730B1B6580; Mon, 5 Apr 2004 15:41:12 -0500 (CDT) Date: Mon, 5 Apr 2004 15:41:12 -0500 From: "Jacques A. Vidrine" To: Pierre Beyssac Message-ID: <20040405204112.GA17398@lum.celabo.org> Mail-Followup-To: "Jacques A. Vidrine" , Pierre Beyssac , audit@FreeBSD.org, green@FreeBSD.org References: <20040217161920.GB712@straylight.m.ringlet.net> <20040405173424.GA2440@bofh.enst.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040405173424.GA2440@bofh.enst.fr> X-Url: http://www.celabo.org/ User-Agent: Mutt/1.5.6i cc: green@FreeBSD.org cc: audit@FreeBSD.org Subject: Re: fix for getipnodebyname(3) X-BeenThere: freebsd-audit@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD Security Audit List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Apr 2004 20:41:51 -0000 On Mon, Apr 05, 2004 at 07:34:24PM +0200, Pierre Beyssac wrote: > getipnodebyname(3) as it stands in FreeBSD 4 and 5 has a problem > with nameserver timeouts or misconfiguration. > > Symptom: getipnodebyname(3) lookups in unreachable/unconfigured > zones return h_errno=HOST_NOT_FOUND instead of h_errno=TRY_AGAIN. > > It causes email to bounce at least with sendmail, which is quite > annoying. > > Unless someone objects to it, I'd like to commit the following fix > to current later today. Since FreeBSD 4 is impacted too, the patch > will have to be adapted and MFC'd some day. > > The only potential problem I see with my patch is that it accesses > h_errno, which is possibly not thread-safe. Could someone please > shed some light on this for me? > > Pierre > > --- name6.c.old Wed Feb 25 23:27:17 2004 > +++ name6.c Mon Apr 5 14:19:31 2004 > @@ -1565,7 +1565,8 @@ > continue; > hp = _hpcopy(&hpbuf, errp); > hp0 = _hpmerge(hp0, hp, errp); > - } > + } else > + *errp = h_errno; > } > if (hp0 != NULL) { > free(buf); > @@ -1604,7 +1605,8 @@ > continue; > hp = _hpcopy(&hpbuf, errp); > hp0 = _hpmerge(hp0, hp, errp); > - } > + } else > + *errp = h_errno; > } > if (hp0 != NULL) { > free(buf); > @@ -1677,7 +1679,8 @@ > continue; > hp = _hpcopy(&hpbuf, errp); > hp0 = _hpmerge(hp0, hp, errp); > - } > + } else > + *errp = h_errno; > } > if (hp0 != NULL) { > free(buf); > @@ -1739,7 +1742,12 @@ > rtl = &rtl4; > #endif > *(struct hostent **)rval = _res_search_multi(name, rtl, errp); > - return (*(struct hostent **)rval != NULL) ? NS_SUCCESS : NS_NOTFOUND; > + if (*(struct hostent **)rval != NULL) > + return NS_SUCCESS; > + else if (*errp == TRY_AGAIN) > + return NS_TRYAGAIN; > + else > + return NS_NOTFOUND; > } > > static int This fix looks correct to me. Hey, Pierre, one wonders why you bothered posting a patch for review if you were just going to commit it less than 3 hours later? Please allow more time next time. Good catch, BTW :-) Cheers, -- Jacques Vidrine / nectar@celabo.org / jvidrine@verio.net / nectar@freebsd.org From owner-freebsd-audit@FreeBSD.ORG Tue Apr 6 02:25:24 2004 Return-Path: Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2D0C216A4CE; Tue, 6 Apr 2004 02:25:24 -0700 (PDT) Received: from smtp2.enst.fr (enst.enst.fr [137.194.2.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 98EB343D2D; Tue, 6 Apr 2004 02:25:23 -0700 (PDT) (envelope-from beyssac@enst.fr) Received: from bofh.enst.fr (bofh.enst.fr [137.194.32.191]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "bofh.enst.fr", Issuer "ENST CA" (verified OK)) by smtp2.enst.fr (Postfix) with ESMTP id CE3A853F7A; Tue, 6 Apr 2004 11:24:29 +0200 (CEST) Received: from enst.fr (localhost [127.0.0.1]) by bofh.enst.fr (8.12.11/8.12.11) with ESMTP id i369OU4T032287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 6 Apr 2004 11:24:30 +0200 (CEST) (envelope-from beyssac@enst.fr) Received: (from beyssac@localhost) by enst.fr (8.12.11/8.12.11/Submit) id i369OTJw032286; Tue, 6 Apr 2004 11:24:29 +0200 (CEST) (envelope-from beyssac) Date: Tue, 6 Apr 2004 11:24:29 +0200 From: Pierre Beyssac To: "Jacques A. Vidrine" , audit@FreeBSD.org Message-ID: <20040406092429.GA31642@bofh.enst.fr> References: <20040217161920.GB712@straylight.m.ringlet.net> <20040405173424.GA2440@bofh.enst.fr> <20040405204112.GA17398@lum.celabo.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040405204112.GA17398@lum.celabo.org> User-Agent: Mutt/1.4.2.1i X-message-flag: Warning! Use of Microsoft Outlook makes your system susceptible to worms and viruses Subject: Re: fix for getipnodebyname(3) X-BeenThere: freebsd-audit@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: FreeBSD Security Audit List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2004 09:25:24 -0000 On Mon, Apr 05, 2004 at 03:41:12PM -0500, Jacques A. Vidrine wrote: > This fix looks correct to me. Thanks for the review. Actually I just noticed I missed one occurence of "*errp = h_errno" that I'm going to fix right away. > Hey, Pierre, one wonders why you bothered posting a patch for review if > you were just going to commit it less than 3 hours later? Please allow > more time next time. Yes, I'm sorry, I was very anxious to get the fix committed and Brian answered privately regarding my main concern about threads. You're quite right, I'll leave more time for -audit next time. -- Pierre Beyssac pb@freebsd.org