]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
13 months agoCollapse common switch cases when emitting EDNS options
Mark Andrews [Tue, 29 Oct 2024 23:41:21 +0000 (10:41 +1100)] 
Collapse common switch cases when emitting EDNS options

The CHAIN and REPORT-CHANNEL EDNS options are both domain names, so they
can be combined.  THE CLIENT-TAG and SERVER-TAG EDNS options are both 16
bit integers, so they can be combined.

13 months agofix: usr: Disable own memory context for libxml2 on macOS
Ondřej Surý [Fri, 18 Apr 2025 18:50:18 +0000 (18:50 +0000)] 
fix: usr: Disable own memory context for libxml2 on macOS

Apple broke custom memory allocation functions in the system-wide libxml2 starting with macOS Sequoia 15.4.  Usage of the custom memory allocation functions has been disabled on macOS.

Closes #5268

Merge branch '5268-disable-libxml2-memory-management-on-macos' into 'main'

See merge request isc-projects/bind9!10374

13 months agoDisable own memory context for libxml2 on macOS 15.4 Sequoia
Ondřej Surý [Fri, 4 Apr 2025 10:22:15 +0000 (12:22 +0200)] 
Disable own memory context for libxml2 on macOS 15.4 Sequoia

The custom allocation API for libxml2 is deprecated starting in macOS
Sequoia 15.4, iOS 18.4, tvOS 18.4, visionOS 2.4, and tvOS 18.4.

Disable the memory function override for libxml2 when
LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS is defined as Apple
broke the system-wide libxml2 starting with macOS Sequoia 15.4.

13 months agochg: test: Rewrite kasp system test to pytest (2)
Matthijs Mekking [Thu, 17 Apr 2025 12:25:36 +0000 (12:25 +0000)] 
chg: test: Rewrite kasp system test to pytest (2)

Convert the first batch of tests from `kasp/tests.sh` to `kasp/tests_kasp.py`.

Merge branch 'matthijs-pytest-rewrite-kasp-system-test-2' into 'main'

See merge request isc-projects/bind9!10253

13 months agoFix bugs in isctest.kasp
Matthijs Mekking [Fri, 11 Apr 2025 17:54:15 +0000 (12:54 -0500)] 
Fix bugs in isctest.kasp

isctest.util was not imported so file_contents_contain could not be
found. And rename verify_keys to check_keys because it asserts in
isctest.run.retry_with_timeout.

13 months agoThe kasp tests require dnspython >= 2.0.0
Matthijs Mekking [Tue, 18 Mar 2025 09:06:29 +0000 (10:06 +0100)] 
The kasp tests require dnspython >= 2.0.0

The kasp tests make use of dns.update.UpdateMessage and dns.tsig.Key,
that are introduced in dnspython 2.0.0.

13 months agoConvert some special kasp test cases to pytest
Matthijs Mekking [Fri, 14 Mar 2025 12:42:30 +0000 (13:42 +0100)] 
Convert some special kasp test cases to pytest

This converts a special characters test case, a max-zone-ttl error
check, and two cases of insecure zones.

We no longer assert for having more than one DNSKEY and/or RRSIG
records. If the zone is insecure, this is no longer always true. And
we already check for the expected number of records in the
check_dnskeys/check_signatures functions.

13 months agoConvert dynamic zone test cases to pytest
Matthijs Mekking [Fri, 14 Mar 2025 12:08:44 +0000 (13:08 +0100)] 
Convert dynamic zone test cases to pytest

This commit deals with converting the dynamic zone test cases to
pytest. The tests for 'inline-signing.kasp' are similar to the default
case, so these are added to 'test_kasp_default'.

Unfortunately I need to add sleep calls in between freezing, updating,
and thawing a zone. Without it the intermittent failures are too
frequent.

13 months agoConvert kasp default test cases to pytest
Matthijs Mekking [Fri, 14 Mar 2025 11:52:36 +0000 (12:52 +0100)] 
Convert kasp default test cases to pytest

This commit deals with converting the test cases related to the default
dnssec-policy.

This requires a new method 'check_update_is_signed'. This method will
be used in future tests as well, and checks if an expected record is
in the zone and is properly signed.

Remove the counterparts for the newly added test from the kasp shell
tests script.

13 months agoConvert kasp dnssectools tests to pytest
Matthijs Mekking [Fri, 14 Mar 2025 11:19:36 +0000 (12:19 +0100)] 
Convert kasp dnssectools tests to pytest

Convert the first couple of tests from 'kasp/tests.sh' to
'kasp/tests_kasp.py', those are test cases related to 'dnssec-keygen'
and 'dnssec-settime'.

For this, we also add a new KeyProperties method,
'policy_to_properties', that takes a list of strings which represent
the keys according to the dnssec-policy and the expected key states.

13 months agonew: ci: Add Fedora 42
Michal Nowak [Thu, 17 Apr 2025 08:04:07 +0000 (08:04 +0000)] 
new: ci: Add Fedora 42

Merge branch 'mnowak/fedora-42' into 'main'

See merge request isc-projects/bind9!10404

13 months agoAdd Fedora 42
Michal Nowak [Tue, 25 Mar 2025 09:11:59 +0000 (10:11 +0100)] 
Add Fedora 42

13 months agofix: test: Fix the isc_rwlock_tryupgrade() function's unit test
Arаm Sаrgsyаn [Wed, 16 Apr 2025 16:00:29 +0000 (16:00 +0000)] 
fix: test: Fix the isc_rwlock_tryupgrade() function's unit test

The pthread-based implementation of the isc_rwlock_tryupgrade()
function always returns ISC_R_LOCKBUSY. Fix the test by adding
conditional checks.

Closes #5287

Merge branch '5287-pthread-rwlock-tryupgrade-test-fix' into 'main'

See merge request isc-projects/bind9!10398

13 months agoFix the isc_rwlock_tryupgrade() function's unit test
Aram Sargsyan [Wed, 16 Apr 2025 12:56:18 +0000 (12:56 +0000)] 
Fix the isc_rwlock_tryupgrade() function's unit test

The pthread-based implementation of the isc_rwlock_tryupgrade()
function always returns ISC_R_LOCKBUSY. Fix the test by adding
conditional checks.

13 months agochg: ci: Remove allow_failure from cross-version-config-tests
Nicki Křížek [Wed, 16 Apr 2025 13:58:18 +0000 (13:58 +0000)] 
chg: ci: Remove allow_failure from cross-version-config-tests

v9.21.7 was released and the job now passes.

Merge branch 'nicki/ci-re-enable-cross-version-config-tests' into 'main'

See merge request isc-projects/bind9!10402

13 months agoRemove allow_failure from cross-version-config-tests
Nicki Křížek [Wed, 16 Apr 2025 13:25:03 +0000 (15:25 +0200)] 
Remove allow_failure from cross-version-config-tests

v9.21.7 was released and the job now passes.

13 months agoMerge tag 'v9.21.7'
Nicki Křížek [Wed, 16 Apr 2025 13:23:14 +0000 (15:23 +0200)] 
Merge tag 'v9.21.7'

