NetBSD Problem Report #48475

From www@NetBSD.org  Tue Dec 24 02:36:40 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 6AC28A642D
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 24 Dec 2013 02:36:40 +0000 (UTC)
Message-Id: <20131224023627.44FF6A6469@mollari.NetBSD.org>
Date: Tue, 24 Dec 2013 02:36:27 +0000 (UTC)
From: y@maya.st
Reply-To: y@maya.st
To: gnats-bugs@NetBSD.org
Subject: "options edns0" in /etc/resolv.conf (or RES_OPTIONS=edns0) is broken
X-Send-Pr-Version: www-1.0

>Number:         48475
>Category:       lib
>Synopsis:       "options edns0" in /etc/resolv.conf (or RES_OPTIONS=edns0) is broken
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 24 02:40:00 +0000 2013
>Closed-Date:    Sun Dec 07 17:08:31 +0000 2014
>Last-Modified:  Sun Dec 07 17:08:31 +0000 2014
>Originator:     YAMAGUCHI Takanori
>Release:        NetBSD 6.1.2
>Organization:
>Environment:
NetBSD 6.1.2 (GENERIC) i386
>Description:
When enables edns0 in resolv.conf, resolver sends a query that UDP payload size is always 0. It must be larger than 512.
Unbound caching dns server returns SERVFAIL response to that query.
>How-To-Repeat:
% cat /etc/resolv.conf
nameserver 127.0.0.1     # unbound
options edns0
% getent hosts www.netbsd.org

>Fix:
--- lib/libc/resolv/res_mkquery.c.orig  2012-03-14 13:31:08.000000000 +0900
+++ lib/libc/resolv/res_mkquery.c       2013-12-24 10:17:56.000000000 +0900
@@ -251,6 +251,8 @@
        *cp++ = 0;                              /*%< "." */
        ns_put16(ns_t_opt, cp);                 /*%< TYPE */
        cp += INT16SZ;
+       if (anslen > 0xffff)
+               anslen = 0xffff;
        ns_put16(anslen & 0xffff, cp);          /*%< CLASS = UDP payload size */
        cp += INT16SZ;
        *cp++ = NOERROR;                        /*%< extended RCODE */

same as:
http://svnweb.freebsd.org/base/head/lib/libc/resolv/res_mkquery.c?r1=156953&r2=156956
http://www.freshbsd.org/commit/openbsd/16a3d261bc0fcded7d8d515415436c5b5f2e291a

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48475 CVS commit: src/lib/libc/resolv
Date: Mon, 10 Nov 2014 22:29:24 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Tue Nov 11 03:29:24 UTC 2014

 Modified Files:
 	src/lib/libc/resolv: res_mkquery.c

 Log Message:
 PR/48475: YAMAGUCHI Takanori: EDNS option broken with unbound. struct
 querybuf in net/gethnamaddr.c defines MAXPACKET to 64K. This in turn
 gets passed down until it reached res_nopt(..., answer, anslen), where
 the size of the buffer must fit in 16 bits. Unfortunately we end up
 being one more than the max so we end up sending a 0 as the size and
 unbound does not like that. Instead we clip now to 64K - 1, and everyone
 is happy.
 XXX: Pullup to 7.


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.14 src/lib/libc/resolv/res_mkquery.c

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

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: PR/48475 CVS commit: src/lib/libc/resolv
Date: Tue, 11 Nov 2014 17:23:36 +0700

     Date:        Tue, 11 Nov 2014 03:30:00 +0000 (UTC)
     From:        "Christos Zoulas" <christos@netbsd.org>
     Message-ID:  <20141111033001.4E16CA668B@mollari.NetBSD.org>


   |  PR/48475: YAMAGUCHI Takanori: EDNS option broken
   |  XXX: Pullup to 7.

 and 6 and 5 please - they all have the exact same code (all current
 tracked versions)

 kre

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48475 CVS commit: [netbsd-7] src/lib/libc/resolv
Date: Wed, 12 Nov 2014 13:54:14 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Nov 12 13:54:13 UTC 2014

 Modified Files:
 	src/lib/libc/resolv [netbsd-7]: res_mkquery.c

 Log Message:
 Pull up following revision(s) (requested by christos in ticket #213):
 	lib/libc/resolv/res_mkquery.c: revision 1.14
 PR/48475: YAMAGUCHI Takanori: EDNS option broken with unbound. struct
 querybuf in net/gethnamaddr.c defines MAXPACKET to 64K. This in turn
 gets passed down until it reached res_nopt(..., answer, anslen), where
 the size of the buffer must fit in 16 bits. Unfortunately we end up
 being one more than the max so we end up sending a 0 as the size and
 unbound does not like that. Instead we clip now to 64K - 1, and everyone
 is happy.
 XXX: Pullup to 7.


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.13.10.1 src/lib/libc/resolv/res_mkquery.c

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

From: "Stephen Borrill" <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48475 CVS commit: [netbsd-5] src/lib/libc/resolv
Date: Thu, 20 Nov 2014 08:41:32 +0000

 Module Name:	src
 Committed By:	sborrill
 Date:		Thu Nov 20 08:41:31 UTC 2014

 Modified Files:
 	src/lib/libc/resolv [netbsd-5]: res_mkquery.c

 Log Message:
 Pull up the following revisions(s) (requested by christos in ticket #1932):
 	lib/libc/resolv/res_mkquery.c:	revision 1.14

 Fix EDNS option being broken with unbound by clipping MAXPACKET to
 64K - 1. Addresses PR/48475


 To generate a diff of this commit:
 cvs rdiff -u -r1.10.4.1 -r1.10.4.2 src/lib/libc/resolv/res_mkquery.c

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

From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48475 CVS commit: [netbsd-6] src/lib/libc/resolv
Date: Tue, 2 Dec 2014 21:56:37 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Tue Dec  2 21:56:37 UTC 2014

 Modified Files:
 	src/lib/libc/resolv [netbsd-6]: res_mkquery.c

 Log Message:
 Pull up following revision(s) (requested by pettai in ticket #1191):
 	lib/libc/resolv/res_mkquery.c: revision 1.14
 PR/48475: YAMAGUCHI Takanori: EDNS option broken with unbound. struct
 querybuf in net/gethnamaddr.c defines MAXPACKET to 64K. This in turn
 gets passed down until it reached res_nopt(..., answer, anslen), where
 the size of the buffer must fit in 16 bits. Unfortunately we end up
 being one more than the max so we end up sending a 0 as the size and
 unbound does not like that. Instead we clip now to 64K - 1, and
 everyone is happy.


 To generate a diff of this commit:
 cvs rdiff -u -r1.12 -r1.12.8.1 src/lib/libc/resolv/res_mkquery.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->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 07 Dec 2014 17:08:31 +0000
State-Changed-Why:
fixed and pulled up, thanks all


>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-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.