public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified
@ 2013-03-01  6:20 ghudson at mit dot edu
  2013-03-01 19:56 ` [Bug network/15218] " bugdal at aerifal dot cx
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ghudson at mit dot edu @ 2013-03-01  6:20 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15218

             Bug #: 15218
           Summary: getaddrinfo uses PTR records for canonname if address
                    family specified
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: network
        AssignedTo: unassigned@sourceware.org
        ReportedBy: ghudson@mit.edu
    Classification: Unclassified


Created attachment 6909
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6909
Test program demonstrating getaddrinfo issue

With today's master, getaddrinfo with AI_CANONNAME yields the right
ai_canonname (the result of CNAME resolution but not PTR lookup) if no other
hint fields are given.  However, if hint.ai_family is set to INET6, it appears
to do a PTR lookup.  The attached test program demonstrates the problem (the
first and third output lines in particular):

$ ./a.out ptr-mismatch.kerberos.org
AI_CANONNAME alone: www.kerberos.org
AI_ADDRCONFIG also: www.kerberos.org
ai_family AF_INET : KERBEROS-ORG.MIT.EDU
ai_family AF_INET6: Name or service not known

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
@ 2013-03-01 19:56 ` bugdal at aerifal dot cx
  2013-03-02  6:30 ` ghudson at mit dot edu
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bugdal at aerifal dot cx @ 2013-03-01 19:56 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15218

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> 2013-03-01 19:55:54 UTC ---
To clarify what's wrong: it was a common historic misunderstanding that
"canonical" name meant reverse DNS lookups. This was a cause of bad lookup
performance in applications that were using AI_CANNONNAME correctly and not
respecting it to perform PTR lookups. For a reference on why the PTR lookup is
incorrect, see the following paragraphs in POSIX:

>From DESCRIPTION of getaddrinfo:

"If the AI_CANONNAME flag is specified and the nodename argument is not null,
the function shall attempt to determine the canonical name corresponding to
nodename (for example, if nodename is an alias or shorthand notation for a
complete name).

Note:
Since different implementations use different conceptual models, the terms
``canonical name'' and ``alias'' cannot be precisely defined for the general
case. However, Domain Name System implementations are expected to interpret
them as they are used in RFC 1034.
A numeric host address string is not a ``name'', and thus does not have a
``canonical name'' form; no address to host name translation is performed. See
below for handling of the case where a canonical name cannot be obtained."

And from APPLICATION USAGE:

"The term ``canonical name'' is misleading; it is taken from the Domain Name
System (RFC 2181). It should be noted that the canonical name is a result of
alias processing, and not necessarily a unique attribute of a host, address, or
set of addresses. See RFC 2181 for more discussion of this in the Domain Name
System context."

Source:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
  2013-03-01 19:56 ` [Bug network/15218] " bugdal at aerifal dot cx
@ 2013-03-02  6:30 ` ghudson at mit dot edu
  2013-03-02  6:51 ` ghudson at mit dot edu
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ghudson at mit dot edu @ 2013-03-02  6:30 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15218

--- Comment #2 from Greg Hudson <ghudson at mit dot edu> 2013-03-02 06:29:42 UTC ---
Created attachment 6912
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6912
Candidate fix

I stepped through the code and found that:

* In the good case (hint.ai_family == 0), line 569 of gaih_inet does not
trigger and we continue on to the loop at line 832, using gethostbyname4_r
functions.  When the DNS function succeeds, we set canon from the result at
line 892.  This value of canon is later used for ai_canonname.

* In the bad case (hint.ai_family == AF_INET), line 569 of gaih_inet triggers
and we use __gethostbyname2_r for the lookup.  This branch of the code does not
set canon, so later on at line 1119, canon is still NULL.  The conditional
there kicks in and sets canon using __gethostbyaddr_r on the first address.

