Commit Graph

37714 Commits

Author SHA1 Message Date
Ondřej Surý
c2be97eeff Fix reference counting in get_attached_entry
When get_attached_entry() encounters entry that would be expired, it
needs to get reference to the entry before calling maybe_expire_entry(),
so the ADB entry doesn't get destroyed inside the its own lock.
2022-12-07 16:16:22 +01:00
Matthijs Mekking
406de85309 Merge branch 'matthijs-document-ns-minimal-responses' into 'main'
Document NS queries are excempt from minimal-responses

See merge request isc-projects/bind9!7072
2022-12-07 11:19:20 +00:00
Matthijs Mekking
f7b477f6ea Document NS queries are excempt from minimal-responses
Also document that DNSKEY, DS, CDNSKEY, and CDS never do additional
section processing.
2022-12-07 11:37:55 +01:00
Michal Nowak
e5afd7c50c Merge branch 'mnowak/asan-tsan-respdiff-jobs' into 'main'
Add ASAN- and TSAN-enabled respdiff jobs

See merge request isc-projects/bind9!7115
2022-12-07 07:26:21 +00:00
Michal Nowak
4f23de554c Add ASAN- and TSAN-enabled respdiff jobs
Neither of the new CI jobs can reliably pass at the moment; hence they
are defined with "allow_failure: true" until issues in the code base are
resolved.
2022-12-07 07:28:03 +01:00
Michal Nowak
9856296666 Extract TSAN parsing code 2022-12-07 07:28:03 +01:00
Mark Andrews
8f6a0c85ea Merge branch '3683-use-after-free-in-catalog-zone-processing' into 'main'
Resolve "use after free in catalog zone processing"

Closes #3683

