<feed xmlns='http://www.w3.org/2005/Atom'>
<title>musl/src/network, branch v1.2.5</title>
<subtitle>musl - an implementation of the standard library for Linux-based systems</subtitle>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/'/>
<entry>
<title>getnameinfo: fix calling __dns_parse with potentially too large rlen</title>
<updated>2024-02-29T15:14:16+00:00</updated>
<author>
<name>Alexey Izbyshev</name>
<email>izbyshev@ispras.ru</email>
</author>
<published>2023-05-08T16:03:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=5c653ccaa1383db0c310abf66d5b6806e83ac18f'/>
<id>5c653ccaa1383db0c310abf66d5b6806e83ac18f</id>
<content type='text'>
__res_send returns the full answer length even if it didn't fit the
buffer, but __dns_parse expects the length of the filled part of the
buffer.

This is analogous to commit 77327ed064bd57b0e1865cd0e0364057ff4a53b4,
which fixed the only other __dns_parse call site.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
__res_send returns the full answer length even if it didn't fit the
buffer, but __dns_parse expects the length of the filled part of the
buffer.

This is analogous to commit 77327ed064bd57b0e1865cd0e0364057ff4a53b4,
which fixed the only other __dns_parse call site.
</pre>
</div>
</content>
</entry>
<entry>
<title>remove arbitrary limit from dns result parsing</title>
<updated>2023-11-06T18:50:21+00:00</updated>
<author>
<name>Quentin Rameau</name>
<email>quinq@fifth.space</email>
</author>
<published>2023-10-04T19:29:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=8c086e767468cc11c6d58d6a92d8511c2bd12024'/>
<id>8c086e767468cc11c6d58d6a92d8511c2bd12024</id>
<content type='text'>
The name resolution would abort when getting more than 63 records per
request, due to what seems to be a left-over from the original code.
This check was non-breaking but spurious prior to TCP fallback
support, since any 512-byte packet with more than 63 records was
necessarily malformed. But now, it wrongly rejects valid results.

Reported by Daniel Stefanik in Alpine Linux aports issue 15320.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The name resolution would abort when getting more than 63 records per
request, due to what seems to be a left-over from the original code.
This check was non-breaking but spurious prior to TCP fallback
support, since any 512-byte packet with more than 63 records was
necessarily malformed. But now, it wrongly rejects valid results.

Reported by Daniel Stefanik in Alpine Linux aports issue 15320.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix rejection of dns responses with pointers past 512 byte offset</title>
<updated>2023-07-17T22:03:38+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2023-07-17T22:03:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=83b858f83b658bd34eca5d8ad4d145f673ae7e5e'/>
<id>83b858f83b658bd34eca5d8ad4d145f673ae7e5e</id>
<content type='text'>
the __dns_parse code used by the stub resolver traditionally included
code to reject label pointers to offsets past a 512 byte limit,
despite never processing the label contents, only stepping over them.
when commit 51d4669fb97782f6a66606da852b5afd49a08001 added support for
tcp fallback, this limit was overlooked, and as a result, it was at
least theoretically possible for some valid large answers to be
rejected on account of these offsets.

since the limit was never serving any useful purpose, just remove it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the __dns_parse code used by the stub resolver traditionally included
code to reject label pointers to offsets past a 512 byte limit,
despite never processing the label contents, only stepping over them.
when commit 51d4669fb97782f6a66606da852b5afd49a08001 added support for
tcp fallback, this limit was overlooked, and as a result, it was at
least theoretically possible for some valid large answers to be
rejected on account of these offsets.

since the limit was never serving any useful purpose, just remove it.
</pre>
</div>
</content>
</entry>
<entry>
<title>dns stub resolver: increase buffer size to handle chained CNAMEs</title>
<updated>2023-07-05T03:36:05+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2023-07-05T03:11:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=a4ecaf89a9b88df76e8bf9f28e1cc6cb89e4bfa8'/>
<id>a4ecaf89a9b88df76e8bf9f28e1cc6cb89e4bfa8</id>
<content type='text'>
in the event of chained CNAMEs, the answer to a query will contain the
entire CNAME chain, not just one CNAME record. previously, the answer
buffer size had been chosen to admit a maximal-length CNAME, but only
one. a moderate-length chain could fill the available 768 bytes
leaving no room for an actual address answering the query.

