2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

37043 Commits

Author SHA1 Message Date
Ondřej Surý
b1026dd4c1
Add missing isc_refcount_destroy() for isc__nmsocket_t
The destructor for the isc__nmsocket_t was missing call to the
isc_refcount_destroy() on the reference counter, which might lead to
spurious ThreadSanitizer data race warnings if we ever change the
acquire-release memory order in the isc_refcount_decrement().
2022-09-19 14:38:56 +02:00
Ondřej Surý
9b8d432403
Reorder the uv_close() calls to close the socket immediately
Simplify the closing code - during the loopmgr implementation, it was
discovered that the various lists used by the uv_loop_t aren't FIFO, but
LIFO.  See doc/dev/libuv.md for more details.

With this knowledge, we can close the protocol handles (uv_udp_t and
uv_tcp_t) and uv_timer_t at the same time by reordering the uv_close()
calls, and thus making sure that after calling the
isc__nm_stoplistening(), the code will not issue any additional callback
calls (accept, read) on the socket that stopped listening.

This might help with the TLS and DoH shutting down sequence as described
in the [GL #3509] as we now stop the reading, stop the timer and call
the uv_close() as earliest as possible.
2022-09-19 14:38:56 +02:00
Ondřej Surý
23800ecd86
Add developer note for the libuv quirks 2022-09-19 14:38:56 +02:00
Ondřej Surý
88f6f30c3d Merge branch '3545-prevent-unexpected-client-read-callbacks' into 'main'
Prevent unexpected UDP client read callbacks

Closes #3545

See merge request isc-projects/bind9!6777
2022-09-19 12:38:04 +00:00
Ondřej Surý
845d7ef69b Add CHANGES note for [GL #3545] 2022-09-19 14:16:07 +02:00
Ondřej Surý
014da8599f Improve the udp_shutdown_read and udp_cancel_read tests
In the udp_shutdown_read unit test, delay the isc_loopmgr_shutdown() to
the send callback, and in the udp_cancel_read test wait for a single
timed out test, then read again, send an UDP packet and cancel the read
from the send callback.
2022-09-19 14:16:07 +02:00
Ondřej Surý
eac8bc5c1a
Prevent unexpected UDP client read callbacks
The network manager UDP code was misinterpreting when the libuv called
the udp_recv_cb with nrecv == 0 and addr == NULL -> this doesn't really
mean that the "stream" has ended, but the libuv indicates that the
receive buffer can be freed.  This could lead to assertion failure in
the code that calls isc_nm_read() from the network manager read callback
due to the extra spurious callbacks.

Properly handle the extra callback calls from the libuv in the client
read callback, and refactor the UDP isc_nm_read() implementation to be
synchronous, so no datagram is lost between the time that we stop the
reading from the UDP socket and we restart it again in the asychronous
udpread event.

Add a unit test that tests the isc_nm_read() call from the read
callback to receive two datagrams.
2022-09-19 12:20:41 +02:00
Evan Hunt
94b32f2e0b Merge branch '3522-update-detach' into 'main'
fix an incorrect detach in update processing

Closes #3522

See merge request isc-projects/bind9!6722
2022-09-15 18:33:51 +00:00
Evan Hunt
fdc35928eb CHANGES for [GL #3522] 2022-09-15 10:34:25 -07:00
Evan Hunt
00e0758e12 fix an incorrect detach in update processing
when processing UDPATE requests, hold the request handle until
we either drop the request or respond to it.
2022-09-15 10:33:42 -07:00
Michal Nowak
9f7a514e49 Merge branch '3427-tcp-system-test-bump-socket.create_connection-timeout' into 'main'
Bump socket.create_connection() timeout to 10 seconds

Closes #3427

See merge request isc-projects/bind9!6757
2022-09-15 10:19:51 +00:00
Michal Nowak
658cae9fad
Bump socket.create_connection() timeout to 10 seconds
The tcp Pytest on OpenBSD fairly reliably fails when receive_tcp()
on a socket is attempted:

    >           (response, rtime) = dns.query.receive_tcp(sock, timeout())

    tests-tcp.py:50:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    /usr/local/lib/python3.9/site-packages/dns/query.py:659: in receive_tcp
        ldata = _net_read(sock, 2, expiration)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    sock = <socket.socket [closed] fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6>
    count = 2, expiration = 1662719959.8106785

        def _net_read(sock, count, expiration):
            """Read the specified number of bytes from sock.  Keep trying until we
            either get the desired amount, or we hit EOF.
            A Timeout exception will be raised if the operation is not completed
            by the expiration time.
            """
            s = b''
            while count > 0:
                try:
    >               n = sock.recv(count)
    E               socket.timeout: timed out

This is because the socket is already closed.

Bump the socket connection timeout to 10 seconds.
2022-09-15 11:13:36 +02:00
Ondřej Surý
1362ffed1f Merge branch '3542-gracefuly-handle-cancelled-http-read-during-sending' into 'main'
Handle canceled read during sending data over stats channel

Closes #3542

See merge request isc-projects/bind9!6773
2022-09-15 08:57:19 +00:00
Ondřej Surý
e29563173b
Add CHANGES and release note for [GL #3542] 2022-09-15 10:29:58 +02:00
Ondřej Surý
6869c98d36
Provide stronger wording about the security of statistics channel
Add more text about the importance of properly securing the statistics
channel and what is and what is not considered a security vulnerability.
2022-09-15 10:29:38 +02:00
Ondřej Surý
6562227cc8
Handle canceled read during sending data over stats channel
An assertion failure would be triggered when the TCP connection
is canceled during sending the data back to the client.

Don't require the state to be `RECV` on non successful read to
gracefully handle canceled TCP connection during the SEND state of the
HTTPD channel.
2022-09-15 10:29:37 +02:00
Petr Špaček
0ffa8d1a9c Merge branch '1176-add-support-for-sd_notify-interface-to-better-integrate-on-linux' into 'main'
Add support for reporting status via sd_notify()

Closes #1176

See merge request isc-projects/bind9!5514
2022-09-15 08:17:20 +00:00
Ondřej Surý
1eb848d71a
Add CHANGES and release note for [GL #1176] 2022-09-15 10:12:50 +02:00
Ondřej Surý
52b62b7890
Add support for reporting status via sd_notify()
sd_notify() may be called by a service to notify the service manager
about state changes. It can be used to send arbitrary information,
encoded in an environment-block-like string. Most importantly, it can be
used for start-up completion notification.

Add libsystemd check to autoconf script and when the library is detected
add calls to sd_notify() around the server->reload_status changes.

Co-authored-by: Petr Špaček <pspacek@isc.org>
2022-09-15 10:12:15 +02:00
Petr Špaček
0b7f082060 Merge branch 'pspacek/log-no-recursion-reason' into 'main'
Log reasons why ACL denied recursion or cache peek

See merge request isc-projects/bind9!6669
2022-09-15 07:40:17 +00:00
Evan Hunt
a2bbe578bf
Add tests for the new log messages with refusal reason
Update the allow-query test to check for the new log messages.
2022-09-15 06:50:57 +02:00
Petr Špaček
67c3a3439b
CHANGES note for [GL !6669] 2022-09-15 06:50:55 +02:00
Petr Špaček
fdf7456643
Log reason why cache peek is not available
Log which ACL caused RD=0 query into cache to be refused.
Expected performance impact is negligible.
2022-09-15 06:50:13 +02:00
Petr Špaček
95fc05c454
Log reason why recursion is not available
Log which ACL caused RA=0 condition.
Expected performance impact is negligible.
2022-09-15 06:50:13 +02:00
Mark Andrews
5c5f6964ff Merge branch '3525-key-id-clashes-across-algorithms-cause-problems-with-statistics' into 'main'
Resolve "key id clashes across algorithms cause problems with statistics"

Closes #3525

See merge request isc-projects/bind9!6745
2022-09-15 01:04:17 +00:00
Mark Andrews
91488a9b6d Add a release note for [GL #3525] 2022-09-15 09:09:35 +10:00
Mark Andrews
b15309e10d Add a CHANGES note for [GL #3525] 2022-09-15 08:44:28 +10:00
Mark Andrews
b1ef1ded69 Emit key algorithm + key id in dnssec signing statsistics
If there was a collision of key id across algorithms it was not
possible to determine where counter applies to which algorithm for
xml statistics while for json only one of the values was emitted.
The key names are now "<algorithm-number>+<id>" (e.g. "8+54274").
2022-09-15 08:42:45 +10:00
Evan Hunt
491ead7820 Merge branch 'each-remove-resolve' into 'main'
remove 'resolve' test binary

See merge request isc-projects/bind9!6733
2022-09-14 17:20:52 +00:00
Evan Hunt
d99076ede4 remove 'resolve' test binary
the 'resolve' binary was added for testing dns_client as part of
the export library. the export libraries are no longer supported,
and tests using 'delv' provide the same coverage, so 'resolve' can
be removed now.
2022-09-14 10:17:06 -07:00
Evan Hunt
e73317d4f3 Merge branch 'each-cleanup-dns_request' into 'main'
remove dns_request_create()

See merge request isc-projects/bind9!6753
2022-09-14 17:14:01 +00:00
Evan Hunt
ebf7b31aa3 merge dns_request_createvia() into dns_request_create()
dns_request_create() was a front-end to dns_request_createvia() that
was only used by test binaries. dns_request_createvia() has been
renamed to dns_request_create(), and the test programs that formerly
used dns_request_create() have been updated to use the new parameters.
2022-09-14 09:51:08 -07:00
Evan Hunt
05c1d2d365 Merge branch '3399-random-device-ancient' into 'main'
flag "random-device" as ancient

Closes #3399

See merge request isc-projects/bind9!6769
2022-09-14 16:41:15 +00:00
Evan Hunt
0cc6c9f0b8 CHANGES for [GL #3399] 2022-09-14 09:36:58 -07:00
Evan Hunt
9730f21f83 flag "random-device" as ancient
the "random-device" option was made non-functional in 9.13. this commit
removes it from the configuration parser; setting it is now an error.
2022-09-14 09:36:58 -07:00
Tony Finch
fade14c809 Merge branch '3537-idna-test' into 'main'
Fix dig idna test on Debian 10 "buster"

Closes #3537

See merge request isc-projects/bind9!6767
2022-09-14 12:39:08 +00:00
Tony Finch
5c1aed2881 Fix dig idna test on Debian 10 "buster"
The test expected `xn--ah-` to be treated as a syntax error (punycode
requires letters after the last hyphen) but libidn2 on buster
converted the label to `ah` instead. To avoid this bug, change the
invalid label to `xn--0000h` which translates to an out-of-range
unicode codepoint (beyond the maximum value) which is corectly
trated as invalid in older libidn2.
2022-09-14 11:59:42 +01:00
Tony Finch
83f27b6f3b Merge branch '3536-out-of-tree' into 'main'
Fix out-of-tree tests

Closes #3536

See merge request isc-projects/bind9!6766
2022-09-14 10:23:29 +00:00
Tony Finch
2a0b81d6da Fix out-of-tree tests
The change to `testsock.pl` in commit 258a896a broke the system
tests in out-of-tree builds because `ifconfig.sh.in` is not
copied to the worktree. Use `ifconfig.sh` instead.
2022-09-14 10:02:58 +01:00
Mark Andrews
44235cd2cf Merge branch '2295-add-the-ability-to-specify-that-a-server-supports-cookies' into 'main'
Resolve "Add the ability to specify that a server supports COOKIES."

Closes #2295

See merge request isc-projects/bind9!4410
2022-09-14 01:36:42 +00:00
Mark Andrews
b22df206d4 Add CHANGES and release notes for [GL #2295] 2022-09-13 12:07:13 +10:00
Mark Andrews
9d893d55e0 Check "require-cookie yes;" triggers TCP fallback on no cookie 2022-09-13 12:07:13 +10:00
Mark Andrews
7751e5e039 Add server clause require-cookie
Specifies if an UDP response requires a DNS COOKIE or not.
Fallback to TCP if not present and not TSIG signed.
2022-09-13 12:07:13 +10:00
Evan Hunt
00e3c8fe1a Merge branch '3520-rndc-shutdown-hang' into 'main'
prevent a possible shutdown hang in rndc

See merge request isc-projects/bind9!6734
2022-09-12 20:34:32 +00:00
Evan Hunt
9683439d73 prevent a possible shutdown hang in rndc
In rndc_recvdone(), if 'sends' was not 0, then 'recvs' was not
decremented, in which case isc_loopmgr_shutdown() was never reached,
which could cause a hang. (This has not been observed to happen, but
the code was incorrect on examination.)
2022-09-12 13:14:19 -07:00
Tony Finch
b5b147864f Merge branch 'fanf-tolower' into 'main'
De-duplicate `tolower()`

See merge request isc-projects/bind9!6516
2022-09-12 12:08:06 +00:00
Tony Finch
022bb06264 CHANGES note for [GL !6516]
[cleanup]	Move the duplicated ASCII case conversion tables to
		isc_ascii where they can be shared, and replace the
		various hot-path tolower() loops with calls to new
		isc_ascii implementations.
2022-09-12 12:23:39 +01:00
Tony Finch
68029bfc9d Tests and benchmark for isc_ascii
The test is to verify basic functionality. The benchmark compares a
number of alternative tolower() implementations on large and small
strings.
2022-09-12 12:23:39 +01:00
Tony Finch
21a383a8fd General-purpose unrolled ASCII tolower() loops
When converting a string to lower case, the compiler is able to
autovectorize nicely, so a nice simple implementation is also very
fast, comparable to memcpy().

Comparisons are more difficult for the compiler, so we convert eight
bytes at a time using "SIMD within a register" tricks. Experiments
indicate it's best to stick to simple loops for shorter strings and
the remainder of long strings.
2022-09-12 12:18:57 +01:00
Tony Finch
27a561273e Consolidate some ASCII tables in isc/ascii and isc/hex
There were a number of places that had copies of various ASCII
tables (case conversion, hex and decimal conversion) that are intended
to be faster than the ctype.h macros, or avoid locale pollution.

Move them into libisc, and wrap the lookup tables with macros that
avoid the ctype.h gotchas.
2022-09-12 12:18:57 +01:00