Commit graph

15807 commits

Author SHA1 Message Date
Alessio Podda
d4fd6b323d Skip buffer allocations if not logging
Currently, during IXFR we allocate a 2KB buffer for IXFR change logging
regardless of the log level. This commit introduces an early check
on the log level in dns_diff_print to avoid this.

Results in a speedup from 28% in the test case from issue #5442.

(cherry picked from commit a164492f3c)
2025-11-05 18:38:33 +01:00
Ondřej Surý
619db66c47
Skip unsupported algorithms when looking for signing key
When looking for a signing key in select_signing_key(), the result code
indicating unsupported algorithm would abort the search.  Instead, skip
such keys and continue searching for the right key.

Co-Authored-By: Aram Sargsyan <aram@isc.org>
Co-Authored-By: Petr Menšík <pemensik@redhat.com>
(cherry picked from commit a94a7c1a1e)
2025-11-05 04:36:00 +01:00
Ondřej Surý
2c2cb31394
Drop the unit test for testing randomness
Since we are using system routines for randomness, there's no point
in spending time and run the statistical suite for testing PRNG.

(cherry picked from commit 90b3def5e9)
2025-11-04 20:51:22 +01:00
Evan Hunt
5ed3bebbf4 fix a "max-cache-size" configuration bug
"max-cache-size default;" is allowed, according to the documentation
and the parser, but when it's configured, named crashes due to an
INSIST that the only legal string value is "unlimited". this has
been fied.

the configuration has also been simplified. previously, we checked for
max-cache-size in view and options, then determined whether to look in
the global default options based on whether the view had recursion set.
the default value set there was only applicable to views with recursion.
now, the default is an explicit "default", which affects views with
and without recursion in different ways.

the cfg type for "max-cache-size" has been changed from
cfg_type_sizeorpercent to cfg_type_maxcachesize.

(cherry picked from commit cd921cc7ef)
2025-10-29 11:30:25 -07:00
Mark Andrews
31ae3dc355 Fix "shutdown system test crashed in dns_dispatchmgr_getblackhole"
While shutting down view->dispatchmgr is no longer valid.  Attach
to it and when creates a fetch context and use that pointer instead
of view->dispatchmgr.  Use dns_view_getdispatchmgr to do the attaching
as view->dispatchmgr is it managed using rcu.

(cherry picked from commit 012a47476d)
2025-10-27 22:39:47 +00:00
Ondřej Surý
97487d1abb Fix assertion failure from arc4random_uniform with invalid limit
When the arc4random_uniform() is called on NetBSD with upper_bound that
makes no sense statistically (0 or 1), the call crashes the calling
program.  Fix this by returning 0 when upper bound is < 2 as does Linux,
FreeBSD and NetBSD.  (Hint: System CSPRNG should never crash.)

(cherry picked from commit 871bce312b)
2025-10-24 20:23:32 +00:00
Michał Kępień
b35d6513d8 Merge tag 'v9.20.15' into bind-9.20 2025-10-22 16:16:59 +00:00
Michal Nowak
184cb00814 Use SET_IF_NOT_NULL in isc__nm_base64*
(cherry picked from commit d91e8ed575)
2025-10-22 11:30:33 +00:00
Mark Andrews
2d496ef257 Don't log spurious error "bad key type" in findmatchingkeys
(cherry picked from commit 4c5d48926a)
2025-10-22 12:55:43 +11:00
Aram Sargsyan
3a1922f464 Fix dnssec-keygen key collision checking for KEY rrtype keys
When generating a new key, dnssec-keygen checks for possible
key ID collisions with existing keys. The dnssec.c:findmatchingkeys()
function, which is supposed to get the list of the existing keys,
fails to do that for the existing KEY rrtype keys (i.e. generated
using 'dnssec-keygen -T KEY') because it doesn't pass down to the
dst_key_fromnamedfile() -> dst_key_read_public() functions the type
of the keys it's interested in. Fix the issue by introducing a new
function parameter which tells in which type of keys the caller is
currently interested in.