13 months agofix: dev: Move the call_rcu_thread explicit create and shutdown to isc_loop
Ondřej Surý [Wed, 16 Apr 2025 12:26:52 +0000 (12:26 +0000)] 
fix: dev: Move the call_rcu_thread explicit create and shutdown to isc_loop

When isc__thread_initialize() is called from a library constructor, it
could be called before we fork the main process.  This happens with
named, and then we have the call_rcu_thread attached to the pre-fork
process and not the post-fork process, which means that the initial
process will never shutdown, because there's noone to tell it so.

Move the isc__thread_initialize() and isc__thread_shutdown() to the
isc_loop unit where we call it before creating the extra thread and
after joining all the extra threads respectively.

Closes #5281

Merge branch '5281-move-call_rcu-thread-ctor-dtor-to-main-thread' into 'main'

See merge request isc-projects/bind9!10394

13 months agoMove the call_rcu_thread explicit create and shutdown to isc_loop
Ondřej Surý [Tue, 15 Apr 2025 21:04:14 +0000 (23:04 +0200)] 
Move the call_rcu_thread explicit create and shutdown to isc_loop

When isc__thread_initialize() is called from a library constructor, it
could be called before we fork the main process.  This happens with
named, and then we have the call_rcu_thread attached to the pre-fork
process and not the post-fork process, which means that the initial
process will never shutdown, because there's noone to tell it so.

Move the isc__thread_initialize() and isc__thread_shutdown() to the
isc_loop unit where we call it before creating the extra thread and
after joining all the extra threads respectively.

13 months agochg: dev: Reduce QPDB_VIRTUAL to 10 seconds
Ondřej Surý [Wed, 16 Apr 2025 10:19:50 +0000 (10:19 +0000)] 
chg: dev: Reduce QPDB_VIRTUAL to 10 seconds

The QPDB_VIRTUAL value was introduced to allow the clients (presumably
ns_clients) that has been running for some time to access the cached
data that was valid at the time of its inception.  The default value
of 5 minutes is way longer than longevity of the ns_client object as
the resolver will give up after 2 minutes.

Reduce the value to 10 seconds to accomodate to honour the original
more closely, but still allow some leeway for clients that started some
time in the past.

Our measurements show that even setting this value to 0 has no
statistically significant effect, thus the value of 10 seconds should be
on the safe side.

Merge branch 'ondrej/reduce-QPDB_VIRTUAL' into 'main'

See merge request isc-projects/bind9!10309

13 months agoReduce QPDB_VIRTUAL to 10 seconds
Ondřej Surý [Fri, 21 Mar 2025 05:17:55 +0000 (06:17 +0100)] 
Reduce QPDB_VIRTUAL to 10 seconds

The *DB_VIRTUAL value was introduced to allow the clients (presumably
ns_clients) that has been running for some time to access the cached
data that was valid at the time of its inception.  The default value
of 5 minutes is way longer than longevity of the ns_client object as
the resolver will give up after 2 minutes.

Reduce the value to 10 seconds to accomodate to honour the original
more closely, but still allow some leeway for clients that started some
time in the past.

Our measurements show that even setting this value to 0 has no
statistically significant effect, thus the value of 10 seconds should be
on the safe side.

13 months agochg: pkg: Use jinja2 templates in system tests
Nicki Křížek [Tue, 15 Apr 2025 15:28:39 +0000 (15:28 +0000)] 
chg: pkg: Use jinja2 templates in system tests

`python-jinja2` is now required to run system tests.

Related #4938

Merge branch 'nicki/replace-setup-sh-files-with-jinja2-templates' into 'main'

See merge request isc-projects/bind9!9588

13 months agoRequire python-jinja2 for system tests
Nicki Křížek [Tue, 15 Apr 2025 12:16:08 +0000 (14:16 +0200)] 
Require python-jinja2 for system tests

Many of the system tests now use jinja2 template engine. Adding jinja2
as a hard dependency is preferable than potentially silently skipping
many system tests.

13 months agoReplace selected setup.sh system test files
Nicki Křížek [Fri, 4 Oct 2024 14:44:13 +0000 (16:44 +0200)] 
Replace selected setup.sh system test files

These setup.sh scripts only do templating and copying files. Both of
these can be replaced with either jinja templates, or using plain files.
Since each test invocation creates its own temporary directory, copying
files to ensure a "clean" state is no longer necessary.

In cases where named writes some content to the files, a jinja template
can be used instead of a plain file to avoid an artifact check which
would detect a change to a git-tracked file.

13 months agoReplace the trivial setup.sh system test files
Nicki Křížek [Tue, 1 Oct 2024 13:13:06 +0000 (15:13 +0200)] 
Replace the trivial setup.sh system test files

All these setup files only use copy_setports function which can be done
with jinja2 templates instead -- simply by renaming the .in files to
.j2, without any other changes. The pytest runner will render these
templates during test setup without any need for an additional script.

13 months agofix: usr: Return DNS COOKIE and NSID with BADVERS
Mark Andrews [Tue, 15 Apr 2025 03:11:01 +0000 (03:11 +0000)] 
fix: usr: Return DNS COOKIE and NSID with BADVERS

This change allows the client to identify the server that returns the
BADVERS and to provide a DNS SERVER COOKIE to be included in the
resend of the request.

Closes #5235

Merge branch '5235-return-the-server-cookie-when-returning-badvers' into 'main'

See merge request isc-projects/bind9!10334

13 months agoCheck DNS COOKIE, NSID and BADVERS
Mark Andrews [Fri, 28 Mar 2025 01:08:37 +0000 (12:08 +1100)] 
Check DNS COOKIE, NSID and BADVERS

DNS COOKIE and NSID should also be being processed when returning
BADVERS.  Check that this has actually occured by looking for the
cookie and nsid in the response.

13 months agoExtract and send server cookie with BADVERS retry
Mark Andrews [Thu, 27 Mar 2025 05:37:02 +0000 (16:37 +1100)] 
Extract and send server cookie with BADVERS retry

A BADVERS response can also include EDNS SERVER COOKIE.  Extract
that from the OPT record and use it when resending the request.

13 months agoProcess NSID and DNS COOKIE options when returning BADVERS
Mark Andrews [Fri, 25 Oct 2024 03:43:03 +0000 (14:43 +1100)] 
Process NSID and DNS COOKIE options when returning BADVERS

This will help identify the broken server if we happen to break
EDNS version negotiation.  It will also help protect the client
from spoofed BADVERSION responses.

13 months agochg: doc: Add a note on pregenerating keys
Matthijs Mekking [Mon, 14 Apr 2025 15:01:49 +0000 (15:01 +0000)] 
chg: doc: Add a note on pregenerating keys

With `dnssec-policy` you can pregenerate keys and if they are eligible, rather than creating a new key, a key is selected from the pregenerated keys. A key is eligible if it is unused, i.e it has no key timing metadata set.

Merge branch 'matthijs-clarify-pregenerating-keys' into 'main'

See merge request isc-projects/bind9!10385

