Commit graph

14308 commits

Author SHA1 Message Date
Evan Hunt
fe05278424 fix several bugs in the RBTDB dbiterator implementation
- the DNS_DB_NSEC3ONLY and DNS_DB_NONSEC3 flags are mutually
  exclusive; it never made sense to set both at the same time.
  to enforce this, it is now a fatal error to do so.  the
  dbiterator implementation has been cleaned up to remove
  code that treated the two as independent: if nonsec3 is
  true, we can be certain nsec3only is false, and vice versa.
- previously, iterating a database backwards omitted
  NSEC3 records even if DNS_DB_NONSEC3 had not been set. this
  has been corrected.
- when an iterator reaches the origin node of the NSEC3 tree, we
  need to skip over it and go to the next node in the sequence.
  the NSEC3 origin node is there for housekeeping purposes and
  never contains data.
- the dbiterator_test unit test has been expanded, several
  incorrect expectations have been fixed. (for example, the
  expected number of iterations has been reduced by one; we were
  previously counting the NSEC3 origin node and we should not
  have been doing so.)

(cherry picked from commit e40fd4ed06)
2024-02-15 11:34:34 -08:00
Michał Kępień
4ad3c694f1 BIND 9.18.24
-----BEGIN PGP SIGNATURE-----
 
 iQJDBAABCgAtFiEENKwGS3ftSQfs1TU17QVz/8hFYQUFAmXIo/4PHG1pY2hhbEBp
 c2Mub3JnAAoJEO0Fc//IRWEFEe0QAJGj+gBVSNYgTM/ay4tbtmoTbJvmHbIcsRJn
 5ANQD5TPCm+tJCJ4ZFFFmdRiyP/ConXAms2UnyCPggd6hl4av9C32q1Wses9Qr1O
 ZOsgJ1tSuvCCihLTlRIZKdK3/J/fn/iLobgqTZfN6O06Voq6spjJwA7CMktwWr8f
 FsDiZVjnPZJhpnKkGJe3Nk6hsSJuTkF76tJgWSjg44q2PsQXVCUg5AfZBoWmrST0
 OHdhXCirTO1YbFBKL7444O+c/jV54/U+6dr8ofoWX/CRG1kkoQXy1eIdEMnbaruN
 3inzgxCJFiN8ZwwmqFjDmYsGD6jt7E11seBSE9nqX7JczDVOx6umwjNMM5AsCvaW
 BH9PZOli/AKyVXHia7WEpiVlFqsHCh10WvNFhCCv8Jqecy7HeKgQirW5SZUkHs4D
 y5/dzG+dSq3yX+mIM7s/5NyWEIWhsx7Q6m1FEY4uCyk8Z38YYeT0XzmRs62nXoa2
 KqdKUuNzZgBne5ECHRM6h2mA0luOIEJuj8t4xqqsOuPOzfkONJp8PSyStgktJwnf
 jAqZhSWQLF2222kowkCjDDJDqbIGulThntMo8VNRjSDuKgFDHJyk/j3cU0QLYGE9
 ZHc0KxjZbAmYQpCFwxETXPgl6i4VY4ax7yHi0mB7VqsG+5/djZarZObotYDp23yf
 VWzlqkac
 =BLMg
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN SSH SIGNATURE-----
 U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAg25GGAuUyFX1gxo7QocNm8V6J/8
 frHSduYX7Aqk4iJLwAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5
 AAAAQPSjqDoHAxyeh5X6uWwlLa+g4ElTZhkKmKru+61PbSiGGZacV2z3fap5FAyyQz5oLS
 2Qn3cmhvo0jEeaIMOauwM=
 -----END SSH SIGNATURE-----

Merge tag 'v9.18.24' into bind-9.18

BIND 9.18.24
2024-02-14 13:35:19 +01:00
Mark Andrews
1c8851b142 Dissassociate rdatasets returned from dns_ncache_current
lib/dns/validator.c:findnsec3proofs failed to disassociate the
temporary rdataset returned by dns_ncache_current on all paths.

(cherry picked from commit dc94f42209)
2024-02-14 09:38:56 +11:00
Ondřej Surý
c462d65b2f
Fix case insensitive matching in isc_ht hash table implementation
The case insensitive matching in isc_ht was basically completely broken
as only the hashvalue computation was case insensitive, but the key
comparison was always case sensitive.