(cherry picked from commit 49b7ce9a54)
2025-10-22 12:55:41 +11:00
Michal Nowak
bc35b646b9
Use clang-format-21 to update formatting 2025-10-21 12:12:01 +02:00
Ondřej Surý
13b88233be
Fix the assertion failure in the selfsigned DNSKEY handling
The selfsigned_dnskey() function can now return all the return codes
that dns_dnssec_keyfromrdata() can return and this would cause an
assertion failure as we were not expecting new isc_result_t codes.

(cherry picked from commit 7b26176c46)
2025-10-18 09:36:58 +02:00
Mark Andrews
d70cb26231 Fix parse_rr in lib/dns/skr.c was failing to reset the comments
If dns_name_fromtext failed or the subsequent dns_name_compare
failed the lexer's comments state wasn't cleaned up.

(cherry picked from commit e5ceda617d)
2025-10-14 06:48:57 +00:00
Ondřej Surý
26c77915d5
Use arc4random for CSPRNG when available
Use arc4random on platforms where available.  arc4random() provides high
quality cryptographically-secure pseudo-random numbers and is generally
recommended for application use.

The uv_random() call unfortunately uses getentropy() on platforms like
MacOS, OpenBSD or NetBSD which is not recommended for application use.

(cherry picked from commit 4db9e5d90e)
2025-10-02 13:49:33 +02:00
Ondřej Surý
2924910eee
Use cryptographically-secure pseudo-random generator everywhere
It was discovered in an upcoming academic paper that a xoshiro128**
internal state can be recovered by an external 3rd party allowing to
predict UDP ports and DNS IDs in the outgoing queries.  This could lead
to an attacker spoofing the DNS answers with great efficiency and
poisoning the DNS cache.

Change the internal random generator to system CSPRNG with buffering to
avoid excessive syscalls.

Thanks Omer Ben Simhon and Amit Klein of Hebrew University of Jerusalem
for responsibly reporting this to us.  Very cool research!

(cherry picked from commit cffcab9d5f)
2025-10-02 13:49:33 +02:00
Mark Andrews
a266f329e9
Retry lookups with unsigned DNAME over TCP
To prevent spoofed unsigned DNAME responses being accepted retry
response with unsigned DNAMEs over TCP if the response is not TSIG
signed or there isn't a good DNS CLIENT COOKIE.

(cherry picked from commit 2e40705c06)
2025-10-02 12:58:54 +02:00
Mark Andrews
ab97f6e9f4
Further restrict addresses that are cached when processing referrals
Use the owner name of the NS record as the bailwick apex name
when determining which additional records to cache, rather than
the name of the delegating zone (or a parent thereof).

(cherry picked from commit a41054e9e6)
2025-10-02 12:58:54 +02:00
Mark Andrews
1967320413
Tighten restrictions on caching NS RRsets in authority section
To prevent certain spoofing attacks, a new check has been added
to the existing rules for whether NS data can be cached: the owner
name of the NS RRset must be an ancestor of the name being queried.

(cherry picked from commit fa153f791f)
2025-10-02 12:58:54 +02:00
Ondřej Surý
cae2b2289f
Fail the DNSSEC validation if matching but invalid DNSKEY is found
If a matching but cryptographically invalid key was encountered during
the DNSSEC validation, the key would be just skipped and not counted
towards validation failures.  Treat such DNSSEC keys as hard failures
and fail the DNSSEC validation immediatelly instead of continuing the
DNSSEC validation with the next DNSKEYs in the RRset.

Co-authored-by: Matthijs Mekking <matthijs@isc.org>

(cherry picked from commit f00117a422)
2025-10-02 12:32:06 +02:00
Matthijs Mekking
c2c6f60928 Minor refactor of dst code
Convert the defines to enums. Initialize the tags more explicitly and
less ugly.

(cherry picked from commit 4a0c829584)
2025-10-01 12:26:40 +00:00
Colin Vidal
5a98141a00 check plugin config before registering
In named_config_parsefile(), when checking the validity of
named.conf, the checking of plugin correctness was deliberately
postponed until the plugin is loaded and registered. However,
when the plugin was registered, the checking was never actually
done: the plugin_register() implementation was called, but
plugin_check() was not.

This made it necessary to duplicate the correctness checking in both
functions, so that both named-checkconf and named could catch errors.
That should not be required.

