NetBSD Problem Report #46454

From www@NetBSD.org  Tue May 15 07:06:16 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id D2B4063C785
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 15 May 2012 07:06:15 +0000 (UTC)
Message-Id: <20120515070614.DA1B763B86B@www.NetBSD.org>
Date: Tue, 15 May 2012 07:06:14 +0000 (UTC)
From: naruse@airemix.jp
Reply-To: naruse@airemix.jp
To: gnats-bugs@NetBSD.org
Subject: getnameinfo(3) is not thread-safe
X-Send-Pr-Version: www-1.0

>Number:         46454
>Category:       lib
>Synopsis:       getnameinfo(3) is not thread-safe
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 15 07:10:00 +0000 2012
>Closed-Date:    Mon Dec 23 23:27:49 +0000 2013
>Last-Modified:  Mon Dec 23 23:27:49 +0000 2013
>Originator:     Yui NARUSE
>Release:        6.99.4
>Organization:
>Environment:
NetBSD nbsd.rubyci.org 6.99.4 NetBSD 6.99.4 (GENERIC) #0: Fri Apr 13 00:47:23 JST 2012  naruse@nbsd.rubyci.org:/usr/obj/sys/arch/i386/compile/GENERIC i386
>Description:
SuS says getnameinfo(3) shall be thread-safe.
But NetBSD's getnameinfo(3) uses gethostbyaddr(3), which is not thread-safe.
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html
http://pubs.opengroup.org/onlinepubs/009695399/functions/gethostbyname.html
(gethostbyname is removed in SuSv7)

getnameinfo() calls getpeername(),
getpeername() calls nsdispatch(),
nsdispatch() calls _gethtbyaddr() with rdlock,
_gethtbyaddr() calls _gethtent().
_gethtent() uses static variable hostf.
If someone calls _endhtent() during one runs _gethtent(),
_endhtent() sets NULL to hostf, and _gethtent() will cause SEGV.


The original issue is derived from Ruby's test case https://gist.github.com/2695368
and this report is helped by enami.
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 16 Aug 2013 16:03:38 +0000
State-Changed-Why:
Christos committed a fix, please inspect/test


From: "NARUSE, Yui" <naruse@airemix.jp>
To: gnats-bugs@netbsd.org
Cc: lib-bug-people@netbsd.org, netbsd-bugs@netbsd.org, gnats-admin@netbsd.org, 
	dholland@netbsd.org
Subject: Re: lib/46454 (getnameinfo(3) is not thread-safe)
Date: Tue, 20 Aug 2013 19:51:44 +0900

 I confirmed our own tests, which pararellely uses getnameinfo(3), now works.
 Thanks!

 2013/8/17  <dholland@netbsd.org>:
 > Synopsis: getnameinfo(3) is not thread-safe
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: dholland@NetBSD.org
 > State-Changed-When: Fri, 16 Aug 2013 16:03:38 +0000
 > State-Changed-Why:
 > Christos committed a fix, please inspect/test
 >
 >
 >



 -- 
 NARUSE, Yui  <naruse@airemix.jp>

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 31 Aug 2013 19:13:30 +0000
State-Changed-Why:
confirmed fixed, thanks


From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/46454 (getnameinfo(3) is not thread-safe)
Date: Sat, 2 Nov 2013 19:33:00 +0000

 not sent to gnats-bugs:

    ------

 From: Christoph Badura <bad@bsd.de>
 To: gnats-admin@netbsd.org
 Subject: Re: lib/46454 (getnameinfo(3) is not thread-safe)
 Date: Tue, 22 Oct 2013 12:35:40 +0200

 These fixes need to be pulled up to the netbsd-5 and netbsd-6 branches.
 The problem exists there too.

 Requests sent.

 --chris

State-Changed-From-To: closed->pending-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 02 Nov 2013 19:44:28 +0000
State-Changed-Why:
pullup-6 #975, pullup-5 #1887


From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46454 CVS commit: [netbsd-6] src/lib/libc/net
Date: Mon, 23 Dec 2013 22:56:48 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Mon Dec 23 22:56:48 UTC 2013

 Modified Files:
 	src/lib/libc/net [netbsd-6]: getaddrinfo.c gethnamaddr.c

 Log Message:
 Apply additional patches (requested by bad in ticket #975):

 src/lib/libc/net/getaddrinfo.c r1.106:
 this is supposed to be re-entrant, call don't call __hostalias that uses
 a static buffer.

 src/lib/libc/net/gethnamaddr.c r1.85:
 - don't clobber hp in the RES_USE_INET6 case
 - increment naddrs in the yp case
 - don't use __hostalias(), it is not thread-safe.

 Fixes additional issues in PR lib/46454


 To generate a diff of this commit:
 cvs rdiff -u -r1.96.4.1 -r1.96.4.2 src/lib/libc/net/getaddrinfo.c
 cvs rdiff -u -r1.77.4.1 -r1.77.4.2 src/lib/libc/net/gethnamaddr.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46454 CVS commit: [netbsd-5] src/lib/libc/net
Date: Mon, 23 Dec 2013 23:12:44 +0000

 Module Name:	src
 Committed By:	riz
 Date:		Mon Dec 23 23:12:44 UTC 2013

 Modified Files:
 	src/lib/libc/net [netbsd-5]: getaddrinfo.c gethnamaddr.c

 Log Message:
 Apply patch (requested by bad in ticket #1887):

 src/lib/libc/net/getaddrinfo.c r1.106:
 this is supposed to be re-entrant, call don't call __hostalias that uses
 a static buffer.

 src/lib/libc/net/gethnamaddr.c r1.85:
 - don't clobber hp in the RES_USE_INET6 case
 - increment naddrs in the yp case
 - don't use __hostalias(), it is not thread-safe.

 This should finish addressing PR lib/46454


 To generate a diff of this commit:
 cvs rdiff -u -r1.91.6.1 -r1.91.6.2 src/lib/libc/net/getaddrinfo.c
 cvs rdiff -u -r1.73.18.2 -r1.73.18.3 src/lib/libc/net/gethnamaddr.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 23 Dec 2013 23:27:49 +0000
State-Changed-Why:
pulled up


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.