Commit Graph

37219 Commits

Author SHA1 Message Date
Mark Andrews
645dd3fdf1 Add release note for [GL #3622]
(cherry picked from commit 42c42be9a9)
2023-01-12 12:27:28 +01:00
Mark Andrews
a4b760d8f6 Add CHANGES note for [GL #3622]
(cherry picked from commit 8ca018b5ec)
2023-01-12 12:27:28 +01:00
Mark Andrews
38323f3b9f Move the mapping of SIG and RRSIG to ANY
dns_db_findext() asserts if RRSIG is passed to it and
query_lookup_stale() failed to map RRSIG to ANY to prevent this.  To
avoid cases like this in the future, move the mapping of SIG and RRSIG
to ANY for qctx->type to qctx_init().

(cherry picked from commit 56eae06418)
2023-01-12 12:27:28 +01:00
Michał Kępień
35c40a8053 Merge branch '3523-confidential-update-quota-v9_18' into 'security-v9_18'
[9.18] [CVE-2022-3094] apply quotas to updates

See merge request isc-private/bind9!490
2023-01-12 11:08:07 +00:00
Evan Hunt
5a7d1d2d0c CHANGES and release notes for [GL #3523]
(cherry picked from commit 991de0aa76)
2023-01-12 12:02:35 +01:00
Evan Hunt
24a684db94 test failure conditions
verify that updates are refused when the client is disallowed by
allow-query, and update forwarding is refused when the client is
is disallowed by update-forwarding.

verify that "too many DNS UPDATEs" appears in the log file when too
many simultaneous updates are processing.

(cherry picked from commit b91339b80e)
2023-01-12 12:02:35 +01:00
Evan Hunt
65d70ebd20 move update ACL and update-policy checks before quota
check allow-update, update-policy, and allow-update-forwarding before
consuming quota slots, so that unauthorized clients can't fill the
quota.

(this moves the access check before the prerequisite check, which
violates the precise wording of RFC 2136. however, RFC co-author Paul
Vixie has stated that the RFC is mistaken on this point; it should have
said that access checking must happen *no later than* the completion of
prerequisite checks, not that it must happen exactly then.)

(cherry picked from commit 964f559edb)
2023-01-12 12:02:35 +01:00
Evan Hunt
3d2033bb89 add a configuration option for the update quota
add an "update-quota" option to configure the update quota.

(cherry picked from commit f57758a730)
2023-01-12 12:02:35 +01:00
Evan Hunt
9f1ebd25f6 add an update quota
limit the number of simultaneous DNS UPDATE events that can be
processed by adding a quota for update and update forwarding.
this quota currently, arbitrarily, defaults to 100.

also add a statistics counter to record when the update quota
has been exceeded.

(cherry picked from commit 7c47254a14)
2023-01-12 12:02:35 +01:00
Ondřej Surý
dec1bf29fd Merge branch '3212-implement-incremental-rehashing-for-isc_ht-hashtables-v9_18' into 'v9_18'
[9.18] Implement incremental hash table resizing in isc_ht

See merge request isc-projects/bind9!7355
2023-01-11 17:01:00 +00:00
Ondřej Surý
68c094c59a Add CHANGES note for [GL #3212]
(cherry picked from commit 5ccb28d6d8)
2023-01-11 17:16:35 +01:00
Ondřej Surý
8c31a939c9 Implement incremental hash table resizing in isc_ht
Previously, an incremental hash table resizing was implemented for the
dns_rbt_t hash table implementation.  Using that as a base, also
implement the incremental hash table resizing also for isc_ht API
hashtables:

 1. During the resize, allocate the new hash table, but keep the old
    table unchanged.
 2. In each lookup, delete, or iterator operation, check both tables.
 3. Perform insertion operations only in the new table.
 4. At each insertion also move <r> elements from the old table to
    the new table.
 5. When all elements are removed from the old table, deallocate it.

To ensure that the old table is completely copied over before the new
table itself needs to be enlarged, it is necessary to increase the
size of the table by a factor of at least (<r> + 1)/<r> during resizing.

In our implementation <r> is equal to 1.

The downside of this approach is that the old table and the new table
could stay in memory for longer when there are no new insertions into
the hash table for prolonged periods of time as the incremental
rehashing happens only during the insertions.

(cherry picked from commit e42cb1f198)
2023-01-11 17:15:33 +01:00
Arаm Sаrgsyаn
c120cc40f5 Merge branch 'aram/dns_fwdtable_addfwd-cleanup-bugfix-v9_18' into 'v9_18'
[9.18] Fix dns_fwdtable_addfwd() error path cleanup bug

See merge request isc-projects/bind9!7354
2023-01-11 14:25:44 +00:00
Aram Sargsyan
39cc597022 Use sizeof(*ptr) for allocating/freeing memory in forward.c
As shown in the previous commit, using sizeof(type_t) is a little
bit more error-prone when copy-pasting code, so extracting the
size information from the pointer which is being dealt with seems
like a better alternative.

(cherry picked from commit cf4003fa58)
2023-01-11 13:42:09 +00:00
Aram Sargsyan
64c8e63942 Fix dns_fwdtable_addfwd() error path cleanup bug
Free 'sizeof(dns_forwarder_t)' bytes of memory instead of
'sizeof(dns_sockaddr_t)' bytes, because `fwd` is a pointer
to a 'dns_forwarder_t' type structure.

(cherry picked from commit 0cc1b06d98)
2023-01-11 13:42:09 +00:00
Arаm Sаrgsyаn
6d3c38e381 Merge branch '3768-dns_zonemgr-use-after-free-v9_18' into 'v9_18'
[9.18] Fix a use-after-free bug in dns_zonemgr_releasezone()

See merge request isc-projects/bind9!7351
2023-01-11 12:53:01 +00:00
Aram Sargsyan
7643e0b60a Add a CHANGES note for [GL #3768]
(cherry picked from commit d50cb1d45d)
2023-01-11 12:16:40 +00:00
Aram Sargsyan
4121af8f7e Fix a use-after-free bug in dns_zonemgr_releasezone()
The dns_zonemgr_releasezone() function makes a decision to destroy
'zmgr' (based on its references count, after decreasing it) inside
a lock, and then destroys the object outside of the lock.

This causes a race with dns_zonemgr_detach(), which could destroy
the object in the meantime.

Change dns_zonemgr_releasezone() to detach from 'zmgr' and destroy
the object (if needed) using dns_zonemgr_detach(), outside of the
lock.

(cherry picked from commit c1fc212253)
2023-01-11 12:16:23 +00:00
Ondřej Surý
4ad0cc8118 Merge branch 'ondrej/use-pthread_barrier-if-available-v9_18' into 'v9_18'
[9.18] Prefer the pthread_barrier implementation over uv_barrier

See merge request isc-projects/bind9!7350
2023-01-11 10:21:46 +00:00
Ondřej Surý
6906b42cdd Prefer the pthread_barrier implementation over uv_barrier
Prefer the pthread_barrier implementation on platforms where it is
available over uv_barrier implementation.  This also solves the problem
with thread sanitizer builds on macOS that doesn't have pthread barrier.

(cherry picked from commit d07c4a98da)
2023-01-11 10:21:39 +00:00
Ondřej Surý
fa53e4f87c Merge branch '3772-revert-fix-single-read-tlsdns-client-v9_18' into 'v9_18'
Don't honour single read per client isc_nm_read() call in the TLSDNS

See merge request isc-projects/bind9!7349
2023-01-11 10:20:49 +00:00
Ondřej Surý
cb3990001f Add CHANGES and release note for [GL #3772] 2023-01-11 10:42:03 +01:00
Ondřej Surý
d0d9e7dfb2 Don't honour single read per client isc_nm_read() call in the TLSDNS
This reverts commit f17f5e831b that made
following change:

> 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.

Turns out that this change broke XoT, so we are reverting the change
until we figure out a proper fix that will keep the design promise and
not break XoT at the same time.
2023-01-11 10:17:55 +01:00
Matthijs Mekking
614d5c3334 Merge branch '3743-unexpected-prohibited-ede-v9_18' into 'v9_18'
[9.18] Fix unexpected "Prohibited" extended DNS error on allow-recursion mismatch

See merge request isc-projects/bind9!7324
2023-01-10 10:02:22 +00:00
Matthijs Mekking
29963f4c0e Add system test for #3743
(cherry picked from commit 8db8ec1f6e)
2023-01-10 10:02:14 +00:00
Matthijs Mekking
f8b7bb7c9f Add release note and CHANGES for #3743
(cherry picked from commit e43a26fd1e)
2023-01-10 10:02:14 +00:00
Matthijs Mekking
f481073110 Don't set EDE in ns_client_aclchecksilent
The ns_client_aclchecksilent is used to check multiple ACLs before
the decision is made that a query is denied. It is also used to
determine if recursion is available. In those cases we should not
set the extended DNS error "Prohibited".

(cherry picked from commit 798c8f57d4)
2023-01-10 10:02:14 +00:00
Mark Andrews
81f8b8fc14 Merge branch '3787-siphash-c-105-26-runtime-error-applying-zero-offset-to-null-pointer-v9_18' into 'v9_18'
[9.18] Accept 'in=NULL' with 'inlen=0' in isc_{half}siphash24

See merge request isc-projects/bind9!7341

Backport of MR !7339
2023-01-10 08:28:15 +00:00
Mark Andrews
f99593a9ca Accept 'in=NULL' with 'inlen=0' in isc_{half}siphash24
Arthimetic on NULL pointers is undefined.  Avoid arithmetic operations
when 'in' is NULL and require 'in' to be non-NULL if 'inlen' is not zero.

(cherry picked from commit 349c23dbb7)
2023-01-10 18:36:08 +11:00
Evan Hunt
12de356ed6 Merge branch '3773-remove-dscp-v9_18' into 'v9_18'
[9.18] Merge branch '3773-remove-dscp' into 'main'

See merge request isc-projects/bind9!7336
2023-01-10 00:20:14 +00:00
Evan Hunt
55d728a678 CHANGES and release note for [GL #3773]
(cherry picked from commit 34a7166029)
2023-01-09 14:24:23 -08:00
Evan Hunt
5fd93c66aa remove nonfunctional DSCP implementation
DSCP has not been fully working since the network manager was
introduced in 9.16, and has been completely broken since 9.18.
This seems to have caused very few difficulties for anyone,
so we have now marked it as obsolete and removed the
implementation.

To ensure that old config files don't fail, the code to parse
dscp key-value pairs is still present, but a warning is logged
that the feature is obsolete and should not be used. Nothing is
done with configured values, and there is no longer any
range checking.

(cherry picked from commit 916ea26ead)
2023-01-09 14:23:26 -08:00
Michal Nowak
703c799376 Merge branch 'mnowak/abort-on-ubsan-errors-v9_18' into 'v9_18'
[9.18] Abort on UBSAN errors

See merge request isc-projects/bind9!7327
2023-01-09 17:07:44 +00:00
Michal Nowak
addd4141a7 Abort on UBSAN errors
Previously, UBSAN errors might slip undetected.

(cherry picked from commit 1451bb7390)
2023-01-09 17:40:32 +01:00
Matthijs Mekking
815ac08a26 Merge branch '3678-serve-stale-servfailing-unexpectedly-v9_18' into 'v9_18'
[9.18] Resolve "stale-serve and RPZ put in SERVFAIL cache unexpected record"

See merge request isc-projects/bind9!7310
2023-01-09 15:01:49 +00:00
Michał Kępień
90408617d7 Check for NULL before dereferencing qctx->rpz_st
Commit 9ffb4a7ba1 causes Clang Static
Analyzer to flag a potential NULL dereference in query_nxdomain():

    query.c:9394:26: warning: Dereference of null pointer [core.NullDereference]
            if (!qctx->nxrewrite || qctx->rpz_st->m.rpz->addsoa) {
                                    ^~~~~~~~~~~~~~~~~~~
    1 warning generated.

The warning above is for qctx->rpz_st potentially being a NULL pointer
when query_nxdomain() is called from query_resume().  This is a false
positive because none of the database lookup result codes currently
causing query_nxdomain() to be called (DNS_R_EMPTYWILD, DNS_R_NXDOMAIN)
can be returned by a database lookup following a recursive resolution
attempt.  Add a NULL check nevertheless in order to future-proof the
code and silence Clang Static Analyzer.

(cherry picked from commit 07592d1315)
(cherry picked from commit a4547a1093)
2023-01-09 14:26:02 +01:00
Aram Sargsyan
096d980a87 Add a CHANGES note for [GL #3678]
(cherry picked from commit 40dee61a1e)
2023-01-09 14:26:02 +01:00
Matthijs Mekking
271bc20b1c 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.

(cherry picked from commit 91a1a8efc5)
2023-01-09 14:26:02 +01:00
Aram Sargsyan
d54e7052ab 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.

(cherry picked from commit 537187bf2f)
2023-01-09 14:26:02 +01:00
Ondřej Surý
bea3d7994a Merge branch '3766-pin-TCP-dispatch-to-threads-v9_18' into 'v9_18'
[9.18] Pin the dns_dispatch to threads when reusing

See merge request isc-projects/bind9!7302
2023-01-05 10:25:32 +00:00
Ondřej Surý
0e263b34c6 Pin the dns_dispatch to threads when reusing
Previously, dns_dispatch_gettcp() could pick a TCP connection created by
different thread - this breaks our contractual promise to DNS dispatch
by using the TCP connection on a different thread than it was created.
Add .tid member to the dns_dispatch_t struct and skip the dispatches
from other threads when looking up a TCP dispatch that we can reuse in
dns_request.

NOTE: This is going to be properly refactored, but this change could be
also backported to 9.18 for better stability and thread-affinity.

(cherry picked from commit 1a999353cd)
2023-01-05 10:20:47 +01:00
Tony Finch
3c411ad294 Merge branch '3745-delzone-catz-v9_18' into 'v9_18'
[9.18] Don't crash when rndc delzone encounters a catz member

See merge request isc-projects/bind9!7297
2023-01-04 18:56:07 +00:00
Tony Finch
03beb6e355 Don't crash when rndc delzone encounters a catz member
This bug was masked in the tests because the `catz` test script did an
`rndc addzone` before an `rndc delzone`. The `addzone` autovivified
the NZF config, so `delzone` worked OK.

This commit swaps the order of two sections of the `catz` test script
so that it uses `delzone` before `addzone`, which provokes a crash
when `delzone` requires a non-NULL NZF config.

To fix the crash, we now try to remove the zone from the NZF config
only if it was dynamically added but not by a catalog zone.

(cherry picked from commit 9fa20d6f6c)
2023-01-04 17:50:44 +00:00
Ondřej Surý
f5e7192691 Merge branch '3723-dont-shutdown-invalid-tasks-v9_18' into 'v9_18'
[v9.18] Don't cleanup uninitialized dns_resolver buckets

See merge request isc-projects/bind9!7286
2023-01-03 11:54:21 +00:00
Ondřej Surý
d48f5e253f Don't cleanup uninitialized dns_resolver buckets
If the isc_task_create_bound() fails in the middle of buckets
initialization - the most common case would be shutdown initialized
during reload, not all tasks would be initialized, but the cleanup
code would try to cleanup all buckets.

Make sure that we cleanup only the initialized buckets by setting
ntasks to the number of already initialized tasks on the error path.
2023-01-03 10:33:23 +01:00
Michał Kępień
04d4a608b8 Merge branch 'michal/update-copyright-year-to-2023-v9_18' into 'v9_18'
[9.18] Update copyright year to 2023

See merge request isc-projects/bind9!7283
2023-01-02 13:16:50 +00:00
Michał Kępień
d72070f30e Update copyright year to 2023
(cherry picked from commit 1a5d707f52)
2023-01-02 14:12:23 +01:00
Arаm Sаrgsyаn
a21562c6cf Merge branch 'aram/dns_dispatch_createtcp-bugfix-v9_18' into 'v9_18'
[9.18] Don't pass a NULL pointer to isc_sockaddr_format()

See merge request isc-projects/bind9!7278
2022-12-28 14:54:16 +00:00
Aram Sargsyan
35b5ba2ff4 Don't pass a NULL pointer to isc_sockaddr_format()
The 'localaddr' pointer can be NULL, which causes an assertion failure.

Use '&disp->local' instead when printing a debug log message.

(cherry picked from commit 41ca9d419e)
2022-12-28 14:19:37 +00:00
Tom Krizek
5102e676e7 Merge branch 'tkrizek/gitignore-fixes-v9_18' into 'v9_18'
[9.18] Don't track gitignored files in the repo

See merge request isc-projects/bind9!7274
2022-12-23 14:14:28 +00:00