(cherry picked from commit ec11aa2836)
2024-02-11 11:23:28 +01:00
Ondřej Surý
ec11aa2836
Fix case insensitive matching in isc_ht hash table implementation
The case insensitive matching in isc_ht was basically completely broken
as only the hashvalue computation was case insensitive, but the key
comparison was always case sensitive.

(cherry picked from commit 34ae6916f115fc291865857509433f95c2bc0871)
2024-02-11 09:39:19 +01:00
Ondřej Surý
d43a955d0c
Optimize cname_and_other_data to stop as earliest as possible
Stop the cname_and_other_data processing if we already know that the
result is true.  Also, we know that CNAME will be placed in the priority
headers, so we can stop looking for CNAME if we haven't found CNAME and
we are past the priority headers.

(cherry picked from commit 3f774c2a8a)
2024-02-08 08:48:09 +01:00
Ondřej Surý
6557abc8bc
Optimize the slabheader placement for certain RRTypes
Mark the infrastructure RRTypes as "priority" types and place them at
the beginning of the rdataslab header data graph.  The non-priority
types either go right after the priority types (if any).

(cherry picked from commit 3ac482be7f)
2024-02-08 08:48:09 +01:00
Ondřej Surý
d228dc63c1
Fix missing RRSIG for CNAME with different slabheader order
The cachedb was missing piece of code (already found in zonedb) that
would make lookups in the slabheaders to miss the RRSIGs for CNAME if
the order of CNAME and RRSIG(CNAME) was reversed in the node->data.

(cherry picked from commit 5070c7f5c7)
2024-02-08 08:37:24 +01:00
Aram Sargsyan
cbc0357881 Improve the definition of the DNS_GETDB_* flags
Use the (1 << N) form for defining the flags, in order to avoid
errors like the one fixed in the previous commit.

Also convert the definitions to an enum, as done in some of our
recent refactoring work.

(cherry picked from commit 0d7c7777da)
2024-02-02 15:06:48 +00:00
Aram Sargsyan
2bcd6c2fd3 Fix the DNS_GETDB_STALEFIRST flag
The DNS_GETDB_STALEFIRST flag is defined as 0x0C, which is the
combination of the DNS_GETDB_PARTIAL (0x04) and the
DNS_GETDB_IGNOREACL (0x08) flags (0x04 | 0x08 == 0x0C) , which is
an obvious error.

All the flags should be power of two, so they don't interfere with
each other. Fix the DNS_GETDB_STALEFIRST flag by setting it to 0x10.

(cherry picked from commit be7d8fafe2)
2024-02-02 15:06:43 +00:00
Ondřej Surý
f39cd17a26
Optimize selecting the signing key
Don't parse the crypto data before parsing and matching the id and the
algorithm for consecutive DNSKEYs.  This allows us to parse the RData
only in case the other parameters match allowing us to skip keys that
are of no interest to us, but still would consume precious CPU time by
parsing possibly garbage with OpenSSL.
2024-02-01 21:47:29 +01:00
Ondřej Surý
21af5c9a97
Don't iterate from start every time we select new signing key
Remember the position in the iterator when selecting the next signing
key.  This should speed up processing for larger DNSKEY RRSets because
we don't have to iterate from start over and over again.
2024-02-01 21:47:29 +01:00
Mark Andrews
0add293477
Fail processing incoming DNS message on first validation failure
Stop processing the DNS validation when first validation failure occurs
in the DNS message.
2024-02-01 21:47:29 +01:00
Mark Andrews
439e16e4de
Skip revoked keys when selecting DNSKEY in the validation loop
Don't select revoked keys when iterating through DNSKEYs in the DNSSEC
validation routines.
2024-02-01 21:47:29 +01:00
Ondřej Surý
1b3b0cef22
Split fast and slow task queues
Change the taskmgr (and thus netmgr) in a way that it supports fast and
slow task queues.  The fast queue is used for incoming DNS traffic and
it will pass the processing to the slow queue for sending outgoing DNS
messages and processing resolver messages.

In the future, more tasks might get moved to the slow queues, so the
cached and authoritative DNS traffic can be handled without being slowed
down by operations that take longer time to process.
2024-02-01 21:47:29 +01:00
Aram Sargsyan
cf34bccf4c
fix another message parsing regression
The fix for CVE-2023-4408 introduced a regression in the message
parser, which could cause a crash if an rdata type that can only
occur in the question was found in another section.

