NetBSD Problem Report #57609

From www@netbsd.org  Thu Sep  7 02:11:22 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B68451A9239
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  7 Sep 2023 02:11:21 +0000 (UTC)
Message-Id: <20230907021120.387F31A923A@mollari.NetBSD.org>
Date: Thu,  7 Sep 2023 02:11:20 +0000 (UTC)
From: hakan.engvall@gmail.com
Reply-To: hakan.engvall@gmail.com
To: gnats-bugs@NetBSD.org
Subject: getnameinfo(3)'s salen argument is interpreted too strictly
X-Send-Pr-Version: www-1.0

>Number:         57609
>Category:       lib
>Synopsis:       getnameinfo(3)'s salen argument is interpreted too strictly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 07 02:15:00 +0000 2023
>Closed-Date:    Mon Mar 11 22:15:22 +0000 2024
>Last-Modified:  Mon Mar 11 22:15:22 +0000 2024
>Originator:     Carl Engvall
>Release:        NetBSD 9.3_STABLE per 8/12/2023
>Organization:
>Environment:
NetBSD {hostname} 9.3_STABLE NetBSD 9.3_STABLE (SYN) #4: Mon Aug 14 18:20:20 EDT 2023  root@{hostname}:/usr/src/sys/arch/i386/compile/SYN i386
>Description:
getnameinfo(3) returns EAI_FAIL when salen is not equal to the corresponding length specified for the family (sa->sa_family). RFC 4038
Sec.6.2.3 shows an example passing sizeof(struct sockaddr_storage)
to salen. This has been adopted by software packages as well, e.g., collectd-5.12. 
>How-To-Repeat:
Code calling getnameinfo(3) in this way:

struct sockaddr_storage *address;
char host[48];

status = getnameinfo((struct sockaddr *)address,
         sizeof(struct sockaddr_storage), host, sizeof(host),
         NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV);

will return EAI_FAIL.

The software collectd-5.12 uses this code and the network module will fail to receive data.


>Fix:
Have the address family independent code accept the larger buffer length (sizeof(struct sockaddr_storage)) but adjust the salen value in the address family dependent functions.  FreeBSD has implemented it in this way.

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57609 CVS commit: src/lib/libc/net
Date: Fri, 8 Sep 2023 14:17:41 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Fri Sep  8 18:17:41 UTC 2023

 Modified Files:
 	src/lib/libc/net: getnameinfo.c

 Log Message:
 PR/57609: Carl Engvall: Add salen checks but accept larger sizes
 (upto sockaddr_storage)


 To generate a diff of this commit:
 cvs rdiff -u -r1.59 -r1.60 src/lib/libc/net/getnameinfo.c

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

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Fri, 23 Feb 2024 02:49:11 +0000
State-Changed-Why:
needs pullup-10, pullup-9, pullup-8
(could also stand an automatic test)


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Fri, 01 Mar 2024 15:10:05 +0000
State-Changed-Why:
pullup-10 #612
pullup-9 #1806
pullup-8 #1939


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57609 CVS commit: [netbsd-10] src/lib/libc/net
Date: Sun, 10 Mar 2024 13:44:35 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Mar 10 13:44:35 UTC 2024

 Modified Files:
 	src/lib/libc/net [netbsd-10]: getnameinfo.c

 Log Message:
 Pull up following revision(s) (requested by riastradh in ticket #612):

 	lib/libc/net/getnameinfo.c: revision 1.60

 PR/57609: Carl Engvall: Add salen checks but accept larger sizes
 (upto sockaddr_storage)


 To generate a diff of this commit:
 cvs rdiff -u -r1.59 -r1.59.26.1 src/lib/libc/net/getnameinfo.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57609 CVS commit: [netbsd-9] src/lib/libc/net
Date: Sun, 10 Mar 2024 13:46:04 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Mar 10 13:46:04 UTC 2024

 Modified Files:
 	src/lib/libc/net [netbsd-9]: getnameinfo.c

 Log Message:
 Pull up following revision(s) (requested by riastradh in ticket #1806):

 	lib/libc/net/getnameinfo.c: revision 1.60

 PR/57609: Carl Engvall: Add salen checks but accept larger sizes
 (upto sockaddr_storage)


 To generate a diff of this commit:
 cvs rdiff -u -r1.59 -r1.59.18.1 src/lib/libc/net/getnameinfo.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57609 CVS commit: [netbsd-8] src/lib/libc/net
Date: Sun, 10 Mar 2024 13:47:33 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Mar 10 13:47:32 UTC 2024

 Modified Files:
 	src/lib/libc/net [netbsd-8]: getnameinfo.c

 Log Message:
 Pull up following revision(s) (requested by riastradh in ticket #1939):

 	lib/libc/net/getnameinfo.c: revision 1.60

 PR/57609: Carl Engvall: Add salen checks but accept larger sizes
 (upto sockaddr_storage)


 To generate a diff of this commit:
 cvs rdiff -u -r1.59 -r1.59.8.1 src/lib/libc/net/getnameinfo.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: riastradh@NetBSD.org
State-Changed-When: Mon, 11 Mar 2024 22:15:22 +0000
State-Changed-Why:
fixed and pulled up


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.