Commit graph

14280 commits

Author SHA1 Message Date
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
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
Mark Andrews
9ded7428ad Use explict atomic for older compilers 2023-12-07 22:16:13 +11:00
Mark Andrews
2cc84d7678 Also cleanup the space for the rbt nodes
As we are in overmem state we want to free more memory than we are
adding so we need to add in an allowance for the rbtnodes that may
have been added and the names stored with them.  There is the node
for the owner name and a possible ENT node if there was a node split.

(cherry picked from commit 7e462c2b26)
2023-12-07 21:50:02 +11:00
Mark Andrews
8e5bd86416 Process the combined LRU lists in LRU order
Only cleanup headers that are less than equal to the rbt's last_used
time.  Adjust the rbt's last_used time when the target cleaning was
not achieved to the oldest value of the remaining set of headers.

When updating delegating NS and glue records last_used was not being
updated when it should have been.

When adding zero TTL records to the tail of the LRU lists set
last_used to rbtdb->last_used + 1 rather than now.  This appoximately
preserves the lists LRU order.

(cherry picked from commit 5e8f0e9ceb)
2023-12-07 21:34:19 +11:00
Evan Hunt
374b4d6258 deprecate resolver-retry-interval and resolver-nonbackoff-tries
these options control default timing of retries in the resolver
for experimental purposes; they are not known to useful in production
environments.  they will be removed in the future; for now, we
only log a warning if they are used.

(cherry picked from commit 4aaa4f7dca)
2023-12-06 13:41:47 -08:00
Evan Hunt
8f73814469 correctly limit hash resize to RBTDB_GLUE_TABLE_MAX_BITS
Use < instead of <= when testing the new new hash bits size,
otherwise it can exceed the limit.
2023-12-06 11:30:41 -08:00
Artem Boldariev
d20f1240e2 Fix TLS certs store deletion on concurrent access
During initialisation or reconfiguration, it is possible that multiple
threads are trying to create a TLS context and associated data (like
TLS certs store) concurrently. In some cases, a thread might be too
late to add newly created data to the TLS contexts cache, in which
case it needs to be discarded. In the code that handles that case, it
was not taken into account that, in some cases, the TLS certs store
could not have been created or should not be deleted, as it is being
managed by the TLS contexts cache already. Deleting the store in such
cases might lead to crashes.

This commit fixes the issue.

(cherry picked from commit b109fa9192)
2023-12-06 17:06:51 +02:00
Mark Andrews
3aaf20a2dc Ineffective DbC protections
Dereference before NULL checks.  Thanks to Eric Sesterhenn from X41
D-Sec GmbH for reporting this.

(cherry picked from commit decc17d3b0)
2023-12-06 09:01:05 +11:00
Ondřej Surý
1285238d95
Deprecate AES algorithm for DNS cookies
The AES algorithm for DNS cookies was being kept for legacy reasons,
and it can be safely removed in the next major release.  Mark is as
deprecated, so the `named-checkconf` prints a warning when in use.

(cherry picked from commit 67d14b0ee5)
2023-12-05 10:52:03 +01:00
Matthijs Mekking
3c244da9d4 Recognize escapes when reading the public key
Escapes are valid in DNS names, and should be recognized when reading
the public key from disk.

(cherry picked from commit 71f023a1c3)
2023-11-20 08:35:30 +01:00
Evan Hunt
6b47d98a95 set loadtime during initial transfer of a secondary zone
when transferring in a non-inline-signing secondary for the first time,
we previously never set the value of zone->loadtime, so it remained
zero. this caused a test failure in the statschannel system test,
and that test case was temporarily disabled.  the value is now set
correctly and the test case has been reinstated.

(cherry picked from commit 9643281453)
2023-11-15 18:06:58 -08:00
Mark Andrews
617f73426d Adjust comment to have correct message limit value
(cherry picked from commit 560c245971)
2023-11-16 12:22:08 +11:00
Mark Andrews
ab2a450887 Check that buffer length in dns_message_renderbegin
The maximum DNS message size is 65535 octets. Check that the buffer
being passed to dns_message_renderbegin does not exceed this as the
compression code assumes that all offsets are no bigger than this.

(cherry picked from commit a069513234)
2023-11-16 12:22:08 +11:00
Ondřej Surý
6a85e79c0b
Reformat sources with up-to-date clang-format-17 2023-11-13 17:13:07 +01:00
Mark Andrews
ba7cfd2f92 Suppress reporting upcoming changes in root hints
To reduce the amount of log spam when root servers change their
addresses keep a table of upcoming changes by expected date and time
and suppress reporting differences for them until then.

Add initial entry for B.ROOT-SERVERS.NET, Nov 27, 2023.

(cherry picked from commit b69100b747)
2023-11-03 03:43:49 +11:00
Mark Andrews
15e13bd523 Update b.root-servers.net IP addresses
This covers both root hints and the default primaries for the root
zone mirror.  The official change date is Nov 27, 2023.

(cherry picked from commit 2ca2f7e985)
2023-11-03 03:43:49 +11:00
Michał Kępień
e974f98eb4
Improve stability of the jemalloc workaround
When jemalloc is linked into BIND 9 binaries (rather than preloaded or
used as the system allocator), depending on the decisions made by the
linker, the malloc() symbol may be resolved to a non-jemalloc
implementation at runtime.  Such a scenario foils the workaround added
in commit 2da371d005 as it relies on the
jemalloc implementation of malloc() to be executed.