I think the code which uses __gethostbyname2_r ought to be able to set canon
using th.h_name.  If I use the attached patch, my test program gives the
correct answer with hint.ai_family == AF_INET.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
  2013-03-01 19:56 ` [Bug network/15218] " bugdal at aerifal dot cx
  2013-03-02  6:30 ` ghudson at mit dot edu
@ 2013-03-02  6:51 ` ghudson at mit dot edu
  2013-03-02  7:12 ` ghudson at mit dot edu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ghudson at mit dot edu @ 2013-03-02  6:51 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15218

Greg Hudson <ghudson at mit dot edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #6912|0                           |1
        is obsolete|                            |

--- Comment #3 from Greg Hudson <ghudson at mit dot edu> 2013-03-02 06:50:40 UTC ---
Created attachment 6913
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6913
Candidate fix 2

This updated patch is more consistent with how other branches of the function
set canon.

I believe h->h_name should still be valid by the time canon is used at the end
of the function, because it lives in tmpbuf just like it does in the
gethostbyname4_r case.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
                   ` (2 preceding siblings ...)
  2013-03-02  6:51 ` ghudson at mit dot edu
@ 2013-03-02  7:12 ` ghudson at mit dot edu
  2013-10-17 14:36 ` schwab@linux-m68k.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ghudson at mit dot edu @ 2013-03-02  7:12 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15218

--- Comment #4 from Greg Hudson <ghudson at mit dot edu> 2013-03-02 07:11:43 UTC ---
Another approach can be found at:

http://pkgs.fedoraproject.org/cgit/glibc.git/plain/glibc-fedora-gai-canonical.patch

which completely avoids the gethostbyname2_r path if AI_CANONNAME is requested,
and also rips out the code to use gethostbyaddr_r for canonname.  Although that
change is much more invasive than my candidate fix, it has received more
testing.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
                   ` (3 preceding siblings ...)
  2013-03-02  7:12 ` ghudson at mit dot edu
@ 2013-10-17 14:36 ` schwab@linux-m68k.org
  2014-02-16 19:41 ` jackie.rosen at hushmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: schwab@linux-m68k.org @ 2013-10-17 14:36 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=15218

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |2.19

--- Comment #5 from Andreas Schwab <schwab@linux-m68k.org> ---
Fixed by b957ced.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
                   ` (4 preceding siblings ...)
  2013-10-17 14:36 ` schwab@linux-m68k.org
@ 2014-02-16 19:41 ` jackie.rosen at hushmail dot com
  2014-05-28 19:41 ` schwab at sourceware dot org
  2014-06-13 18:46 ` fweimer at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 19:41 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15218

Jackie Rosen <jackie.rosen at hushmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jackie.rosen at hushmail dot com

--- Comment #6 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
                   ` (5 preceding siblings ...)
  2014-02-16 19:41 ` jackie.rosen at hushmail dot com
@ 2014-05-28 19:41 ` schwab at sourceware dot org
  2014-06-13 18:46 ` fweimer at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: schwab at sourceware dot org @ 2014-05-28 19:41 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15218

Andreas Schwab <schwab at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jackie.rosen at hushmail dot com   |

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified
  2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
                   ` (6 preceding siblings ...)
  2014-05-28 19:41 ` schwab at sourceware dot org
@ 2014-06-13 18:46 ` fweimer at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 18:46 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=15218

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-06-13 18:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-01  6:20 [Bug network/15218] New: getaddrinfo uses PTR records for canonname if address family specified ghudson at mit dot edu
2013-03-01 19:56 ` [Bug network/15218] " bugdal at aerifal dot cx
2013-03-02  6:30 ` ghudson at mit dot edu
2013-03-02  6:51 ` ghudson at mit dot edu
2013-03-02  7:12 ` ghudson at mit dot edu
2013-10-17 14:36 ` schwab@linux-m68k.org
2014-02-16 19:41 ` jackie.rosen at hushmail dot com
2014-05-28 19:41 ` schwab at sourceware dot org
2014-06-13 18:46 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).