(cherry picked from commit 510f1de8a6)
2024-02-01 21:24:26 +01:00
Evan Hunt
6d70ccd128
fix a message parsing regression
the fix for CVE-2023-4408 introduced a regression in the message
parser, which could cause a crash if duplicate rdatasets were found
in the question section. this commit ensures that rdatasets are
correctly disassociated and freed when this occurs.

(cherry picked from commit 4c19d35614)
2024-02-01 21:24:26 +01:00
Matthijs Mekking
b730a65975 Don't also skip keymgr run if checkds is skipped
Checking the DS at the parent only happens if dns_zone_getdnsseckeys()
returns success. However, if this function somehow fails, it can also
prevent the keymgr from running.

Before adding the check DS functionality, the keymgr should only run
if 'dns_dnssec_findmatchingkeys()' did not return an error (either
ISC_R_SUCCESS or ISC_R_NOTFOUND). After this change the correct
result code is used again.

(cherry picked from commit 07c2acf15d)
2024-02-01 13:32:56 +01:00
Aydın Mercan
afb0b3971c
Forward declare mallocx in isc/mem.h
cmocka.h and jemalloc.h/malloc_np.h has conflicting macro definitions.
While fixing them with push_macro for only malloc is done below, we only
need the non-standard mallocx interface which is easy to just define by
ourselves.

(cherry picked from commit 197de93bdc)
2024-01-18 10:40:46 +01:00
Ondřej Surý
f82f4d1d77
Add workaround for jemalloc linking order
Because we don't use jemalloc functions directly, but only via the
libisc library, the dynamic linker might pull the jemalloc library
too late when memory has been already allocated via standard libc
allocator.

Add a workaround round isc_mem_create() that makes the dynamic linker
to pull jemalloc earlier than libc.

(cherry picked from commit 41a0ee1071)
2024-01-18 10:40:46 +01:00
Artem Boldariev
7b390a7fb6 Fix reading extra messages in TLS DNS in client mode
When connecting to a remote party the TLS DNS code could process more
than one message at a time despite the fact that it is expected that
we should stop after every DNS message.

Every DNS message is handled and consumed from the input buffer by
isc__nm_process_sock_buffer(). However, as opposed to TCP DNS code, it
can be called more than once when processing incoming data from a
server (see tls_cycle_input()). That, in turn means that we can
process more than one message at a time. Some higher level code might
not expect that, as it breaks the contract.

In particular, in the original report that happened during
isc__nm_async_tlsdnsshutdown() call: when shutting down multiple calls
to tls_cycle() are possible (each possibly leading to a
isc__nm_process_sock_buffer()). If there are any non processed
messages left, for any of the messages left the read callback will be
called even when it is not expected as there were no preceding
isc_nm_read().

To keep TCP DNS and TLS DNS code in sync, we make a similar change to
it as well, although it should not matter.
2024-01-17 22:35:25 +02:00
Matthijs Mekking
0daae0bdcf Fix CDS/CDNSKEY is published logging
The logs were misplaced, it was logging "CDS is published" when the
CDNSKEY is being published and vice versa.
2024-01-17 10:05:20 +01:00
Artem Boldariev
cff69c65b5 Fix flawed logic when detecting same listener type
The older version of the code was reporting that listeners are going
to be of the same type after reconfiguration when switching from DoT
to HTTPS listener, making BIND abort its executions.

That was happening due to the flaw in logic due to which the code
could consider a current listener and a configuration for the new one
to be of the same type (DoT) even when the new listener entry is
explicitly marked as HTTP.

The checks for PROXY in between the configuration were masking that
behaviour, but when porting it to 9.18 (when there is no PROXY
support), the behaviour was exposed.

Now the code mirrors the logic in 'interface_setup()' closely (as it
was meant to).

(cherry picked from commit 8ae661048d)
2024-01-15 14:31:06 +02:00
Artem Boldariev
2be0acf3f3 Recreate listeners on DNS transport change
This commit ensures that listeners are recreated on reconfiguration in
the case when their type changes (or when PROXY protocol type changes,
too).

Previously, if a "listen-on" statement was modified to represent a
different transport, BIND would not pick-up the change on
reconfiguration if listener type changes (e.g. DoH -> DoT) for a given
interface address and port combination. This commit fixes that by
recreating the listener.

