2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00
Commit Graph

34758 Commits

Author SHA1 Message Date
Mark Andrews
60e444848c Merge branch '2935-cid-339035-1-of-1-explicit-null-dereferenced-forward_null' into 'main'
Resolve "CID 339035 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)"

Closes #2935

See merge request isc-projects/bind9!5470
2021-10-11 23:16:22 +00:00
Mark Andrews
c48ca52851 Add CHANGES for [GL #2935] 2021-10-12 09:57:24 +11:00
Mark Andrews
0378c05ba0 Fix cleanup of signature buffer in dns_dnssec_signmessage
A NULL pointer could be freed if error handling occured.
2021-10-12 09:56:44 +11:00
Michał Kępień
e112afa156 Merge branch '2899-placeholder' into 'main'
Add placeholder for GL #2899

See merge request isc-projects/bind9!5479
2021-10-08 10:07:46 +00:00
Michał Kępień
3b0b45c4bf Add placeholder for GL #2899 2021-10-08 12:04:04 +02:00
Ondřej Surý
e96e9bba10 Merge branch '719-make-isc_result-static-CHANGES' into 'main'
Update isc_result_t developer documentation and CHANGES

Closes #719

See merge request isc-projects/bind9!5475
2021-10-07 06:48:02 +00:00
Ondřej Surý
2737bca579 Add CHANGES notes for [GL #719] 2021-10-07 08:06:54 +02:00
Ondřej Surý
848fef4d4d Update isc_result_t developer documentation
There's no multiple result.{c,h} location to defining result codes,
update the documentation accordingly.
2021-10-07 08:05:16 +02:00
Ondřej Surý
3b9d9f5afb Merge branch '2934-cid-339111-memory-corruptions-use_after_free' into 'main'
Resolve "CID 339111:  Memory - corruptions  (USE_AFTER_FREE)"

Closes #2934

See merge request isc-projects/bind9!5469
2021-10-06 15:45:58 +00:00
Mark Andrews
b7c362738d Correctly call dns_dispatch_done() in dns_dispatch_cancel()
Pass '&resp' rather than 'respp' as we have already cleared '*respp'
when we took ownership of 'resp'.
2021-10-06 17:20:38 +02:00
Ondřej Surý
2705860bb3 Merge branch '719-make-isc_result-static' into 'main'
Make isc_result a static enum

Closes #719

See merge request isc-projects/bind9!5458
2021-10-06 09:40:47 +00:00
Ondřej Surý
2e3a2eecfe Make isc_result a static enum
Remove the dynamic registration of result codes.  Convert isc_result_t
from unsigned + #defines into 32-bit enum type in grand unified
<isc/result.h> header.  Keep the existing values of the result codes
even at the expense of the description and identifier tables being
unnecessary large.

Additionally, add couple of:

    switch (result) {
    [...]
    default:
        break;
    }

statements where compiler now complains about missing enum values in the
switch statement.
2021-10-06 11:22:20 +02:00
Ondřej Surý
804ec1bcaa Improve STATIC_ASSERT macro for older compilers
Previously, when using compiler without support for static assertions,
the STATIC_ASSERT() macro would be replaced with runtime assertion.
Change the STATIC_ASSERT() macro to a version that's compile time
assertion even when using pre-C11 compilers.

Courtesy of Joseph Quinsey: https://godbolt.org/z/K9RvWS
2021-10-05 22:13:29 +02:00
Ondřej Surý
9f5985bae5 Remove duplicate DE_CONST macro
Both <isccc/util.h> and <isc/util.h> defined DE_CONST() macro.  As
<isccc/util.h> header includes <isc/util.h>, remove the macro from
<isccc/util.h> header.
2021-10-05 22:13:29 +02:00
Ondřej Surý
4d85040df5 Change the ISC_R_SUCCESS to DNS_RRL_RESULT_OK in dns_rrl()
There's value mismatch between the return type of dns_rrl() that's
dns_rrl_result_t and ISC_R_SUCCESS which belongs to isc_result_t.  This
works incidentally, because DNS_RRL_RESULT_OK == ISC_R_SUCCESS.

This would break when we change isc_result_t to be static enum in
consecutive commit.  Change the value to match the type.
2021-10-05 22:13:29 +02:00
Evan Hunt
4445d0a7d6 Merge branch '2928-coverity-fixes' into 'main'
address coverity and sanitizer reports

Closes #2928

See merge request isc-projects/bind9!5456
2021-10-05 19:30:55 +00:00
Evan Hunt
436424c458 increment fctx references while waiting for validator
We need to ensure the fctx isn't freed while the validator
is pending.
2021-10-05 10:18:48 -07:00
Evan Hunt
24dbf9849e refactor dispatch cancellation
Renamed some functions for clarity and readability:

- dns_dispatch_addresponse() -> dns_dispatch_add()
- dns_dispatch_removeresponse() -> dns_dispatch_done()

The dns_dispatch_cancel() function now calls dns_dispatch_done()
directly, so it is no longer ever necessary to call both functions.

dns_dispatch_cancel() is used to terminate dispatch connections
that are still pending, while dns_dispatch_done() is used when they
are complete.
2021-10-05 10:18:48 -07:00
Evan Hunt
2653800e0b simplify sending request events
The function send_if_done() was just a front-end for req_sendevents().
2021-10-05 10:18:48 -07:00
Evan Hunt
5948aa7766 clarify fctx_cancelquery() behavior
Cleaned up dereferencing of query objects, and added a comment
explaining it better.
2021-10-05 10:18:48 -07:00
Ondřej Surý
931779b3f6 Merge branch 'ondrej/fix-missing-OPENSSL_CFLAGS-in-bind9' into 'main'
Add OPENSSL_CFLAGS to libbind9 Makefile.am

See merge request isc-projects/bind9!5465
2021-10-05 13:15:57 +00:00
Ondřej Surý
13dfc191c5 Add OPENSSL_CFLAGS to libbind9 Makefile.am
The build would fail if the OpenSSL libraries were not in default
include path because we include <openssl/opensslv.h> header in
lib/bind9/check.c.  Add $(OPENSSL_CFLAGS) to lib/bind9/Makefile.am.
2021-10-05 13:13:53 +00:00
Artem Boldariev
1af9d8d7bb Merge branch '2794-dot-alpn-for-xfrs' into 'main'
Resolve #2794, #2884: make "dot" ALPN token negotiation to be required for XoT

Closes #2884 and #2794

See merge request isc-projects/bind9!5391
2021-10-05 08:49:27 +00:00
Artem Boldariev
cdf39260a7 Add an entry to the release notes file [GL #2794]
Mention that "dot" ALPN tag is now required for XoT.
2021-10-05 11:30:22 +03:00
Artem Boldariev
d696f5dd83 Add an entry to the CHANGES [GL #2884]
Mention that the bug making dig abort during zone transfers sometimes
is resolved.
2021-10-05 11:30:22 +03:00
Artem Boldariev
abecfdc298 DoT: do not attempt to call read callback if it is not avaialble
This commit fixes a crash in DoT code when it was attempting to call a
read callback on the later stages of the connection when it is not
available.

It also fixes [GL #2884] (back-trace provided in the bug report is
exactly the same as was seen when fixing this problem).
2021-10-05 11:26:14 +03:00
Artem Boldariev
fc3a37a2ad Add an entry to the CHANGES file [GL #2794]
Mention in the CHANGES file that "dot" ALPN token is required to be
negotiated for XoT.
2021-10-05 11:26:08 +03:00
Artem Boldariev
8cd3b9ef66 Do not allow zone transfers in dig over TLS without ALPN
This commit makes dig fail with error in case a zone transfer is
attempted over a connections where ALPN was not negotiated. All other
request types will work fine.
2021-10-05 11:23:47 +03:00
Artem Boldariev
610bd2726e Add ALPN negotiation tests to TLS DNS test set
This commits adds a set of unit tests to ensure that ALPN happens over
the connections and that the result of the negotiation can be checked.
2021-10-05 11:23:47 +03:00
Artem Boldariev
79d8af7354 Require "dot" ALPN token for incoming xfrs over XoT
This commit make the code handling incoming zone transfers to verify
if they are allowed to be done over the underlying connections. As a
result the check ensures that the "dot" ALPN token has been negotiated
over the underlying connection.
2021-10-05 11:23:47 +03:00
Artem Boldariev
382098198e Make dig advertise the "dot" ALPN token for DoT connections
This commit makes dig advertise the "dot" ALPN token to make it
possible for ALPN to happen.
2021-10-05 11:23:47 +03:00
Artem Boldariev
25b2c6ad96 Require "dot" ALPN token for zone transfer requests over DoT (XoT)
This commit makes BIND verify that zone transfers are allowed to be
done over the underlying connection. Currently, it makes sense only
for DoT, but the code is deliberately made to be protocol-agnostic.
2021-10-05 11:23:47 +03:00
Artem Boldariev
eba3278e52 Add isc_nm_xfr_allowed() function
The intention of having this function is to have a predicate to check
if a zone transfer could be performed over the given handle. In most
cases we can assume that we can do zone transfers over any stream
transport except DoH, but this assumption will not work for zone
transfers over DoT (XoT), as the RFC9103 requires ALPN to happen,
which might not be the case for all deployments of DoT.
2021-10-05 11:23:47 +03:00
Artem Boldariev
56b3f5d832 Low level code to support ALPN in DoT
This commit adds low-level code necessary to support ALPN in DoT as
XoT requires "dot" ALPN token to be negotiated on a connection for
zone transfers.
2021-10-05 11:23:47 +03:00
Mark Andrews
c75d6afc1c Merge branch '2900-listenlist_test-notify_test-and-query_test-failing' into 'main'
Resolve "listenlist_test, notify_test, and query_test failing."

Closes #2900

See merge request isc-projects/bind9!5461
2021-10-05 06:44:43 +00:00
Mark Andrews
877f52b772 Increase the number of file descriptors available
The 'listenlist_test', 'notify_test', and 'query_test' tests failed
when the descriptor limit was 256 on MacOS 11.6 with 8 cpus. On the
test platform the limit needed to be increased to ~400.  Increase
the limit to at least 1024 to give some head room.
2021-10-05 17:21:30 +11:00
Evan Hunt
0261bad3df Merge branch '88-make-libs-private' into 'main'
remove libdns init/shutdown functions

Closes #88

See merge request isc-projects/bind9!5405
2021-10-04 21:16:34 +00:00
Evan Hunt
dfccfc9361 CHANGES for [GL #88] 2021-10-04 13:58:00 -07:00
Evan Hunt
e61b76292a Remove libns init/shutdown functions
as libraries are no longer exported, these functions served
no useful purpose.
2021-10-04 13:57:34 -07:00
Evan Hunt
cd8a081a4f Remove libdns init/shutdown functions
as libdns is no longer exported, it's not necessary to have
init and shutdown functions. the only purpose they served
was to create a private mctx and run dst_lib_init(), which
can be called directly instead.
2021-10-04 13:57:32 -07:00
Artem Boldariev
372d065eff Merge branch '2925-do-not-allow-default-http' into 'main'
Do not allow defining "http" clauses named "default"

Closes #2925

See merge request isc-projects/bind9!5453
2021-10-04 15:04:07 +00:00
Artem Boldariev
79ce4441e7 Modify CHANGES [GL #2925]
Mention that it is not allowed defining "http" clauses named "default"
2021-10-04 17:29:47 +03:00
Artem Boldariev
d45df0d923 Do not allow defining "http" clauses named "default"
This name is reserved for being used in 'listen-on' statements only.
2021-10-04 17:28:30 +03:00
Evan Hunt
d27d20e6d4 Merge branch '2401-use-netmgr-for-dispatch' into 'main'
Resolve "use netmgr for dispatch"

Closes #2401

See merge request isc-projects/bind9!4601
2021-10-02 19:04:03 +00:00
Evan Hunt
d596bd04b6 Add CHANGES and release note for [GL #2401] 2021-10-02 11:43:59 -07:00
Evan Hunt
ffbe6268f5 Corrected several system test issues
- serve-stale: dig wasn't always running in background when it should.
  some of the serve-stale test cases are based on groups of dig calls
  running simultaneously in the background: the test pauses and resumes
  running after 'wait'. in some cases the final call to dig in a group
  wasn't in the background, and this sometimes caused delays that
  affected later test results.  in another case, a test was simplified
  and made more reliable by running dig in the foreground removing a
  sleep.

- serve-stale: The extension of the dig timeout period from 10 to 11
  seconds in commit 5307bf64ce was left undone in a few places and has
  now been completed.

- serve-stale: Resolver-query-timeout was set incorrectly.  a comment
  above a test case in serve-stale/tests.sh says: "We configured a long
  value of 30 seconds for resolver-query-timeout," but
  resolver-query-timeout was actually set to 10, not 30. this is now
  fixed.

- rpz: Force retransfer of the fast-expire zone, to ensure it's fully
  loaded in ns3; previously it could have been left unloaded if ns5
  wasn't up yet when ns3 attempted the zone transfer.

- statistics: The TCP4SendErr counter is incremented when a TCP dispatch
  is canceled while sending. depending on test timing, this may have
  happened by the time the statistics are dumped. worked around by
  ignoring that stat couunter when checking for errors.

- hooks: Add a prereq.sh script to prevent running under TSAN.

- zero: Disabled the servfail cache so that SERVFAIL is reported only
  when there actually is a failure, not repeatedly every time the same
  query is sent.
2021-10-02 11:43:59 -07:00
Evan Hunt
dc1203b426 resolver: Fixed shutdown processing
- Prevent shutdown races: attach/detach to dns_resolver in dns_fetch_t
  and fctx_t; delay destruction of fctx when finds are still active;
  reference the fctx while canceling; reverse the order of
  fctx_destroy() and empty_bucket().

- Don't resend queries if fetches have been canceled.

- It's possible for fctx_doshutdown() to run before a TCP connection has
  completed. if the query is not on the queries list, then it is not
  canceled, but the adbaddrinfo is freed. when tcp_connected() runs
  later, the query is in an inconstent state. to fix this, we add the
  query to queries before running dns_dispatch_connect(), instead of in
  the connect callback.

- Combined the five fctx_cleanup* functions into a single one.

- Added comments and changed some names to make this code easier to
  understand.
2021-10-02 11:43:59 -07:00
Evan Hunt
f67f524405 dispatch: Enforce original timeout when calling _getnext()
udp_recv() will call dispatch_getnext() if the message received is
invalid or doesn't match; we need to reduce the timeout each time this
happens so we can't be starved forever by someone sending garbage
packets.
2021-10-02 11:43:52 -07:00
Evan Hunt
6ea7d59ad2 dispatch: Clean up connect and recv callbacks
- disp_connected() has been split into two functions,
  udp_connected() (which takes 'resp' as an argument) and
  tcp_connected() (which takes 'disp', and calls the connect callbacks
  for all pending resps).

- In dns_dispatch_connect(), if a connection is already open, we need to
  detach the dispentry immediately because we won't be running
  tcp_connected().

- dns_disptach_cancel() also now calls the connect callbacks for pending
  TCP responses, and the response callbacks for open TCP connections
  waiting on read.

- If udp_connected() runs after dns_dispatch_cancel() has been called,
  ensure that the caller's connect callback is run.

- If a UDP connection fails with EADDRINUSE, we try again up to five
  times with a different local port number before giving up.

- If a TCP connection is canceled while still pending connection, the
  connect timeout may still fire. we attach the dispatch before
  connecting to ensure that it won't be detached too soon in this case.

- The dispentry is no longer removed from the pending list when
  deactivating, so that the connect callback can still be run if
  dns_dispatch_removeresponse() was run while the connecting was
  pending.

- Rewrote dns_dispatch_gettcp() to avoid a data race.

- startrecv() and dispatch_getnext() can be called with a NULL resp when
  using TCP.

- Refactored udp_recv() and tcp_recv() and added result logging.

- EOF is now treated the same as CANCELED in response callbacks.

- ISC_R_SHUTTINGDOWN is sent to the reponse callbacks for all resps if
  tcp_recv() is triggered by a netmgr shutdown.  (response callbacks
  are *not* sent by udp_recv() in this case.)
2021-10-02 11:39:56 -07:00
Evan Hunt
8551ad026f dispatch: Fix several connect-related issues
- startrecv() and getnext() have been rewritten.

- Don't set TCP flag when connecting a UDP dispatch.

- Prevent TCP connections from trying to connect twice.

- dns_dispatch_gettcp() can now find a matching TCP dispatch that has
  not yet fully connected, and attach to it.  when the connection is
  completed, the connect callbacks are run for all of the pending
  entries.

- An atomic 'state' variable is now used for connection state instead of
  attributes.

- When dns_dispatch_cancel() is called on a TCP dispatch entry, only
  that one entry is canceled. the dispatch itself should not be shut
  down until there are no dispatch entries left associated with it.

- Other incidental cleanup, including removing DNS_DISPATCHATTR_IPV4 and
  _IPV6 (they were being set in the dispatch attributes but never used),
  cleaning up dns_requestmgr_create(), and renaming dns_dispatch_read()
  to the more descriptive dns_dispatch_resume().
2021-10-02 11:39:56 -07:00