Handle the above scenario properly by calling mallocx() explicitly
instead of relying on the runtime resolution of the malloc() symbol.
Use trivial wrapper functions to avoid the need to copy multiple #ifdef
lines from lib/isc/mem.c to lib/isc/trampoline.c.  Using a simpler
alternative, e.g. calling isc_mem_create() & isc_mem_destroy(), was
already considered before and rejected, as described in the log message
for commit 2da371d005.

ADJUST_ZERO_ALLOCATION_SIZE() is only used in isc__mem_free_noctx() to
concisely avoid compilation warnings about its 'size' parameter not
being used when building against jemalloc < 4.0.0 (as sdallocx() is then
redefined to dallocx(), which has a different signature).
2023-11-01 18:04:07 +01:00
Matthijs Mekking
76c9019403 Don't ignore auth zones when in serve-stale mode
When serve-stale is enabled and recursive resolution fails, the fallback
to lookup stale data always happens in the cache database. Any
authoritative data is ignored, and only information learned through
recursive resolution is examined.

If there is data in the cache that could lead to an answer, and this can
be just the root delegation, the resolver will iterate further, getting
closer to the answer that can be found by recursing down the root, and
eventually puts the final response in the cache.

Change the fallback to serve-stale to use 'query_getdb()', that finds
out the best matching database for the given query.

(cherry picked from commit 2322425016)
2023-10-31 13:52:08 +01:00
Mark Andrews
8b11061b91 Only declare 'engine' if it is used
Move the declaration of 'engine' within the appropriate #if/#endif
block.  Remove the UNUSED(engine) from the #else block.
2023-10-27 10:49:38 +11:00
Aram Sargsyan
2141bde46b Fix shutdown races in catzs
The dns__catz_update_cb() does not expect that 'catzs->zones'
can become NULL during shutdown.

Add similar checks in the dns__catz_update_cb() and dns_catz_zone_get()
functions to protect from such a case. Also add an INSIST in the
dns_catz_zone_add() function to explicitly state that such a case
is not expected there, because that function is called only during a
reconfiguration.

(cherry picked from commit 4eb4fa288c)
2023-10-23 10:53:40 +00:00
Mark Andrews
306ee4cb28 Adjust UDP timeouts used in zone maintenance
Drop timeout before resending a UDP request from 15 seconds to 5
seconds and add 1 second to the total time to allow for the reply
to the third request to arrive.  This will speed up the time it
takes for named to recover from a lost packet when refreshing a
zone and for it to determine that a primary is down.

(cherry picked from commit 29f399797d)
2023-10-20 00:16:01 +00:00
Mark Andrews
ebfbad29c1 Add parentheses around macro arguement 'msec'
The is needed to ensure that the multiplication is correctly done.
This was reported by Jinmei Tatuya.
2023-10-20 10:30:48 +11:00
Michal Nowak
7c6632e174
Update the source code formatting using clang-format-17 2023-10-18 09:02:57 +02:00
Matthijs Mekking
ac1b70ad00 Don't resign raw version of the zone
Update the function 'set_resigntime()' so that raw versions of
inline-signing zones are not scheduled to be resigned.

Also update the check in the same function for zone is dynamic, there
exists a function 'dns_zone_isdynamic()' that does a similar thing
and is more complete.

Also in 'zone_postload()' check whether the zone is not the raw
version of an inline-signing zone, preventing calculating the next
resign time.

(cherry picked from commit 741ce2d07a)
2023-10-16 10:34:17 +02:00
Ondřej Surý
905f8c5899
Don't undef <unit>_TRACE, instead add comment how to enable it
In units that support detailed reference tracing via ISC_REFCOUNT
macros, we were doing:

    /* Define to 1 for detailed reference tracing */
    #undef <unit>_TRACE

This would prevent using -D<unit>_TRACE=1 in the CFLAGS.

Convert the above mentioned snippet with just a comment how to enable
the detailed reference tracing:

    /* Add -D<unit>_TRACE=1 to CFLAGS for detailed reference tracing */

(cherry picked from commit 6afa961534)
2023-10-13 11:46:41 +02:00
Aram Sargsyan
c061b90cc6 Remove unnecessary NULL-checks in ns__client_setup()
All these pointers are guaranteed to be non-NULL.

Additionally, update a comment to remove obviously outdated
information about the function's requirements.

(cherry picked from commit b970556f21)
2023-10-02 10:04:56 +00:00
Aram Sargsyan
92e5173a9f Don't use an uninitialized link on an error path
Move the block on the error path, where the link is checked, to a place
where it makes sense, to avoid accessing an unitialized link when
jumping to the 'cleanup_query' label from 4 different places. The link
is initialized only after those jumps happen.

In addition, initilize the link when creating the object, to avoid
similar errors.

(cherry picked from commit fb7bbbd1be)
2023-09-28 10:30:42 +00:00
Ondřej Surý
818f4dc3a7
Explicitly cast chars to unsigned chars for <ctype.h> functions
Apply the semantic patch to catch all the places where we pass 'char' to
the <ctype.h> family of functions (isalpha() and friends, toupper(),
tolower()).

(cherry picked from commit 29caa6d1f0)
2023-09-22 17:01:59 +02:00
Michał Kępień
2f08b622bf Merge tag 'v9.18.19' into bind-9.18 2023-09-20 16:52:16 +02:00