13 months agoAdd a note about pregenarating keys for key rolls
Matthijs Mekking [Fri, 11 Apr 2025 18:16:39 +0000 (13:16 -0500)] 
Add a note about pregenarating keys for key rolls

With dnssec-policy you can pregenerate keys and if they are eligible,
rather than creating a new key, a key is selected from the pregenerated
keys. A key is eligible if it is unused, i.e it has no key timing
metadata set.

13 months agofix: test: Fix check_pid() in runtime system test on FreeBSD
Michal Nowak [Mon, 14 Apr 2025 10:56:13 +0000 (10:56 +0000)] 
fix: test: Fix check_pid() in runtime system test on FreeBSD

The original check_pid() always returned 0 on FreeBSD, even if the
process was still running. This makes the "verifying that named checks
for conflicting named processes" check fail on FreeBSD with TSAN.

Merge branch 'mnowak/fix-runtime-pid-check' into 'main'

See merge request isc-projects/bind9!10373

13 months agoFix check_pid() in runtime system test on FreeBSD
Michal Nowak [Thu, 3 Apr 2025 11:38:03 +0000 (13:38 +0200)] 
Fix check_pid() in runtime system test on FreeBSD

The original check_pid() always returned 0 on FreeBSD, even if the
process was still running. This makes the "verifying that named checks
for conflicting named processes" check fail on FreeBSD with TSAN.

13 months agochg: test: Use isctest.asyncserver in the "forward" test
Michał Kępień [Fri, 11 Apr 2025 14:51:14 +0000 (14:51 +0000)] 
chg: test: Use isctest.asyncserver in the "forward" test

Replace the custom DNS servers used in the "forward" system test with new
code based on the isctest.asyncserver module.

For ans6, instead of configuring the responses to send at runtime, set
them up when the server is started.  Make sure the server supports
toggling response sending at runtime to enable simulating forwarder
timeouts as required by one of the checks.

For ans11, put most of the responses to be provided by that server into
a zone file, only retaining code modifying zone-based answers in the
form of a response handler, to improve code readability.  Use explicit
domain names instead of variables as that server only handles a single
domain and fixed strings improve readability in this case.  Make sure
the server supports toggling response sending at runtime to enable
simulating forwarder timeouts as required by one of the checks.

Migrate sendcmd() and its uses to the new way of sending control queries
to custom servers used in system tests.

Depends on !10339

Merge branch 'michal/forward-asyncserver' into 'main'

See merge request isc-projects/bind9!10340

13 months agoUse isctest.asyncserver in the "forward" test
Michał Kępień [Fri, 11 Apr 2025 14:18:50 +0000 (09:18 -0500)] 
Use isctest.asyncserver in the "forward" test

Replace the custom DNS servers used in the "forward" system test with
new code based on the isctest.asyncserver module.

For ans6, instead of configuring the responses to send at runtime, set
them up when the server is started.  Make sure the server supports
toggling response sending at runtime to enable simulating forwarder
timeouts as required by one of the checks.

For ans11, put most of the responses to be provided by that server into
a zone file, only retaining code modifying zone-based answers in the
form of a response handler, to improve code readability.  Use explicit
domain names instead of variables as that server only handles a single
domain and fixed strings improve readability in this case.  Make sure
the server supports toggling response sending at runtime to enable
simulating forwarder timeouts as required by one of the checks.

Migrate sendcmd() and its uses to the new way of sending control queries
to custom servers used in system tests.

13 months agonew: test: Add support for control commands to isctest.asyncserver
Michał Kępień [Fri, 11 Apr 2025 14:17:22 +0000 (14:17 +0000)] 
new: test: Add support for control commands to isctest.asyncserver

Some BIND 9 system tests need to dynamically change custom server
behavior at runtime.  Existing custom servers typically use a separate
TCP socket for listening to control commands, which mimics what `named`
does, but adds extra complexity to the custom server's networking code
for no gain (given the purpose at hand).  There is also no common way of
performing typical runtime actions (like toggling response dropping)
across all custom servers.

Instead of listening on a separate TCP socket in `asyncserver.py`, make
it detect DNS queries to a "magic" domain (`_control.`) on the same port
as the one it uses for receiving "production" DNS traffic.  This enables
query/response logging code to be reused for control traffic, clearly
denotes behavior changes in packet captures, facilitates implementing
commonly used features as reusable chunks of code (by making them "own"
distinct subdomains of the control domain), voids the need for separate
tools sending control commands, and enables using DNS facilities for
returning information to the user (e.g. RCODE for status codes, TXT
records for additional information, etc.).

Merge branch 'michal/asyncserver-control-commands' into 'main'

See merge request isc-projects/bind9!10339

13 months agoAdd control command for toggling response dropping
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Add control command for toggling response dropping

Implement a reusable control command that makes it possible to
dynamically disable/enable sending responses to clients.  This is a
typical use case for custom DNS servers employed in various BIND 9
system tests.

13 months agoImplement control query handling
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Implement control query handling

Some BIND 9 system tests need to dynamically change custom server
behavior at runtime.  Existing custom servers typically use a separate
TCP socket for listening to control commands, which mimics what named
does, but adds extra complexity to the custom server's networking code
for no gain (given the purpose at hand).  There is also no common way of
performing typical runtime actions (like toggling response dropping)
across all custom servers.

Instead of listening on a separate TCP socket in asyncserver.py, make it
detect DNS queries to a "magic" domain ("_control.") on the same port as
the one it uses for receiving "production" DNS traffic.  This enables
query/response logging code to be reused for control traffic, clearly
denotes behavior changes in packet captures, facilitates implementing
commonly used features as reusable chunks of code (by making them "own"
distinct subdomains of the control domain), voids the need for separate
tools sending control commands, and enables using DNS facilities for
returning information to the user (e.g. RCODE for status codes, TXT
records for additional information, etc.).

13 months agoAdd debug logs for response handler matching
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Add debug logs for response handler matching

With multiple and/or dynamically managed response handlers at play, it
becomes useful for debugging purposes to know which handler (if any) was
used for preparing each response sent by the server.  Add debug logs
providing that information.  Make class name the default string
representation of each response handler to prettify logs.

13 months agoMake response handler management more flexible
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Make response handler management more flexible

Extend AsyncDnsServer.install_response_handler() so that the provided
response handler can be inserted at the beginning of the handler list.
This enables installing a response handler that takes priority over all
previously installed handlers.

Add a new method, AsyncDnsServer.uninstall_response_handler(), which
enables removing a previously installed response handler.

Together, these two methods provide full control over the response
handler list at runtime.

13 months agoAvoid global namespace pollution
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Avoid global namespace pollution

Add a main() function to all custom servers based on isctest.asyncserver
and move server startup code there.  This prevents redefining variables
from outer scope in custom server code as it evolves.

13 months agoGracefully handle invalid queries
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Gracefully handle invalid queries

Prevent custom servers based on asyncserver.py from exiting prematurely
due to unhandled exceptions raised as a result of attempting to parse
invalid queries sent by clients.

13 months agoFix Python 3.6 StreamWriter compatibility issue
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Fix Python 3.6 StreamWriter compatibility issue