ns_plugin_register() now calls the check function before the register
function, and aborts if either one fails.  ns_plugin_check() calls only
the check function.  ns_plugin_check() is used by named-checkconf, and
ns_plugin_register() is used by named. (Note: this design has a
side effect that a call to ns_plugin_register() will result in the
plugin parameters being parsed twice at registration time.)

Partial backport of !11031
2025-10-01 11:16:11 +02:00
Matthijs Mekking
c1bf603bb6
Change checkconf to include built-in dnssec-policy
The configuration should also take into account the built-in
DNSSEC policies when verifying the keys in the key-directory match the
given policy. Update the code accordingly and add some good and
failure test cases.

(cherry picked from commit dcd49f2ead)
2025-09-29 15:13:26 +02:00
Matthijs Mekking
079898cbf6
Implement named-checkconf -k (check keys)
With named-checkconf -k you can check your configuration including
checking the dnssec-policy keys against the configured keystores. If
there is a mismatch in the key files versus the policy, named-checkconf
will fail. This is useful for running before migrating to dnssec-policy.

For logging purposes, introduce a function that writes the identifying
information about a policy key into a string.

Allow a dnssec key to be initialized outside the keymgr code.

Add 'log_errors' to 'cfg_kasp_fromconfig' to avoid duplicate error
logs.

(cherry picked from commit 9fe520ece9)
2025-09-29 15:13:26 +02:00
Mark Andrews
2ce20f6e49
re-split STATIC_ASSERT message
(cherry picked from commit ccc41c7044)
2025-09-29 13:08:04 +02:00
Mark Andrews
0c1dc9a3eb
re-split log message text
(cherry picked from commit a64c350523)
2025-09-29 13:08:04 +02:00
Mark Andrews
2554a724d4 Use signer name when disabling DNSSEC algorithms
When disabling algorithms, use the signer name to determine if the
algorithm is disabled or not.  This allows for algorithms to be
cleanly disabled on a zone level basis.  Previously, just using the
records owner name, "disable-algorithms" could impact resolution of
names that where not disabled.  This does now mean that
"disable-algorithms" can not be used to disable part of a zone anymore.

(cherry picked from commit a0945f6337)
2025-09-29 11:16:24 +10:00
Matthijs Mekking
bd13d0d2af Update the retire interval after full sign
After a full sign we no longer have to need to take the sign delay into
account. Update the timing checks in keymgr_transition_time to determine
the start of the interval: Either the last change, or if SigPublish/
SigDelete is set. The latter case indicates a full sign was done and
so we no longer have to take the sign delay into account.

(cherry picked from commit 489752eb1f)
2025-09-26 14:36:25 +02:00
Matthijs Mekking
76ecde48af Force full sign to generate new signatures
When introducing the kasp logic, a full sign of the zone did not
generate new signatures for the new active keys during a ZSK rollover.

The introduced kasp logic ensured that the rollover is performed
smoothly, as in the signatures are only replaced if the old signature
is close to expiring (depending on the signatures-refresh option).

Fix by maintaining a fullsign boolean value in the signing structure,
that will ensure the RRsets are signed with the correct key, rather
than a similar good key.

In case of a fullsign, we can also remove signatures from inactive
keys.

Remove the unused dns_zone_signwithkey function.

(cherry picked from commit 844bde0c70)
2025-09-26 14:18:57 +02:00
Ondřej Surý
f65c7b0c02
Fix dns_qpmulti_memusage() on empty dns_qpmulti_t instance
The dns_qpmulti_memusage() causes assertion failure when called on
freshly created qpmulti instance because the qp->usage hasn't been
allocated yet.

(cherry picked from commit b2f653b332)
2025-09-17 14:01:44 +02:00
Mark Andrews
d471995445 Remove dns_rdataset_equals as unneeded
(cherry picked from commit 7d765a3514)
2025-09-10 17:09:14 +10:00
Mark Andrews
f8cafb9756 Fix missing RRSIGs for "glue" lookups with CD=1
The code to test whether to store the RRSIGs on DNS_R_UNCHANGED
with CD=1 was failing because the comparison methods of the two
rdatatset instances were not compatible.  Move the testing into
dns_db_addrdataset(), and request it by setting the DNS_ADD_EQUALOK
option.  If the option is set and the old and new rrsets compare
as equal, dns_db_addrdataset() returns ISC_R_SUCCESS instead of
DNS_R_UNCHANGED.