while the DNS RFCs do not specify any limit on the length of a CNAME
chain, or any reasonable behavior is the chain exceeds the entire 64k
possible message size, actual recursive servers have to impose a
limit, and a such, for all practical purposes, chains longer than this
limit are not usable. it turns out BIND has a hard-coded limit of 16,
and Unbound has a default limit of 11.

assuming the recursive server makes use of "compression" (pointers),
each maximal-length CNAME record takes at most 268 bytes, and thus any
chain up to length 16 fits in at most 4288 bytes.

this patch increases the answer buffer size to preserve the original
intent of having 512 bytes available for address answers, plus space
needed for a maximal CNAME chain, for a total of 4800 bytes. the
resulting size of 9600 bytes for two queries (A+AAAA) is still well
within what is reasonable to place in automatic storage.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
in the event of chained CNAMEs, the answer to a query will contain the
entire CNAME chain, not just one CNAME record. previously, the answer
buffer size had been chosen to admit a maximal-length CNAME, but only
one. a moderate-length chain could fill the available 768 bytes
leaving no room for an actual address answering the query.

while the DNS RFCs do not specify any limit on the length of a CNAME
chain, or any reasonable behavior is the chain exceeds the entire 64k
possible message size, actual recursive servers have to impose a
limit, and a such, for all practical purposes, chains longer than this
limit are not usable. it turns out BIND has a hard-coded limit of 16,
and Unbound has a default limit of 11.

assuming the recursive server makes use of "compression" (pointers),
each maximal-length CNAME record takes at most 268 bytes, and thus any
chain up to length 16 fits in at most 4288 bytes.

this patch increases the answer buffer size to preserve the original
intent of having 512 bytes available for address answers, plus space
needed for a maximal CNAME chain, for a total of 4800 bytes. the
resulting size of 9600 bytes for two queries (A+AAAA) is still well
within what is reasonable to place in automatic storage.
</pre>
</div>
</content>
</entry>
<entry>
<title>dns: check length field in tcp response message</title>
<updated>2023-04-08T00:44:20+00:00</updated>
<author>
<name>Alexey Kodanev</name>
<email>aleksei.kodanev@bell-sw.com</email>
</author>
<published>2023-03-22T14:48:40+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=77327ed064bd57b0e1865cd0e0364057ff4a53b4'/>
<id>77327ed064bd57b0e1865cd0e0364057ff4a53b4</id>
<content type='text'>
The received length field in the message may be greater than the
size of the 'answer' buffer in which the message resides. Currently,
ABUF_SIZE is 768. And if we get a larger 'alens[i]', it will result
in an out-of-bounds reading in __dns_parse().

To fix this, limit the length to the size of the received buffer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The received length field in the message may be greater than the
size of the 'answer' buffer in which the message resides. Currently,
ABUF_SIZE is 768. And if we get a larger 'alens[i]', it will result
in an out-of-bounds reading in __dns_parse().

To fix this, limit the length to the size of the received buffer.
</pre>
</div>
</content>
</entry>
<entry>
<title>getservbyport_r: fix wrong result if getnameinfo fails with EAI_OVERFLOW</title>
<updated>2023-02-28T17:01:34+00:00</updated>
<author>
<name>Alexey Izbyshev</name>
<email>izbyshev@ispras.ru</email>
</author>
<published>2023-02-27T20:33:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=b1dfb734a45d4f74c7a24c5f07d37f7e74451802'/>
<id>b1dfb734a45d4f74c7a24c5f07d37f7e74451802</id>
<content type='text'>
EAI_OVERFLOW should be propagated as ERANGE to inform the caller about
the need to expand the buffer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
EAI_OVERFLOW should be propagated as ERANGE to inform the caller about
the need to expand the buffer.
</pre>
</div>
</content>
</entry>
<entry>
<title>getservbyport_r: fix out-of-bounds buffer read</title>
<updated>2023-02-28T17:00:55+00:00</updated>
<author>
<name>Alexey Izbyshev</name>
<email>izbyshev@ispras.ru</email>
</author>
<published>2023-02-27T20:18:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=595416b11dfbc82d40a59d0edd7e3b04ba7a2d6d'/>
<id>595416b11dfbc82d40a59d0edd7e3b04ba7a2d6d</id>
<content type='text'>
If the buffer passed to getservbyport_r is just enough to store two
pointers after aligning it, getnameinfo is called with buflen == 0
(which means that service name is not needed) and trivially succeeds.
Then, strtol is called on the address just past the buffer end, and
if it doesn't happen to find the port number there, getservbyport_r
spuriously succeeds and returns the same bad address to the caller.