Initially, that worked for most of the new transports as we would
recreate listeners on each reconfiguration for DoH and DoT. But at
some point we changed that in such a way that listeners were not
recreated to avoid rebinding a port as on some platforms only root can
do that for port numbers <1000, making some ports binding possible
only on start-up. We chose to asynchronously update listener socket
settings (like TLS contexts, HTTP settings) instead.

Now, we both avoid recreating the sockets if unnecessary and recreate
listeners when listener type changes.

(cherry picked from commit d59cf5e0ce)
2024-01-15 14:31:06 +02:00
Mark Andrews
9999eebbf7 Report the type being filtered from an UPDATE
When processing UPDATE request DNSKEY, CDNSKEY and CDS record that
are managed by named are filtered out.  The log message has been
updated to report the actual type rather that just DNSKEY.

(cherry picked from commit 2cf6cf967d)
2024-01-13 01:58:57 +11:00
Mark Andrews
ecd5459a4d Silence potential unreachable message 2024-01-12 19:56:54 +11:00
Mark Andrews
4efcfa8f1c Apply filters to CDS and CDNSKEY records 2024-01-12 19:56:54 +11:00
Matthijs Mekking
88734ac7cf Add function to check if a DNSKEY record is in use
Add a function that checks whether a DNSKEY, CDNSKEY, or CDS record
belongs to a key that is being used for signing.

(cherry picked from commit 3b6e9a5fa7)
2024-01-12 19:56:54 +11:00
Matthijs Mekking
0d36d98791 Add new dns_rdatatype_iskeymaterial() function
The following code block repeats quite often:

    if (rdata.type == dns_rdatatype_dnskey ||
        rdata.type == dns_rdatatype_cdnskey ||
        rdata.type == dns_rdatatype_cds)

Introduce a new function to reduce the repetition.

(cherry picked from commit ef58f2444f)
2024-01-12 19:56:54 +11:00
Matthijs Mekking
74109dfea6 Make make_dnskey() a public funcion
It can be used to compare DNSKEY, CDNSKEY, and CDS records with
signing keys.

(cherry picked from commit 81cb18b8a2)
2024-01-12 19:56:54 +11:00
Matthijs Mekking
2a6ee4a9a0 Write new DNSKEY TTL to key file
When the current DNSKEY TTL does not match the one from the policy,
write the new TTL to disk.

(cherry picked from commit b770740b44)
2024-01-12 19:56:19 +11:00
Mark Andrews
59067fc568 Only create private records for DNSKEYs that have changed
We don't need to create private records for DNSKEY records that
have only had their TTL's changed.

(cherry picked from commit 27e74b2e4b)
2024-01-12 19:56:19 +11:00
Mark Andrews
c1d1f35f13 sync_secure_db failed to handle some TTL changes
If the DNSKEY, CDNSKEY or CDS RRset had different TTLs then the
filtering of these RRset resulted in dns_diff_apply failing with
"not exact". Identify tuple pairs that are just TTL changes and
allow them through the filter.

(cherry picked from commit d601a90ea3)
2024-01-12 19:56:19 +11:00
Mark Andrews
5bea0d3588 Use the current CDS and CDNSKEY TTLs
When adding new CDS and CDNSKEY records use the existing RRset
TTL if they already exist.

(cherry picked from commit 21be35c54e)
2024-01-12 19:56:19 +11:00
Mark Andrews
3a0b3e92bd Update the DNSKEY, CDNSKEY and CDS TTLs to match dnskey-ttl
If the TTLs of the DNSKEY, CDNSKEY and CDS do not match the
dnskey-ttl update them by removing all records and re-adding
them with the correct TTL.

(cherry picked from commit dcb7799061)
2024-01-12 19:56:19 +11:00
Michał Kępień
a9af1ac5ae
Limit isc_task_send() overhead for tree pruning
Instead of issuing a separate isc_task_send() call for every RBTDB node
that triggers tree pruning, maintain a list of nodes from which tree
pruning can be started from and only issue an isc_task_send() call if
pruning has not yet been triggered by another RBTDB node.