The StreamWriter.wait_closed() method was introduced in Python 3.7, so
attempting to use it with Python 3.6 raises an exception.  This has not
been noticed before because awaiting StreamWriter.wait_closed() is the
last action taken for each TCP connection and unhandled exceptions were
not causing the scripts based on AsyncServer to exit prematurely until
the previous commit.

As per Python documentation [1], awaiting StreamWriter.wait_closed()
after calling StreamWriter.close() is recommended, but not mandatory, so
try to use it if it is available, without taking any fallback action in
case it isn't.

[1] https://docs.python.org/3.13/library/asyncio-stream.html#asyncio.StreamWriter.close

13 months agoEnsure uncaught exceptions kill custom servers
Michał Kępień [Fri, 11 Apr 2025 14:14:57 +0000 (09:14 -0500)] 
Ensure uncaught exceptions kill custom servers

Uncaught exceptions raised by tasks running on event loops are not
handled by Python's default exception handler, so they do not cause
scripts to die immediately with a non-zero exit code.  Set up an
exception handler for AsyncServer code that makes any uncaught exception
the result of the Future that the top-level coroutine awaits.  This
ensures that any uncaught exceptions cause scripts based on AsyncServer
to immediately exit with an error, enabling the system test framework to
fail tests in which custom servers encounter unforeseen problems.

13 months agochg: test: Rewrite kasp system test to pytest (1)
Matthijs Mekking [Thu, 10 Apr 2025 21:17:49 +0000 (21:17 +0000)] 
chg: test: Rewrite kasp system test to pytest (1)

Move test code that can be reused for the kasp pytest-based system test.

Merge branch 'matthijs-pytest-rewrite-kasp-system-test-1' into 'main'

See merge request isc-projects/bind9!10252

13 months agoUpdate _check_dnskeys function
Matthijs Mekking [Mon, 24 Feb 2025 10:35:37 +0000 (11:35 +0100)] 
Update _check_dnskeys function

In the kasp system test there are cases that the SyncPublish is not
set, nor it is required to do so. Update the _check_dnskeys function
accordingly.

13 months agoAdd support for TSIG in isctest.kasp
Matthijs Mekking [Fri, 14 Mar 2025 10:19:40 +0000 (11:19 +0100)] 
Add support for TSIG in isctest.kasp

For some kasp test we are going to need TSIG based queries to
differentiate between views.

13 months agoIntroduce pytest check_next_key_event, get_keyids
Matthijs Mekking [Fri, 14 Mar 2025 10:10:22 +0000 (11:10 +0100)] 
Introduce pytest check_next_key_event, get_keyids

For the kasp tests we need a new utility that can retrieve a list of
Keys from a given directory, belonging to a specific zone. This is
'keydir_to_keylist' and is the replacement of 'kasp.sh:get_keyids()'.

'next_key_event_eqauls' is a method to check when the next key event is
scheduled, needed for the rollover tests, and is the equivalent of shell
script 'check_next_key_event'.

13 months agoIntroduce pytest verify_keys and check_keytimes
Matthijs Mekking [Fri, 14 Mar 2025 09:51:36 +0000 (10:51 +0100)] 
Introduce pytest verify_keys and check_keytimes

This commit introduces replacements for the 'check_keys' and
'check_keytimes' from the shell test library. 'check_keys' is renamed
to 'verify_keys' because it does not assert.

For that, we introduce more functions for the class Key. The
'match_properties' function is used in 'verify_keys' to see if a set of
KeyProperties match the Key. This speficially ignores timing metadata.
The function resembles what is in 'kasp.sh:check_key()'.