(cherry picked from commit b954a1df43)
2025-09-10 17:08:52 +10:00
Aram Sargsyan
36ef759164 Log the servfail-until-ready message not faster than once per second
Since the log level has been raised, busy servers can "explode" from
the amount of log messages. Use the usual practice of logging "every
once in a while".

(cherry picked from commit 1962857ac4)
2025-09-03 15:43:37 +02:00
Aram Sargsyan
25e08a0cfe Change the "RPZ not ready yet" message and its log level
The "RPZ not ready yet" message is logged at debug 3 level. Use the
info level instead for better visibility.

After raising the log level, the rpz_log_fail_helper() function starts
appending " failed: " the the message. Change the log message so it
makes more sense.

(cherry picked from commit 49356ce944)
2025-09-03 15:43:37 +02:00
Aram Sargsyan
cf687c0bda RPZ 'servfail-until-ready': skip updating SERVFAIL cache
In order to not pollute the SERVFAIL cache with the configured
SERVFAIL answers while RPZ is loading, set the NS_CLIENTATTR_NOSETFC
attribute for the client.

(cherry picked from commit d9b5f6c502)
2025-09-03 15:43:37 +02:00
Mark Andrews
e63501f5b0 Add support for parsing and displaying BRID rdata type
(cherry picked from commit 6b29da55fc)
2025-09-03 11:02:15 +10:00
Mark Andrews
f7dda7943a Add support for parsing and displaying HHIT rdata type
(cherry picked from commit 37041c3ec3)
2025-09-03 11:02:15 +10:00
Mark Andrews
6440743bdc RPZ canonical warning displays zone entry incorrectly
Do not insert a NUL into ip_str too early as the full value
is needed later.  Only insert the NUL immediately before
displaying just the prefix string.

(cherry picked from commit 283da99f02)
2025-09-02 23:43:40 +00:00
Michał Kępień
cae623fa69
Obsolete the "tkey-domain" statement
The "tkey-domain" statement has effectively been a no-op since commit
bd4576b3ce, which removed the only bit of
code using it: the logic implementing TKEY Mode 2 (Diffie-Hellman).

A subsequent cleanup commit, 885c132f4a,
also missed the opportunity to remove the "tkey-domain" statement
altogether.

Mark the "tkey-domain" statement as obsolete and remove all code and
documentation related to it.

(cherry picked from commit 805f1c0f65)
2025-09-01 22:34:08 +02:00
Michał Kępień
5700c77a6f Deprecate the "tkey-gssapi-credential" statement
The "tkey-gssapi-keytab" statement enables GSS-TSIG to be set up in a
simpler and more reliable way than using the "tkey-gssapi-credential"
statement and setting environment variables (e.g. KRB5_KTNAME).

Mark the "tkey-gssapi-credential" statement as deprecated to eventually
only have one method for setting up GSS-TSIG in named.  Do not mention
"tkey-gssapi-credential" in the section of the ARM on dynamic updates.

(cherry picked from commit 6de435c528)
2025-09-01 19:34:14 +00:00
Ondřej Surý
a5d7c8f7db Add and use __attribute__((nonnull)) in dnssec-signzone.c
Clang 20 is complaining about passing NULL to an argument with 'nonnull'
attribute.  Mark these two functions with the same attribute to assure
that these two function also don't accept NULL as an argument.

(cherry picked from commit 9e350c1774)
2025-08-28 14:24:48 +00:00
Thomas Abraham
add7cd3640 ensure file descriptors 0-2 are in use before using libuv
libuv expects file descriptors <= STDERR_FILENO are in use. otherwise,
it may abort when closing a file descriptor it opened.

See https://github.com/libuv/libuv/pull/4559

Closes #5226

(cherry picked from commit 5cfdbeba72)
2025-08-28 08:57:12 +00:00
Aram Sargsyan
369a350e04 Resolve false positive compilation warning from some GCC versions
The complier claims that 'qresult_type' may be used uninitialized,
though all the cases inside the switch either set the variable
or return from the function, and the warning is generated on a line
after the switch-case block.