In some older BIND 9 branches, the extra queuing overhead eliminated by
this change could be remotely exploited to cause excessive memory use.
Due to architectural shift, this branch is not vulnerable to that issue,
but applying the fix to the latter is nevertheless deemed prudent for
consistency and to make the code future-proof.

(cherry picked from commit 24381cc36d)
2024-01-05 12:38:16 +01:00
Mark Andrews
f7e137f321
Restore dns64 state during serve-stale processing
If we are in the process of looking for the A records as part of
dns64 processing and the server-stale timeout triggers, redo the
dns64 changes that had been made to the orignal qctx.

(cherry picked from commit 1fcc483df1)
2024-01-05 12:20:25 +01:00
Mark Andrews
b42b1fe051
Save the correct result value to resume with nxdomain-redirect
The wrong result value was being saved for resumption with
nxdomain-redirect when performing the fetch.  This lead to an assert
when checking that RFC 1918 reverse queries where not leaking to
the global internet.

(cherry picked from commit 9d0fa07c5e)
2024-01-05 12:03:59 +01:00
Ondřej Surý
849c05adf4
Use hashtable when parsing a message
When parsing messages use a hashtable instead of a linear search to
reduce the amount of work done in findname when there's more than one
name in the section.

There are two hashtables:

1) hashtable for owner names - that's constructed for each section when
we hit the second name in the section and destroyed right after parsing
that section;

2) per-name hashtable - for each name in the section, we construct a new
hashtable for that name if there are more than one rdataset for that
particular name.

(cherry picked from commit b8a9631754)
2024-01-05 11:50:23 +01:00
Mark Andrews
f46a81932f
Address race in dns_tsigkey_find()
Restart the process with a write lock if we discover an expired key
while holding the read lock.

(cherry picked from commit d2ba96488e)
2024-01-05 11:19:58 +01:00
Aydın Mercan
a83c749115
Use <isc/atomic.h> instead of <stdatomic.h> directly in <isc/types.h> 2024-01-03 20:36:35 +03:00
Aydın Mercan
6c0ae4ef6e
Move atomic statscounter next to the non-atomic definition
(cherry picked from commit 9c4dd863a6)
2024-01-03 20:36:35 +03:00
Aydın Mercan
9601763943
Use a non-atomic counter when passing to stats dumper
(cherry picked from commit bb96142a17)
2024-01-03 20:36:35 +03:00
Petr Špaček
d33b0f9ddb
Avoid overflow during statistics dump
Related: !1493
Fixes: #4467
(cherry picked from commit 7b0115e331)
2024-01-03 20:10:27 +03:00
Mark Andrews
d78df5f96d Don't delete the NSEC3PARAM immediately
Wait until the new NSEC or NSEC3 chain is generated then it should
be deleted.

(cherry picked from commit f3ae88d84e)
2023-12-21 22:07:53 +11:00
Mark Andrews
0ceb01386c Don't look for KSK status here and squash memory leak
Just remove the key from  consideration as it is being removed.

The old code could leak a key reference as dst_free_key was not
called every time we continued. This simplification will address
this as well.

(cherry picked from commit a3d0476d17)
2023-12-21 10:05:54 +11:00
Mark Andrews
a2bcd4fc0e Log what change generated a 'not exact' error
(cherry picked from commit c896e07277)
2023-12-20 02:47:42 +11:00
Mark Andrews
65fdc892eb Use 'now' rather than 'inception' in 'add_sigs'
When kasp support was added 'inception' was used as a proxy for
'now' and resulted in signatures not being generated or the wrong
signatures being generated.  'inception' is the time to be set
in the signatures being generated and is usually in the past to
allow for clock skew.  'now' determines what keys are to be used
for signing.

(cherry picked from commit 6066e41948)
2023-12-19 12:39:16 +11:00
Michał Kępień
8882d88731
"trust-anchor-telemetry" is no longer experimental
Remove the CFG_CLAUSEFLAG_EXPERIMENTAL flag from the
"trust-anchor-telemetry" statement as the behavior of the latter has not
been changed since its initial implementation and there are currently no
plans to do so.  This silences a relevant log message that was emitted
even when the feature was explicitly disabled.

(cherry picked from commit b1baf7af3a)
2023-12-18 15:13:34 +01:00
Mark Andrews
adfb365602 NetBSD has added 'hmac' to libc so rename our uses of hmac
(cherry picked from commit fd077c2661)
2023-12-14 11:14:04 +11:00