The 'match_timingmetadata' function is used in 'check_keytimes' to see
if the timing metadata of a set of KeyProperties match the Key. The
values are checked in all three key files (except if the private key is
not available (set with properties["private"]), or if it is a legacy key
(set with properties["legacy"]).

An additional check function is added, to check if the key relationships
are set correctly. It follows a similar pattern as 'check_keytimes'. If
"Predecessor" and/or "Successor" are expected to be set in the state
file, this function checks so, and also verifies that they are not set
if they should not be.

13 months agoUpdate class Key
Matthijs Mekking [Fri, 14 Mar 2025 09:38:43 +0000 (10:38 +0100)] 
Update class Key

Because we want to check the metadata in all three files, a new
value in the Key class is added: 'privatefile'. The 'get_metadata'
function is adapted so that we can also check metadata in other files.

Introduce methods to easily retrieve the TTL and public DNSKEY record
from the keyfile.

When checking if the CDS is equal to the expected value, use the DNSKEY
TTL instead of hardcoded 3600.

13 months agoIntroduce class KeyProperties
Matthijs Mekking [Fri, 14 Mar 2025 09:23:37 +0000 (10:23 +0100)] 
Introduce class KeyProperties

In isctest.kasp, introduce a new class 'KeyProperties' that can be used
to check if a Key matches expected properties. Properties are for the
time being divided in three parts: 'properties' that contain some
attributes of the expected properties (such as are we dealing with a
legacy key, is the private key available, and other things that do not
fit the metadata exactly), 'metadata' that contains expected metadata
(such as 'Algorithm', 'Lifetime', 'Length'), and 'timing', which is
metadata of the class KeyTimingMetadata.

The 'default()' method fills in the expected properties for the default
DNSSEC policy.

The 'set_expected_times()' sets the expected timing metadata, derived
from when the key was created. This method can take an offset to push
the expected timing metadata a duration in the future or back into the
past. If 'pregenerated=True', derive the expected timing metadata from
the 'Publish' metadata derived from the keyfile, rather than from the
'Created' metadata.

The calculations in the 'Ipub', 'IpubC' and 'Iret' methods are derived
from RFC 7583 DNSSEC Key Rollover Timing Considerations.

13 months agoMove test code that can be reused to isctest
Matthijs Mekking [Thu, 13 Mar 2025 14:46:39 +0000 (15:46 +0100)] 
Move test code that can be reused to isctest

This is the first step of converting the kasp system test to pytest.
Well, perhaps not the first, because earlier the ksr system test was
already converted to pytest and then the `isctest/kasp.py` library
was already introduced. Lots of this code can be reused for the kasp
pytest code.

First of all, 'check_file_contents_equal' is moved out of the ksr test
and into the 'check' library. This feels the most appropriate place
for this function to be reused in other tests. Then, 'keystr_to_keylist'
is moved to the 'kasp' library.

Introduce two new methods that are unused in this point of time, but
we are going to need them for the kasp system test. 'zone_contains'
will be used to check if a signature exists in the zonefile. This way
we can tell whether the signature has been reused or refreshed.
'file_contents_contain' will be used to check if the comment and public
DNSKEY record in the keyfile is correct.

14 months agochg: doc: Set up version for BIND 9.21.8
Nicki Křížek [Thu, 10 Apr 2025 13:32:31 +0000 (13:32 +0000)] 
chg: doc: Set up version for BIND 9.21.8

Merge branch 'nicki/set-up-version-for-bind-9.21.8' into 'main'

See merge request isc-projects/bind9!10378

14 months agoUpdate BIND version to 9.21.8-dev
Nicki Křížek [Thu, 10 Apr 2025 13:21:13 +0000 (15:21 +0200)] 
Update BIND version to 9.21.8-dev

14 months agofix: usr: `check_private` failed to account for the length byte before the OID
Mark Andrews [Wed, 9 Apr 2025 20:05:54 +0000 (20:05 +0000)] 
fix: usr: `check_private` failed to account for the length byte before the OID

In PRIVATEOID keys, the key data begins with a length byte followed
by an ASN.1 object identifier that indicates the cryptographic algorithm
to use. Previously, the length byte was not accounted for when
checking the contents of keys and signatures, which could have led
to interoperability problems with any zones signed using PRIVATEOID.
This has been fixed.

Closes #5270

Merge branch '5270-fix-check-private' into 'main'

See merge request isc-projects/bind9!10372

14 months agoUpdate BIND version for release v9.21.7
Nicki Křížek [Wed, 9 Apr 2025 14:18:20 +0000 (16:18 +0200)] 
Update BIND version for release

14 months agonew: doc: Prepare documentation for BIND 9.21.7
Nicki Křížek [Wed, 9 Apr 2025 14:04:01 +0000 (14:04 +0000)] 
new: doc: Prepare documentation for BIND 9.21.7

Merge branch 'nicki/prepare-documentation-for-bind-9.21.7' into 'v9.21.7-release'

See merge request isc-private/bind9!789

14 months agoTweak and reword release notes
Nicki Křížek [Thu, 3 Apr 2025 13:36:08 +0000 (15:36 +0200)] 
Tweak and reword release notes

14 months agoFix rndc reset-stats documentation
Nicki Křížek [Thu, 3 Apr 2025 13:30:31 +0000 (15:30 +0200)] 
Fix rndc reset-stats documentation

Reformat the section to be more consistent with the rest of the rndc
documentation and avoid using :program: directive which would needlessly
break rst links.

14 months agoAdd missing commands to rndc --help
Nicki Křížek [Thu, 3 Apr 2025 12:59:07 +0000 (14:59 +0200)] 
Add missing commands to rndc --help

14 months agoFix OID check for PRIVATEOID keys and signatures
Mark Andrews [Thu, 3 Apr 2025 01:49:39 +0000 (12:49 +1100)] 
Fix OID check for PRIVATEOID keys and signatures

We were failing to account for the length byte before the OID.
See RFC 4034.

   Algorithm number 254 is reserved for private use and will never be
   assigned to a specific algorithm.  The public key area in the DNSKEY
   RR and the signature area in the RRSIG RR begin with an unsigned
   length byte followed by a BER encoded Object Identifier (ISO OID) of
   that length.  The OID indicates the private algorithm in use, and the
   remainder of the area is whatever is required by that algorithm.
   Entities should only use OIDs they control to designate their private
   algorithms.

14 months agoPrepare release notes for BIND 9.21.7
Nicki Křížek [Thu, 3 Apr 2025 11:11:46 +0000 (13:11 +0200)] 
Prepare release notes for BIND 9.21.7

14 months agoGenerate changelog for BIND 9.21.7
Nicki Křížek [Thu, 3 Apr 2025 11:10:36 +0000 (13:10 +0200)] 
Generate changelog for BIND 9.21.7

14 months agofix: usr: Stop caching lack of EDNS support
Nicki Křížek [Thu, 3 Apr 2025 10:51:47 +0000 (10:51 +0000)] 
fix: usr: Stop caching lack of EDNS support

`named` could falsely learn that a server doesn't support EDNS when
a spoofed response was received; that subsequently prevented DNSSEC
lookups from being made.  This has been fixed.

Closes https://gitlab.isc.org/isc-projects/bind9/-/issues/3949

Closes https://gitlab.isc.org/isc-projects/bind9/-/issues/5066

Merge branch '5066-stop-caching-lack-of-edns-support' into 'v9.21.7-release'

See merge request isc-private/bind9!776

14 months agoDon't cache lack of EDNS based on received responses
Mark Andrews [Thu, 16 Jan 2025 05:24:05 +0000 (16:24 +1100)] 
Don't cache lack of EDNS based on received responses

Caching prevents server upgrades being detected in a timely manner
and it can also prevent DNSSEC responses being requested.

14 months agofix: usr: Nested DNS validation could cause assertion failure
Ondřej Surý [Wed, 2 Apr 2025 16:41:57 +0000 (16:41 +0000)] 
fix: usr: Nested DNS validation could cause assertion failure

When multiple nested DNS validations were destroyed out of order,
the EDE context could be freed before all EDE codes were copied,
which could cause an assertion failure. This has been fixed.

Closes #5213

Merge branch '5213-use-dns_ede_copy-in-dns_validator' into 'main'

See merge request isc-projects/bind9!10365

14 months agoDon't copy EDE codes if source is same as destination
Ondřej Surý [Wed, 2 Apr 2025 16:06:52 +0000 (18:06 +0200)] 
Don't copy EDE codes if source is same as destination

If the nested DNS validator ends up in the same fetch because of the
loops, the code could be copying the EDE codes from the same source EDE
context as the destination EDE context.  Skip copying the EDE codes if
the source and the destination is the same.

14 months agoDon't pass edectx from fetch_and_forget
Ondřej Surý [Wed, 2 Apr 2025 15:38:31 +0000 (17:38 +0200)] 
Don't pass edectx from fetch_and_forget

Pass NULL as edectx for the fetch_and_forget() fetches as nobody
is reading the EDE contexts and it can mess the main client buffer.

14 months agoAdd static ede context into each validator layer
Ondřej Surý [Wed, 2 Apr 2025 14:31:54 +0000 (16:31 +0200)] 
Add static ede context into each validator layer

Instead of passing the edectx from the fetchctx into all subvalidators,
make the ede context ownership explict for dns_resolver_createfetch()
callers, and copy the ede result codes from the children validators to
the parent when finishing the validation process.

14 months agochg: dev: Remove zero initialization of large buffers
Alessio Podda [Wed, 2 Apr 2025 15:00:34 +0000 (15:00 +0000)] 
chg: dev: Remove zero initialization of large buffers

Profiles show that an high amount of CPU time spent in memset.
By removing zero initalization of certain large buffers we improve
performance in certain authoritative workloads.

Closes #5159

Merge branch '5159-do-not-zero-qp-search-buffers' into 'main'

See merge request isc-projects/bind9!10058

14 months agoRemove zero initialization of large buffers
alessio [Thu, 30 Jan 2025 11:33:48 +0000 (12:33 +0100)] 
Remove zero initialization of large buffers

Profiles show that an high amount of CPU time spent in memset.
By removing zero initalization of certain large buffers we improve
performance in certain authoritative workloads.

14 months agochg: ci: Update issue closing regex in dangerfile.py
Andoni Duarte [Wed, 2 Apr 2025 13:38:40 +0000 (13:38 +0000)] 
chg: ci: Update issue closing regex in dangerfile.py

Update issue regex in danger file

The regular expression in `dangerfile.py` has been updated to match
the one in GitLab and bind9-qa (isc-projects/bind9-qa!41), i.e.
https://docs.gitlab.com/user/project/issues/managing_issues/#default-closing-pattern.

Merge branch 'andoni/update-issue-regex-in-danger-file' into 'main'

See merge request isc-projects/bind9!10361

14 months agoUpdate issue closing regex in dangerfile.py
Andoni Duarte Pintado [Wed, 2 Apr 2025 12:14:36 +0000 (14:14 +0200)] 
Update issue closing regex in dangerfile.py

Update the regular expression used for extracting references to GitLab
issues closed by a given merge request so that it is identical to the
one used by GitLab [1].

See also isc-projects/bind9-qa!41

[1] https://docs.gitlab.com/user/project/issues/managing_issues/#default-closing-pattern

14 months agochg: nil: Suppress FreeBSD-specific TSAN false-positive lock-order-inversion
Arаm Sаrgsyаn [Wed, 2 Apr 2025 12:33:00 +0000 (12:33 +0000)] 
chg: nil: Suppress FreeBSD-specific TSAN false-positive lock-order-inversion

TSAN reports a lock-order-inversion (potential deadlock) issue in
`add_trace_entry()`.

While it is true that in one case a lock in the `isc_mem_t` structure is
locked first, and then a lock in the `FILE` structure is locked second,
and in the the second case it is the other way around, this isn't an
issue, because those are `FILE` structures for totally different files,
used in different parts of the code.

Closes #5266

Merge branch '5266-freebsd-suppress-tsan-lock-order-inversion-false-positive' into 'main'

See merge request isc-projects/bind9!10355

14 months agoSuppress FreeBSD-specific TSAN false-positive lock-order-inversion
Aram Sargsyan [Wed, 2 Apr 2025 08:38:58 +0000 (08:38 +0000)] 
Suppress FreeBSD-specific TSAN false-positive lock-order-inversion

TSAN reports a lock-order-inversion (potential deadlock) issue in
add_trace_entry():

    WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock)
      Cycle in lock order graph: M0001 (0x000000000001) => M0002 (0x000000000002) => M0001
      Mutex M0002 acquired here while holding mutex M0001 in main thread:
        #0 _pthread_mutex_lock /usr/src/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1342:3
        #1 add_trace_entry lib/isc/mem.c:210:2
        #2 isc__mem_get lib/isc/mem.c:606:2
        #3 isc_buffer_allocate lib/isc/./include/isc/buffer.h:1080:23
        #4 pushandgrow lib/isc/lex.c:321:3
        #5 isc_lex_gettoken lib/isc/lex.c:445:22
        #6 cfg_gettoken lib/isccfg/parser.c:3490:11
        #7 cfg_parse_mapbody lib/isccfg/parser.c:2230:3
        #8 cfg_parse_obj lib/isccfg/parser.c:247:11
        #9 parse2 lib/isccfg/parser.c:628:11
        #10 cfg_parse_file lib/isccfg/parser.c:668:11
        #11 load_configuration bin/named/server.c:8069:13
        #12 run_server bin/named/server.c:9518:2
        #13 isc__async_cb lib/isc/async.c:110:3
        #14 uv__async_io /tmp/libuv-1.50.0/src/unix/async.c:208:5
        #15 uv__io_poll /tmp/libuv-1.50.0/src/unix/kqueue.c:369:9
        #16 uv_run /tmp/libuv-1.50.0/src/unix/core.c:460:5
        #17 loop_thread lib/isc/loop.c:327:6
        #18 thread_body lib/isc/thread.c:89:8
        #19 isc_thread_main lib/isc/thread.c:124:2
        #20 isc_loopmgr_run lib/isc/loop.c:513:2
        #21 main bin/named/main.c:1469:2
      Mutex M0001 previously acquired by the same thread here:
        #0 _pthread_mutex_lock /usr/src/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1342:3
        #1 _flockfile /usr/src/lib/libc/stdio/_flock_stub.c:72:3
        #2 cfg_gettoken lib/isccfg/parser.c:3490:11
        #3 cfg_parse_mapbody lib/isccfg/parser.c:2230:3
        #4 cfg_parse_obj lib/isccfg/parser.c:247:11
        #5 parse2 lib/isccfg/parser.c:628:11
        #6 cfg_parse_file lib/isccfg/parser.c:668:11
        #7 load_configuration bin/named/server.c:8069:13
        #8 run_server bin/named/server.c:9518:2
        #9 isc__async_cb lib/isc/async.c:110:3
        #10 uv__async_io /tmp/libuv-1.50.0/src/unix/async.c:208:5
        #11 uv__io_poll /tmp/libuv-1.50.0/src/unix/kqueue.c:369:9
        #12 uv_run /tmp/libuv-1.50.0/src/unix/core.c:460:5
        #13 loop_thread lib/isc/loop.c:327:6
        #14 thread_body lib/isc/thread.c:89:8
        #15 isc_thread_main lib/isc/thread.c:124:2
        #16 isc_loopmgr_run lib/isc/loop.c:513:2
        #17 main bin/named/main.c:1469:2
      Mutex M0001 acquired here while holding mutex M0002 in main thread:
        #0 _pthread_mutex_lock /usr/src/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1342:3
        #1 _flockfile /usr/src/lib/libc/stdio/_flock_stub.c:72:3
        #2 print_active lib/isc/mem.c:629:3
        #3 isc_mem_stats lib/isc/mem.c:694:2
        #4 main bin/named/main.c:1498:4
      Mutex M0002 previously acquired by the same thread here:
        #0 _pthread_mutex_lock /usr/src/contrib/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1342:3
        #1 isc_mem_stats lib/isc/mem.c:668:2
        #2 main bin/named/main.c:1498:4
    SUMMARY: ThreadSanitizer: lock-order-inversion (potential deadlock) lib/isc/mem.c:210:2 in add_trace_entry