Fix this by ensuring that buflen is at least 1 when passed to
getnameinfo.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If the buffer passed to getservbyport_r is just enough to store two
pointers after aligning it, getnameinfo is called with buflen == 0
(which means that service name is not needed) and trivially succeeds.
Then, strtol is called on the address just past the buffer end, and
if it doesn't happen to find the port number there, getservbyport_r
spuriously succeeds and returns the same bad address to the caller.

Fix this by ensuring that buflen is at least 1 when passed to
getnameinfo.
</pre>
</div>
</content>
</entry>
<entry>
<title>getifaddrs: fix UB via taking address of null pointer union dereference</title>
<updated>2023-02-28T16:59:53+00:00</updated>
<author>
<name>Alexey Izbyshev</name>
<email>izbyshev@ispras.ru</email>
</author>
<published>2023-02-27T20:05:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=1a708ece1ad8b924466e81c5fcdf4e22311fd770'/>
<id>1a708ece1ad8b924466e81c5fcdf4e22311fd770</id>
<content type='text'>
getifaddrs computes &amp;ctx-&gt;first-&gt;ifa even if ctx-&gt;first is NULL. While
this shouldn't be possible on the success path because the loopback
interface is hardcoded into the kernel, this is still possible on the
error path (for example, if __rtnetlink_enumerate couldn't create a
socket due to exceeding the fd limit).
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
getifaddrs computes &amp;ctx-&gt;first-&gt;ifa even if ctx-&gt;first is NULL. While
this shouldn't be possible on the success path because the loopback
interface is hardcoded into the kernel, this is still possible on the
error path (for example, if __rtnetlink_enumerate couldn't create a
socket due to exceeding the fd limit).
</pre>
</div>
</content>
</entry>
<entry>
<title>accept4: don't fall back to accept if we got unknown flags</title>
<updated>2023-02-28T16:48:05+00:00</updated>
<author>
<name>Alexey Izbyshev</name>
<email>izbyshev@ispras.ru</email>
</author>
<published>2023-02-28T00:11:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=c499c1084eaccd83e4b6e60883a5d92df0202c5e'/>
<id>c499c1084eaccd83e4b6e60883a5d92df0202c5e</id>
<content type='text'>
accept4 emulation via accept ignores unknown flags, so it can spuriously
succeed instead of failing (or succeed without doing the action implied
by an unknown flag if it's added in a future kernel). Worse, unknown
flags trigger the fallback code even on modern kernels if the real
accept4 syscall returns EINVAL, because this is indistinguishable from
socketcall returning EINVAL due to lack of accept4 support.

Fix this by always failing with EINVAL if unknown flags are present and
the syscall is missing or failed with EINVAL.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
accept4 emulation via accept ignores unknown flags, so it can spuriously
succeed instead of failing (or succeed without doing the action implied
by an unknown flag if it's added in a future kernel). Worse, unknown
flags trigger the fallback code even on modern kernels if the real
accept4 syscall returns EINVAL, because this is indistinguishable from
socketcall returning EINVAL due to lack of accept4 support.

Fix this by always failing with EINVAL if unknown flags are present and
the syscall is missing or failed with EINVAL.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix potential read past end of buffer in getnameinfo host name lookup</title>
<updated>2023-02-27T15:04:34+00:00</updated>
<author>
<name>Alexey Izbyshev</name>
<email>izbyshev@ispras.ru</email>
</author>
<published>2023-02-25T15:41:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=523d9b965df65bd3ad52863abc817724d7a35f32'/>
<id>523d9b965df65bd3ad52863abc817724d7a35f32</id>
<content type='text'>
This is completely analoguous to commit 633183b5d1c2.

Similar code called from __lookup_name is not affected because it checks
that the line contains the host name surrounded by blanks.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is completely analoguous to commit 633183b5d1c2.

Similar code called from __lookup_name is not affected because it checks
that the line contains the host name surrounded by blanks.
</pre>
</div>
</content>
</entry>
</feed>