Slightly modify the code to set a default value for the variable when
declaring it.

    In function 'rpz_rewrite',
        inlined from 'query_checkrpz' at query.c:7288:12,
        inlined from 'query_gotanswer' at query.c:7724:12:
    query.c:4693:14: error: 'qresult_type' may be used uninitialized [-Werror=maybe-uninitialized]
     4693 |             !dnsrps_set_p(&emsg, client, st, qtype, &rdataset,
          |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     4694 |                           qresult_type != qresult_type_recurse))
          |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    query.c: In function 'query_gotanswer':
    query.c:4268:24: note: 'qresult_type' was declared here
     4268 |         qresult_type_t qresult_type;
          |                        ^~~~~~~~~~~~
    cc1: all warnings being treated as errors
2025-08-27 10:00:45 +00:00
Aram Sargsyan
ec2c3db702 Implement '-T slowrpz' named testing option
When used, named processes RPZ zones slowly. Useful for system tests.

(cherry picked from commit 5e718dd220)
2025-08-27 10:00:45 +00:00
Aram Sargsyan
ee29e133ac Add a new 'servfail-until-ready' configuration option for RPZ
By default, when named is started it may start answering to
queries before the response policy zones are completely loaded
and processed. This new feature gives an option to the users to
tell named that incoming requests should result in SERVFAIL anwser
until all the response policy zones are procesed and ready.

(cherry picked from commit 41387b8d30)
2025-08-27 10:00:45 +00:00
Aram Sargsyan
a7a5c79d9a Add 'first_time' member to 'dns_rpz_zones_t'
During the initial configuration of named after startup, 'first_time'
is true. This is needed for implementing the new 'servfail-until-ready'
configuration option, which should take into effect only during the
initial configuration.

(cherry picked from commit 88ed81e12d)
2025-08-27 10:00:45 +00:00
Matthijs Mekking
b022a05cad Detect if keymgr made changes
If so we also want to tickle the apex because DNSKEY/CDNSKEY/CDS
RRsets may need to be re-signed.

Note that this may be overzealous, because if state transitions
happen just because of timing events (RUMOURED -> OMNIPRESENT,
UNRETENTIVE -> HIDDEN) this would have to cause changes in the
zone DNSSEC records.

(cherry picked from commit a0dc0434e5)
2025-08-27 08:16:52 +00:00
Matthijs Mekking
c75cab3f96 Implement manual-mode for kasp
When a key retire, key generation/introduction, or a state transition
to RUMOURED/UNRETENTIVE should happen, instead they are logged.
When those logs look good, you can run 'rndc dnssec -step' to run the
keymgr and apply those steps.

(cherry picked from commit aa49850b5e)
2025-08-27 08:16:52 +00:00
Matthijs Mekking
40d2f99852 Add manual-mode config option
Add a new option 'manual-mode' to 'dnssec-policy'. The intended
use is that if it is enabled, it will not automatically move to the
next state transition (RUMOURED, UNRETENTIVE), only after manual
confirmation. The intended state transition should be logged.

(cherry picked from commit 63c5b453e0)
2025-08-27 08:16:52 +00:00
Ondřej Surý
08328a9cce
Don't preserve cache entries if new TTL is smaller than existing
Under certain circumstances, cache entries with equivalent rdataset
might not get replaced.  Previously such entry would get preserved
regardless of the new TTL and expire time on the existing header would
get updated when the expire time was less than the expire time on the
existing header.  Change the logic to preserve the existing header only
if the new expire time is larger than the existing one and replace the
existing cache entry when the new expire time is less than the existing
one.

Co-authored-by: Jinmei Tatuya <jtatuya@infoblox.com>
(cherry picked from commit 9f7ba584cf)
2025-08-26 21:13:25 +02:00
Ondřej Surý
06e3d996c1
Preserve ZEROTTL attribute when replacing NS RRset
Previously, BIND 9 would drop the ZEROTTL attribute when updating
previously cached NS entry with ZEROTTL attribute set.

Co-authored-by: Jinmei Tatuya <jtatuya@infoblox.com>
(cherry picked from commit 982ca161c2)
2025-08-26 21:12:21 +02:00