In the first stack frame ('M0001'->'M0002' lock order) cfg_gettoken()
uses flockfile() to lock 'M0001' for the 'FILE' object associated with
the configuration file (e.g. the configuration file itself and
whatever it includes, like a zone database), then it locks a memory
context mutex M0002.

In the other stack frmae ('M0002'->'M0001' lock order) isc_mem_stats()
locks a memory context mutex M0002, then it uses fprintf(), which
internally locks a 'M0001' mutex with flockfile() to write into the
'named.memstats' memory statistics file.

While it is true that in one case a lock in the 'isc_mem_t' structure is
locked first, and then a lock in the 'FILE' structure is locked second,
and in the the second case it is the other way around, this isn't an
issue, because those are 'FILE' structures for totally different files,
used in different parts of the code.

It was also manually confirmed that 'named.memstats' doesn't get
processed by cfg_gettoken(), and is used only in the second stack
frame's code flow when named is exiting.

14 months agonew: ci: Allow pushing branches and tags to customer git repos
Nicki Křížek [Wed, 2 Apr 2025 11:03:30 +0000 (11:03 +0000)] 
new: ci: Allow pushing branches and tags to customer git repos

For pipelines in the private repository, add an optional manual job,
which allows the current branch to be pushed into the specified
customer's git repository. This can be useful to provide patch previews
for early testing.

