mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Barry Bond <barrybo@microsoft.com>
Cc: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: Re: [musl] Behavior change in getaddrbyname() with AF_UNSPEC
Date: Wed, 18 Jan 2023 10:26:45 -0500	[thread overview]
Message-ID: <20230118152645.GG4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <DM6PR21MB16119FB8E9D5AE1E364D42ABB6C39@DM6PR21MB1611.namprd21.prod.outlook.com>

On Sat, Jan 14, 2023 at 10:56:28PM +0000, Barry Bond wrote:
> This is related to this change:  https://git.musl-libc.org/cgit/musl/commit/?id=5cf1ac2443ad0dba263559a3fe043d929e0e5c4c made back in 2020.
> 
> In the repro case, getaddrbyname() with AF_UNSPEC sends out two
> requests, but only gets back a single response, with the ipv4
> address. There is no ipv6 on the network.
> 
> name_from_dns() contains the relevant code. After __res_msend_rc()
> returns, 'nq' is 2, and 'alens' is [96, 0], indicating that there
> was an ipv4 response of 96 bytes, but no response for ipv6. Then the
> validation code runs:
> 
>                 for (i=0; i<nq; i++) {
>                                 if (alens[i] < 4 || (abuf[i][3] & 15) == 2) return EAI_AGAIN;
>                                 if ((abuf[i][3] & 15) == 3) return 0;
>                                 if ((abuf[i][3] & 15) != 0) return EAI_FAIL;
>                 }
> 
> and the result is EAI_AGAIN, because alens[1]==0.
> 
> Before this patch, the code would have parsed the ipv4 response via
> __dns_parse(), failed to parse the empty second response because
> alens[1]<12, and the function would return with ctx.cnt==1.

That was the wrong behavior that this patch fixed. Previously, the
query was timing out, but because there was an answer to the other
query, we were erroneously hiding the failure from the application and
presenting a timing-/network-congestion-dependent incorrect result
(wrongly claiming only A or only AAAA exist when in fact we didn't get
enough information to make that determination).

"There is no ipv6 on the network" is not cause for the AAAA query to
timeout. The ability to lookup a particular RR type has nothing to do
with what network protocols are supported on your network. Can you
describe the environment this is happening in and why it might be
happening?

Rich

  reply	other threads:[~2023-01-18 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14 22:56 Barry Bond
2023-01-18 15:26 ` Rich Felker [this message]
2023-01-19 14:58   ` [musl] RE: [EXTERNAL] " Barry Bond
2023-01-23  1:34     ` [musl] " Barry Bond
2023-01-24  8:54       ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230118152645.GG4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=barrybo@microsoft.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).