See merge request isc-projects/bind9!7137
2022-12-06 22:29:46 +00:00
Mark Andrews
9843da3423 Add release note for [GL #3683] 2022-12-07 09:04:49 +11:00
Mark Andrews
72402e1710 Add CHANGES note for [GL #3683] 2022-12-07 09:04:48 +11:00
Mark Andrews
bca84c8601 Check that restored catalog zone works
Using a restored catalog zone excercised a use-after-free bug.
The test checks that the use-after-free bug is gone and is just
a reasonable behaviour check in its own right.
2022-12-07 09:04:08 +11:00
Mark Andrews
b1086a5561 Add missing DbC magic checks
Checking for value != NULL is not sufficient to detect use after
free errors.
2022-12-07 09:04:08 +11:00
Mark Andrews
35839e91d8 Call dns_db_updatenotify_unregister earlier
dns_db_updatenotify_unregister needed to be called earlier to ensure
that listener->onupdate_arg always points to a valid object.  The
existing lazy cleanup in rbtdb_free did not ensure that.
2022-12-07 09:04:08 +11:00
Mark Andrews
f13e71e551 Suppress duplicate dns_db_updatenotify_register registrations
Duplicate dns_db_updatenotify_register registrations need to be
suppressed to ensure that dns_db_updatenotify_unregister is successful.
2022-12-07 09:04:08 +11:00
Arаm Sаrgsyаn
629f66ea8e Merge branch '3678-serve-stale-servfailing-unexpectedly' into 'main'
Resolve "stale-serve and RPZ put in SERVFAIL cache unexpected record"

Closes #3678

See merge request isc-projects/bind9!7096
2022-12-06 14:53:16 +00:00
Aram Sargsyan
5b5f3a0ea7 Add a CHANGES note for [GL #3678] 2022-12-06 13:28:49 +00:00
Matthijs Mekking
86a80e723f Consider non-stale data when in serve-stale mode
With 'stale-answer-enable yes;' and 'stale-answer-client-timeout off;',
consider the following situation:

A CNAME record and its target record are in the cache, then the CNAME
record expires, but the target record is still valid.

When a new query for the CNAME record arrives, and the query fails,
the stale record is used, and then the query "restarts" to follow
the CNAME target. The problem is that the query's multiple stale
options (like DNS_DBFIND_STALEOK) are not reset, so 'query_lookup()'
treats the restarted query as a lookup following a failed lookup,
and returns a SERVFAIL answer when there is no stale data found in the
cache, even if there is valid non-stale data there available.

With this change, query_lookup() now considers non-stale data in the
cache in the first place, and returns it if it is available.
2022-12-06 13:26:53 +00:00
Aram Sargsyan
21faf44ef7 Add serve-stale CNAME check with stale-answer-client-timeout off
Prime the cache with the following records:

    shortttl.cname.example.	1	IN	CNAME	longttl.target.example.
    longttl.target.example.	600	IN	A	10.53.0.2

Wait for the CNAME record to expire, disable the authoritative server,
and query 'shortttl.cname.example' again, expecting a stale answer.
2022-12-06 13:26:53 +00:00
Mark Andrews
84a7be327e Merge branch '3697-reject-zones-with-ds-records-not-at-delegations' into 'main'
Resolve "Reject zones with DS records not at delegations"

Closes #3697

See merge request isc-projects/bind9!7116
2022-12-06 13:07:00 +00:00
Mark Andrews
fbb2f67e8d Add CHANGES note for [GL #3697] 2022-12-06 23:28:11 +11:00
Mark Andrews
e8e40e2e01 Check that DS records are only present at delegations
This extends the integrity check to look for stray DS records
in the zone.
2022-12-06 23:27:40 +11:00
Mark Andrews
8ab496b6e1 Merge branch '3721-the-nslookup-command-does-not-obey-the-port-option-when-record-type-any-is-used' into 'main'
Resolve "The nslookup command does not obey the port option when record type ANY is used."

Closes #3721

See merge request isc-projects/bind9!7162
2022-12-05 22:19:23 +00:00
Mark Andrews
27168dbf43 Add CHANGES note for [GL #3721] 2022-12-06 08:58:58 +11:00
Mark Andrews
8caa94bdf1 Remember that the port was set in host and nslookup
Set 'port_set = true;' so that the TCP/DOT/DOH code doesn't reset
the port when making connections.
2022-12-06 08:58:58 +11:00
Mark Andrews
e9c4192ee5 Add checks for 'host' 2022-12-06 08:58:58 +11:00
Mark Andrews
c367dd1b0b Check ANY lookup using nslookup 2022-12-06 08:57:48 +11:00
Mark Andrews
3914aba26d Merge branch '3633-cid-361427-error-handling-issues-in-lib-dns-rdata-c' into 'main'
Resolve "CID 361427: Error handling issues in lib/dns/rdata.c"

Closes #3633

See merge request isc-projects/bind9!7056
2022-12-04 23:16:53 +00:00
Mark Andrews
94008863de Add RUNTIME_CHECK for dns_rdata_tostruct 2022-12-04 21:41:02 +00:00
Artem Boldariev
e3ffe756dc Merge branch 'artem-tls-check-for-recv_cb' into 'main'
TLS: check for sock->recv_cb when handling received data

See merge request isc-projects/bind9!7158
2022-12-02 12:11:41 +00:00
Artem Boldariev
bed5e2bb08 TLS: check for sock->recv_cb when handling received data
This commit adds a check if 'sock->recv_cb' might have been nullified
during the call to 'sock->recv_cb'. That could happen, e.g. by an
indirect call to 'isc_nmhandle_close()' from within the callback when
wrapping up.

In this case, let's close the TLS connection.
2022-12-02 13:20:37 +02:00
Artem Boldariev
69db33e7a5 Merge branch 'artem-tls-doh-listeners-avoid-acessing-non-atomic-flags-on-handshake-or-accept' into 'main'
TLS and DoH: Avoid accessing non-atomic listener socket flags during HS/when accepting a caonnection

See merge request isc-projects/bind9!7155
2022-12-02 11:18:56 +00:00
Artem Boldariev
8b7e123528 DoH: Avoid accessing non-atomic listener socket flags when accepting
This commit ensures that the non-atomic flags inside a DoH listener
socket object (and associated worker) are accessed when doing accept
for a connection only from within the context of the dedicated thread,
but not other worker threads.

The purpose of this commit is to avoid TSAN errors during
isc__nmsocket_closing() calls. It is a continuation of
4b5559cd8f.
2022-12-02 12:16:12 +02:00
Artem Boldariev
4d0c226375 TLS: Avoid accessing non-atomic listener socket flags during HS
This commit ensures that the non-atomic flags inside a TLS listener
socket object (and associated worker) are accessed when doing
handshake for a connection only from within the context of the
dedicated thread, but not other worker threads.

The purpose of this commit is to avoid TSAN errors during
isc__nmsocket_closing() calls. It is a continuation of
4b5559cd8f.
2022-12-02 12:16:12 +02:00
Tom Krizek
fc991fa79d Merge branch 'tkrizek/system-tests-prereqs' into 'main'
Unify system test feature detection and add missing prerequisites

See merge request isc-projects/bind9!7151
2022-12-02 09:44:29 +00:00
Tom Krizek
9846c920c3 Add dnstap prerequisite for dnstap system test 2022-12-02 10:23:52 +01:00
Tom Krizek
f514604613 Add libnghttp2 prerequisite for doth system test
While some of these tests are for DoT which doesn't require nghttp2,
the server configs won't allow the server to start without nghttp2
support during compile time.

It might be possible to split these tests into DoT and DoH and only
require nghttp2 for DoH tests, but since almost all of our CI jobs are
compiled with nghttp2, we wouldn't gain a lot of coverage, so it's
probably not worth the effort.
2022-12-02 10:23:52 +01:00
Tom Krizek
b1e011e158 Add lmdb prerequisite for nzd2nzf system test 2022-12-02 10:23:52 +01:00
Tom Krizek
e9d9f11539 Check for pkcs11-tool in keyfromlabel system test
pkcs11-tool which is typically part of the opensc package is required
for the keyfromlabel test.
2022-12-02 10:23:52 +01:00
Tom Krizek
9730ac4c56 Use feature-test feature detection in pytests
Avoid using the environment variables for feature detection and use the
feature-test utility instead.

Remove the obsolete environment variables from conf.sh, since they're no
longer used anywhere.
2022-12-02 10:23:52 +01:00
Tom Krizek
d24fb1122e Use feature-test to detect feature support in system tests
Previously, there were two different ways to detect feature support.
Either through an environment variable set by configure in conf.sh, or
using the feature-test utility.

It is more simple and consistent to have only one way of detecting the
feature support. Using the feature-test utility seems superior the the
environment variables set by configure.
2022-12-02 10:23:51 +01:00
Tom Krizek
e22d27da71 Add missing options to feature-test utility 2022-12-02 10:23:49 +01:00
Artem Boldariev
89d7970072 Merge branch 'artem-tls-listener-avoid-acessing-flags-on-accept' into 'main'
TLS: Avoid accessing listener socket flags from other threads when accepting a connection

See merge request isc-projects/bind9!7154
2022-12-01 20:00:35 +00:00
Artem Boldariev
4b5559cd8f TLS: Avoid accessing listener socket flags from other threads
This commit ensures that the flags inside a TLS listener socket
object (and associated worker) are accessed when accepting a
connection only from within the context of the dedicated thread, but
not other worker threads.
2022-12-01 21:07:49 +02:00
Ondřej Surý
052200cc2b Merge branch 'ondrej-fix-single-read-tlsdns-client' into 'main'
Honour single read per client isc_nm_read() call in the TLSDNS

See merge request isc-projects/bind9!7152
2022-12-01 18:06:45 +00:00
Ondřej Surý
e3c628d562 Honour single read per client isc_nm_read() call in the TLSDNS
The TLSDNS transport was not honouring the single read callback for
TLSDNS client.  It would call the read callbacks repeatedly in case the
single TLS read would result in multiple DNS messages in the decoded
buffer.
2022-12-01 18:31:05 +01:00
Ondřej Surý
5383363ba9 Merge branch '3709-fix-dns_resolver-hash-tables' into 'main'
Refactor the dns_resolver fetch context hash tables and locking

Closes #3709

See merge request isc-projects/bind9!7142
2022-12-01 13:35:08 +00:00
Ondřej Surý
dbc2542ef3 Add CHANGES note for [GL #3709] 2022-12-01 11:42:46 +01:00
Ondřej Surý
7e4e125e5e Refactor the dns_resolver fetch context hash tables and locking
This is second in the series of fixing the usage of hashtables in the
dns_adb and the dns_resolver units.

Currently, the fetch buckets (used to hold the fetch context) and zone
buckets (used to hold per-domain counters) would never get cleaned from
the memory.  Combined with the fact that the hashtable now grows as
needed (instead of using hashtable as buckets), the memory usage in the
resolver can just grow and it never drops down.

In this commit, the usage of hashtables (hashmaps) has been completely
rewritten, so there are no "buckets" and all the matching conditions are
directly mapped into the hashtable key:

 1. For per-domain counter hashtable, this is simple as the lowercase
    domain name is used directly as a counter.

 2. For fetch context hashtable, this requires copying some extra flags
    back and forth in the key.

As we don't hold the "buckets" forever, the cleaning mechanism has been
rewritten as well:

 1. For per-domain counter hashtable, this is again much simpler, as we
    only need to check whether the usage counter is still zero under the
    lock and bail-out on cleaning if the counter is in use.

 2. For fetch context hashtable, this is more complicated as the fetch
    context cannot be reused after it has been finished.  The algorithm
    is different, the fetch context is always removed from the
    hashtable, but if we find the fetch context that has been marked
    as finished in the lookup function, we help with the cleaning from
    the hashtable and try again.

Couple of additional changes have been implemented in this refactoring
as those were needed for correct functionality and could not be split
into individual commits (or would not make sense as seperate commits):

 1. The dns_resolver_createfetch() has an option to create "unshared"
    fetch.  The "unshared" fetch will never get matched, so there's
    little point in storing the "unshared" fetch in the hashtable.
    Therefore the "unshared" fetches are now detached from the
    hashtable and live just on their own.

 2. Replace the custom reference counting with ISC_REFCOUNT_DECL/IMPL
    macros for better tracing.

 3. fctx_done_detach() is idempotent, it makes the "final" detach (the
    one matching the create function) only once.  But that also means
    that it has to be called before the detach that kept the fetch
    context alive in the callback.  A new macro fctx_done_unref() has
    been added to allow this code flow:

    fctx_done_unref(fctx, result);
    fctx_detach(&fctx);

    Doing this the other way around could cause fctx to get destroyed in
    the fctx_unref() first and fctx_done_detach() would cause UAF.

 4. The resume_qmin() and resume_dslookup() callbacks have been
    refactored for more readability and simpler code paths.  The
    validated() callback has also received some of the simplifications,
    but it should be refactored in the future as it is bit of spaghetti
    now.
2022-12-01 11:42:46 +01:00
Evan Hunt
fbc9d14149 Merge branch 'each-cache-use-loops' into 'main'
change cache cleaning to use loops instead of tasks

See merge request isc-projects/bind9!7136
2022-11-30 20:12:29 +00:00
Evan Hunt
09ee254514 change dns_db_settask() to _setloop()
The mechanism for associating a worker task to a database now
uses loops rather than tasks.

For this reason, the parameters to dns_cache_create() have been
updated to take a loop manager rather than a task manager.
2022-11-30 11:47:35 -08:00
Artem Boldariev
73d36a3901 Merge branch 'artem-tls-tcp-compatibility-fixes' into 'main'
TLS Stream: TCP transport compatibility fixes

See merge request isc-projects/bind9!7127
2022-11-30 16:30:03 +00:00