For tags created in a private repository, add a manual job which pushes
the created tag to all entitled customers.

Merge branch 'nicki/ci-customer-git-automation' into 'main'

See merge request isc-projects/bind9!10323

14 months agoAllow pushing branches and tags to customer git repos
Nicki Křížek [Tue, 25 Mar 2025 15:51:24 +0000 (16:51 +0100)] 
Allow pushing branches and tags to customer git repos

For pipelines in the private repository, add an optional manual job,
which allows the current branch to be pushed into the specified
customer's git repository. This can be useful to provide patch previews
for early testing.

For tags created in a private repository, add a manual job which pushes
the created tag to all entitled customers.

14 months agochg: nil: Suppress FreeBSD-specific TSAN false-positive data race
Arаm Sаrgsyаn [Wed, 2 Apr 2025 08:35:04 +0000 (08:35 +0000)] 
chg: nil: Suppress FreeBSD-specific TSAN false-positive data race

TSAN reports a data race in FreeBSD's memset(), called by its
__crt_calloc() memory allocation function. There is a very similar
bug report [1] in FreeBSD bug tracker, and an existing code-review [2]
that tries to address an issue, the description of which is very
similar to what we are seeing.

Suppress this report by adding its signature to '.tsan-suppress'.

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282794

[2] https://reviews.freebsd.org/D28536?id=86694

Closes #5267

Merge branch '5267-freebsd-suppress-tsan-data-race-false-positive' into 'main'

See merge request isc-projects/bind9!10353

14 months agoSuppress FreeBSD-specific TSAN false-positive data race
Aram Sargsyan [Tue, 1 Apr 2025 13:36:33 +0000 (13:36 +0000)] 
Suppress FreeBSD-specific TSAN false-positive data race

TSAN reports a data race in FreeBSD's memset(), called by its
__crt_calloc() memory allocation function. There is a very similar
bug report [1] in FreeBSD bug tracker, and an existing code-review [2]
that tries to address an issue, the description of which is very
similar to what we are seeing.

Suppress this report by adding its signature to '.tsan-suppress'.

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282794
[2] https://reviews.freebsd.org/D28536?id=86694

14 months agofix: dev: Switch to ISC_LIST_FOREACH everywhere
Evan Hunt [Mon, 31 Mar 2025 21:21:06 +0000 (21:21 +0000)] 
fix: dev: Switch to ISC_LIST_FOREACH everywhere

The pattern `for (x = ISC_LIST_HEAD(...); x != NULL; ISC_LIST_NEXT(...)` has been changed to `ISC_LIST_FOREACH` throughout BIND, except in a few
cases where the change would be excessively complex.

In most cases this was a straightforward change. In some places, however, the list element variable was referenced after the loop ended. Where possible, code has now been refactored to avoid this necessity.

`ISC_LIST_FOREACH` has also been modified to use `typeof(list.head)` to declare list elements automatically. When the list object to be iterated is declared with a `const` qualifier, the qualifier is passed along to the element declaration, causing a compilation failure. To avoid this problem, some `const` qualifiers have been removed; where that was not possible, `UNCONST` was used.

Merge branch 'each-isc-list-foreach' into 'main'

See merge request isc-projects/bind9!10310

14 months agouse ISC_LIST_FOREACH in more places
Evan Hunt [Sat, 22 Mar 2025 22:26:16 +0000 (15:26 -0700)] 
use ISC_LIST_FOREACH in more places

use the ISC_LIST_FOREACH pattern in places where lists had
been iterated using a different pattern from the typical
`for` loop: for example, `while (!ISC_LIST_EMPTY(...))` or
`while ((e = ISC_LIST_HEAD(...)) != NULL)`.

14 months agoswitch to ISC_LIST_FOREACH everywhere
Evan Hunt [Fri, 21 Mar 2025 05:25:56 +0000 (22:25 -0700)] 
switch to ISC_LIST_FOREACH everywhere

the pattern `for (x = ISC_LIST_HEAD(...); x != NULL; ISC_LIST_NEXT(...)`
has been changed to `ISC_LIST_FOREACH` throughout BIND, except in a few
cases where the change would be excessively complex.

in most cases this was a straightforward change. in some places,
however, the list element variable was referenced after the loop
ended, and the code was refactored to avoid this necessity.

also, because `ISC_LIST_FOREACH` uses typeof(list.head) to declare
the list elements, compilation failures can occur if the list object
has a `const` qualifier.  some `const` qualifiers have been removed
from function parameters to avoid this problem, and where that was not
possible, `UNCONST` was used.

14 months agoimplicitly declare list elements in ISC_LIST_FOREACH macros
Evan Hunt [Thu, 20 Mar 2025 22:46:35 +0000 (15:46 -0700)] 
implicitly declare list elements in ISC_LIST_FOREACH macros

ISC_LIST_FOREACH and related macros now use 'typeof(list.head)' to
declare the list elements automatically; the caller no longer needs
to do so.

ISC_LIST_FOREACH_SAFE also now implicitly declares its own 'next'
pointer, so it only needs three parameters instead of four.

14 months agorem: dev: Cleanup dead code: CID 548247
Mark Andrews [Mon, 31 Mar 2025 20:17:57 +0000 (20:17 +0000)] 
rem: dev:  Cleanup dead code: CID 548247

Clean up dead code following merge of !10302.

Closes #5262

Merge branch '5262-cleanup-dead-code-cid-548247' into 'main'

See merge request isc-projects/bind9!10346

14 months agoRemove dead code in dns_message_sectiontotext
Mark Andrews [Sun, 30 Mar 2025 23:36:45 +0000 (10:36 +1100)] 
Remove dead code in dns_message_sectiontotext

Following the merge of !10302 this code to reset the result code
on ISC_R_NOMORE is no longer needed.

14 months agorem: usr: Drop readline alternatives in favor of libedit
Ondřej Surý [Mon, 31 Mar 2025 14:02:59 +0000 (14:02 +0000)] 
rem: usr: Drop readline alternatives in favor of libedit

Libedit is now ubiquitous and has a license compatible with
MPL 2.0. We are now dropping readline (GPL 3.0) and editline (obsolete) support
in favor of libedit.

Merge branch 'ondrej/cleanup-various-readline-libraries' into 'main'

See merge request isc-projects/bind9!10202

14 months agoDrop readline alternatives in favor of libedit
Ondřej Surý [Mon, 3 Mar 2025 11:32:14 +0000 (12:32 +0100)] 
Drop readline alternatives in favor of libedit

The libedit is now ubiquitous and has a licences compatible with
MPL 2.0.  Drop readline (GPL 3.0) and editline (obsolete) support
in favor of libedit.

14 months agochg: dev: Carefully check if the server name used for SNI is a hostname
Artem Boldariev [Mon, 31 Mar 2025 11:57:49 +0000 (11:57 +0000)] 
chg: dev: Carefully check if the server name used for SNI is a hostname

Previously the code would not check if the string intended to be used
for SNI is a hostname.

See also: !9923

Closes #5225

Merge branch '5225-dig-sni-fix' into 'main'

See merge request isc-projects/bind9!10254

14 months agoDispatch: carefully check if the server name for SNI is a hostname
Artem Boldariev [Tue, 18 Mar 2025 10:52:18 +0000 (12:52 +0200)] 
Dispatch: carefully check if the server name for SNI is a hostname

Previously the code would not check if the string intended to be used
for SNI is a hostname.

14 months agoDig: carefully check if the server name for SNI is a hostname
Artem Boldariev [Fri, 14 Mar 2025 19:35:39 +0000 (21:35 +0200)] 
Dig: carefully check if the server name for SNI is a hostname

Previously the code would not check if the string intended to be used
for SNI is a hostname.

14 months agoAdd isc_tls_valid_sni_hostname()
Artem Boldariev [Fri, 28 Mar 2025 07:20:16 +0000 (09:20 +0200)] 
Add isc_tls_valid_sni_hostname()

Add a function that checks if a 'hostname' is not a valid IPv4 or IPv6
address. Returns 'true' if the hostname is likely a domain name, and
'false' if it represents an IP address.

14 months agofix: test: fix out-of-tree mem_test
Colin Vidal [Fri, 28 Mar 2025 14:51:59 +0000 (14:51 +0000)] 
fix: test: fix out-of-tree mem_test

Previously changed mem_test (!10320) introduces a test which checks for
the value of `__FILE__`, which is different if the build is done
out-of-tree or not, even though this is not relevant for the test (only
the base filename is). This result in a broken test for out-of-tree
builds. Fix this by changing the way the "grep" is done in the test,
ignoring the optional path prefix in the filename.

Merge branch 'colin-fix-outoftree-memtest' into 'main'

See merge request isc-projects/bind9!10343

14 months agofix out-of-tree mem_test
Colin Vidal [Fri, 28 Mar 2025 11:55:49 +0000 (12:55 +0100)] 
fix out-of-tree mem_test

Previously changed mem_test (!10320) introduces a test which checks for
the value of `__FILE__`, which is different if the build is done
out-of-tree or not, even though this is not relevant for the test (only
the base filename is). This result in a broken test for out-of-tree
builds. Fix this by changing the way the "grep" is done in the test,
ignoring the optional path prefix in the filename.

14 months agofix: nil: Fix out-of-tree test
Evan Hunt [Fri, 28 Mar 2025 04:03:42 +0000 (04:03 +0000)] 
fix: nil: Fix out-of-tree test

A recent change to the dnssec system test depended on a file
that is only in the source tree, not in the build tree, and was
therefore not available in out-of-tree builds.

Merge branch 'each-fix-dnssec-oot' into 'main'

See merge request isc-projects/bind9!10342

14 months agoFix out-of-tree test
Evan Hunt [Fri, 28 Mar 2025 02:59:53 +0000 (19:59 -0700)] 
Fix out-of-tree test

A recent change to the dnssec system test depended on a file
that is only in the source tree, not in the build tree, and was
therefore not available in out-of-tree builds.

14 months agorem: pkg: Implement the systemd notification protocol manually to remove dependency...
Aydın Mercan [Thu, 27 Mar 2025 19:54:49 +0000 (19:54 +0000)] 
rem: pkg: Implement the systemd notification protocol manually to remove dependency on libsystemd.

Merge branch 'aydin/standalone-notification' into 'main'

See merge request isc-projects/bind9!10263

14 months agoimplement the systemd notification protocol manually, drop libsystemd
Aydın Mercan [Sun, 16 Mar 2025 16:54:18 +0000 (19:54 +0300)] 
implement the systemd notification protocol manually, drop libsystemd

libsystemd, despite being useful, adds a huge surface area for just
using the sd_notify API. libsystemd's surface has been exploited in the
past [1].

Implement the systemd notification protocol by hand since it is just
sending newline-delimited datagrams to a UNIX socket. The code shouldn't
need more attention in the future since the notification protocol is
covered under systemd's stability promise [2].

We don't need to support VSOCK-backed service notifications since they
are only intended for virtual machine inits.

[1]: https://www.openwall.com/lists/oss-security/2024/03/29/4
[2]: https://systemd.io/PORTABILITY_AND_STABILITY/

14 months agofix: dev: copy __FILE__ when allocating memory
Colin Vidal [Thu, 27 Mar 2025 12:15:24 +0000 (12:15 +0000)] 
fix: dev: copy __FILE__ when allocating memory

When allocating memory under -m trace|record, the __FILE__ pointer is
stored, so it can be printed out later in order to figure out in which
file an allocation leaked. (among others, like the line number).

However named crashes when called with -m record and using a plugin
leaking memory. The reason is that plugins are unloaded earlier than
when the leaked allocations are dumped (obviously, as it's done as late
as possible). In such circumstances, `__FILE__` is dangling because the
dynamically loaded library (the plugin) is not in memory anymore.

Fix the crash by systematically copying the `__FILE__` string
instead of copying the pointer. Of course, this make each allocation to
consume a bit more memory (and longer, as it needs to calculate the
length of `__FILE__`) but this occurs only under -m trace|record debugging
flags.

Merge branch 'colin-memdump-plugins' into 'main'

See merge request isc-projects/bind9!10320

14 months agocopy __FILE__ when allocating memory
Colin Vidal [Tue, 25 Mar 2025 13:35:49 +0000 (14:35 +0100)] 
copy __FILE__ when allocating memory

When allocating memory under -m trace|record, the __FILE__ pointer is
stored, so it can be printed out later in order to figure out in which
file an allocation leaked. (among others, like the line number).

However named crashes when called with -m record and using a plugin
leaking memory. The reason is that plugins are unloaded earlier than
when the leaked allocations are dumped (obviously, as it's done as late
as possible). In such circumstances, __FILE__ is dangling because the
dynamically loaded library (the plugin) is not in memory anymore.

Fix the crash by systematically copying the __FILE__ string
instead of copying the pointer. Of course, this make each allocation to
consume a bit more memory (and longer, as it needs to calculate the
length of __FILE__) but this occurs only under -m trace|record debugging
flags.

In term of unit test, because grepping in C is not fun, and because the
whole "syntax" of the dump output is tested in other tests, this simply
search for a substring in the whole buffer to make sure the expected
allocations are found.

14 months agonew: usr: Add an rndc command to reset some statistics counters
Arаm Sаrgsyаn [Thu, 27 Mar 2025 09:35:14 +0000 (09:35 +0000)] 
new: usr: Add an rndc command to reset some statistics counters

The new ``reset-stats`` command for ``rndc`` allows some statistics
counters to be reset during runtime. At the moment only two "high-water"
counters are supported, so the ability to reset them after the
initial peaks during the server's "warm-up" phase may be useful for
some operators.

Closes #5251

Merge branch '5251-feature-rndc-reset-high-water-statistics' into 'main'

See merge request isc-projects/bind9!10318