]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
2 years agoImprove the rcu_barrier() call when destroying the mem context
Ondřej Surý [Wed, 7 Feb 2024 08:23:50 +0000 (09:23 +0100)] 
Improve the rcu_barrier() call when destroying the mem context

Instead of crude 5x rcu_barrier() call in the isc__mem_destroy(), change
the mechanism to call rcu_barrier() until the memory use and references
stops decreasing.  This should deal with any number of nested call_rcu()
levels.

Additionally, don't destroy the contextslock if the list of the contexts
isn't empty.  Destroying the lock could make the late threads crash.

2 years agoUse _exit() in the fatal() function
Ondřej Surý [Wed, 7 Feb 2024 13:44:39 +0000 (14:44 +0100)] 
Use _exit() in the fatal() function

Since the fatal() isn't a correct but rather abrupt termination of the
program, we want to skip the various atexit() calls because not all
memory might be freed during fatal() call, etc.  Using _exit() instead
of exit() has this effect - the program will end, but no destructors or
atexit routines will be called.

2 years agoMerge branch 'ondrej/use-error-checking-mutex-on-linux' into 'main'
Ondřej Surý [Wed, 7 Feb 2024 21:55:31 +0000 (21:55 +0000)] 
Merge branch 'ondrej/use-error-checking-mutex-on-linux' into 'main'

Always use adaptive mutexes on Linux and use error checking mutexes in developer mode

See merge request isc-projects/bind9!8693

2 years agoUse error checking mutex in developer mode on Linux
Ondřej Surý [Mon, 5 Feb 2024 08:03:41 +0000 (09:03 +0100)] 
Use error checking mutex in developer mode on Linux

When developer mode is enabled, use error checking mutex type, so we can
discover wrong use of mutexes faster.

2 years agoAlways use adaptive mutexes on Linux
Ondřej Surý [Mon, 5 Feb 2024 07:57:23 +0000 (08:57 +0100)] 
Always use adaptive mutexes on Linux

When adaptive mutexes are available (with glibc), always use them.
Remove the autoconf switch and also fix the static initializer.

2 years agoRemove unused mutex from netmgr
Ondřej Surý [Mon, 5 Feb 2024 07:52:35 +0000 (08:52 +0100)] 
Remove unused mutex from netmgr

The netmgr->lock was dead code, remove it.

2 years agoMerge branch '4519-check-return-value-of-snprintf-in-lib-isccfg-check-c' into 'main'
Mark Andrews [Wed, 7 Feb 2024 13:49:19 +0000 (13:49 +0000)] 
Merge branch '4519-check-return-value-of-snprintf-in-lib-isccfg-check-c' into 'main'

Resolve "Check return value of snprintf in lib/isccfg/check.c"

Closes #4519

See merge request isc-projects/bind9!8624

2 years agocleanup isc_symtab_define with isc_symexists_replace
Mark Andrews [Wed, 7 Feb 2024 02:52:10 +0000 (13:52 +1100)] 
cleanup isc_symtab_define with isc_symexists_replace

2 years agoAdd RUNTIME_CHECK
Mark Andrews [Wed, 7 Feb 2024 02:34:39 +0000 (13:34 +1100)] 
Add RUNTIME_CHECK

2 years agoEnsure keyname buffer is big enough
Mark Andrews [Fri, 5 Jan 2024 06:36:00 +0000 (17:36 +1100)] 
Ensure keyname buffer is big enough

Use a temporary string rather than a fixed buffer to construct
the keyname.

2 years agocleanup isc_symtab_undefine callers
Mark Andrews [Wed, 7 Feb 2024 01:56:39 +0000 (12:56 +1100)] 
cleanup isc_symtab_undefine callers

isc_symtab_undefine now only return ISC_R_SUCCESS and ISC_R_EXISTS.
Cleanup callers looking for other values.

2 years agoMerge branch '4561-shutdown-test-doesn-t-log-everything-to-named-run' into 'main'
Mark Andrews [Wed, 7 Feb 2024 01:03:05 +0000 (01:03 +0000)] 
Merge branch '4561-shutdown-test-doesn-t-log-everything-to-named-run' into 'main'

Resolve "Shutdown test doesn't log everything to named.run"

Closes #4561

See merge request isc-projects/bind9!8695

2 years agoRe-enable rndc shutdown test
Tom Krizek [Tue, 6 Feb 2024 15:52:44 +0000 (16:52 +0100)] 
Re-enable rndc shutdown test

The issue preventing a proper rndc shutdown was recently fixed and
the test now passes.

2 years agoCapture the resolver's startup and shutdown logging
Mark Andrews [Tue, 6 Feb 2024 04:45:01 +0000 (15:45 +1100)] 
Capture the resolver's startup and shutdown logging

Also set the debugging to 99.

2 years agoMerge branch '4529-abort-in-nsupdate-2' into 'main'
Mark Andrews [Tue, 6 Feb 2024 23:27:05 +0000 (23:27 +0000)] 
Merge branch '4529-abort-in-nsupdate-2' into 'main'

Resolve "Abort in nsupdate"

Closes #4529

See merge request isc-projects/bind9!8658

2 years agoAdd CHANGES entry for [GL #4529]
Mark Andrews [Thu, 1 Feb 2024 01:38:51 +0000 (12:38 +1100)] 
Add CHANGES entry for [GL #4529]

2 years agoRestore dns_requestmgr_shutdown re-entrancy
Mark Andrews [Thu, 18 Jan 2024 02:43:30 +0000 (13:43 +1100)] 
Restore dns_requestmgr_shutdown re-entrancy

In the conversion to rcu the ability to call dns_requestmgr_shutdown
multiple times was lost.  nsupdate depended on this.  Restore support
for that.

2 years agoMerge branch '4241-expose-zone-first-time-refreshes' into 'main'
Arаm Sаrgsyаn [Tue, 6 Feb 2024 11:26:28 +0000 (11:26 +0000)] 
Merge branch '4241-expose-zone-first-time-refreshes' into 'main'

Resolve "Expose data about 'first time' zone maintenance in-progress"

Closes #4241

See merge request isc-projects/bind9!8481

2 years agoAdd a release note for [GL #4241]
Aram Sargsyan [Fri, 10 Nov 2023 11:45:05 +0000 (11:45 +0000)] 
Add a release note for [GL #4241]

2 years agoAdd a CHANGES note for [GL #4241]
Aram Sargsyan [Fri, 10 Nov 2023 11:44:51 +0000 (11:44 +0000)] 
Add a CHANGES note for [GL #4241]

2 years agoAdd a check for the 'first refresh' data in rndc status
Aram Sargsyan [Fri, 10 Nov 2023 11:33:40 +0000 (11:33 +0000)] 
Add a check for the 'first refresh' data in rndc status

Check that 'rndc status' correctly indicates the expected number
of the secondary zones which have the 'first refresh' flag set.

2 years agoAdd a check for the 'first refresh' data in the stats channel
Aram Sargsyan [Fri, 10 Nov 2023 11:14:58 +0000 (11:14 +0000)] 
Add a check for the 'first refresh' data in the stats channel

Currently we test the incoming zone transfers data in the statistics
channel by retransfering the zones in slow mode and capturing the XML
and JSON outputs in the meantime to check their validity. Add a new
transfer to the test, and check that the XML and JSON files correctly
indicate that we have 3 retransfers and 1 new (first time) transfer.

2 years agoExpose the 'first refresh' zone flag in rndc status
Aram Sargsyan [Fri, 10 Nov 2023 11:10:32 +0000 (11:10 +0000)] 
Expose the 'first refresh' zone flag in rndc status

Expose the newly added 'first refresh' flag in the information
provided by the 'rndc staus' command, by showing the number of
zones, which are not yet fully ready, and their first refresh
is pending or is in-progress.

2 years agoExpose 'first refresh' zone flag in stats channel
Aram Sargsyan [Fri, 10 Nov 2023 11:06:08 +0000 (11:06 +0000)] 
Expose 'first refresh' zone flag in stats channel

Add a new zone flag to indicate that a secondary type zone is
not yet fully ready, and a first time refresh is pending or is
in progress.

Expose this new flag in the statistics channel's "Incoming Zone
Transfers" section.

2 years agoMerge branch '4373-dnssec-validation-yes-should-fail-without-trust-anchors' into...
Arаm Sаrgsyаn [Fri, 2 Feb 2024 19:55:00 +0000 (19:55 +0000)] 
Merge branch '4373-dnssec-validation-yes-should-fail-without-trust-anchors' into 'main'

'dnssec-validation yes' should fail when no trust anchors are configured

Closes #4373

See merge request isc-projects/bind9!8575

2 years agoDocument a specific 'dnssec-validation yes' usage incompatibility
Aram Sargsyan [Wed, 24 Jan 2024 14:45:29 +0000 (14:45 +0000)] 
Document a specific 'dnssec-validation yes' usage incompatibility

Static trust anchor for the root zone can not be used with
'dnssec-validation auto'.

2 years agoUse trust anchors with 'dnssec-validation yes' in system tests
Aram Sargsyan [Thu, 14 Dec 2023 13:14:44 +0000 (13:14 +0000)] 
Use trust anchors with 'dnssec-validation yes' in system tests

Explicitly use an empty 'trust-anchors' statement in the system
tests where it was used implicitly before.

In resolver/ns5/named.conf.in use the trust anchor in 'trusted.conf',
which was supposed to be used there.

2 years agoAdd CHANGES and release notes for [GL #4373]
Aram Sargsyan [Thu, 14 Dec 2023 11:10:50 +0000 (11:10 +0000)] 
Add CHANGES and release notes for [GL #4373]

2 years agoTest trusted anchors configurations for 'dnssec-validation yes'
Aram Sargsyan [Thu, 14 Dec 2023 10:44:21 +0000 (10:44 +0000)] 
Test trusted anchors configurations for 'dnssec-validation yes'

Add checks into the  'checkconf' system test to make sure that the
'dnssec-validation yes' option fails without configured trusted
anchors, and succeeds with configured non-empty, as well as empty
trusted anchors.

2 years agoDocument new requirements for 'dnssec-validation yes'
Aram Sargsyan [Thu, 14 Dec 2023 10:42:56 +0000 (10:42 +0000)] 
Document new requirements for 'dnssec-validation yes'

Using the 'dnssec-validation yes' option now requires an explicitly
confgiured 'trust-anchors' statement (or 'managed-keys' or
'trusted-keys', both deprecated).

2 years agoRequire trust anchors for 'dnnsec-validation yes'
Aram Sargsyan [Thu, 14 Dec 2023 10:40:05 +0000 (10:40 +0000)] 
Require trust anchors for 'dnnsec-validation yes'

Using the 'dnssec-validation yes' option now requires an explicitly
confgiured 'trust-anchors' statement (or 'managed-keys' or
'trusted-keys', both deprecated).

2 years agoMerge branch '4531-improve-parental-agents-definition-arm' into 'main'
Matthijs Mekking [Fri, 2 Feb 2024 16:19:05 +0000 (16:19 +0000)] 
Merge branch '4531-improve-parental-agents-definition-arm' into 'main'

Improve parental-agents definition in ARM

Closes #4531

See merge request isc-projects/bind9!8650

2 years agoAdd CHANGES for #4531
Matthijs Mekking [Mon, 15 Jan 2024 08:19:28 +0000 (09:19 +0100)] 
Add CHANGES for #4531

Improve ARM parental-agents definition.

2 years agoImprove parental-agents definition in ARM
Matthijs Mekking [Mon, 15 Jan 2024 08:17:01 +0000 (09:17 +0100)] 
Improve parental-agents definition in ARM

"A parental agent is the entity that is allowed to change a zone's
delegation information" is untrue, because it is possible to use some
hidden server or a validating resolver.

Also the new text makes it more clear that named sends DS queries to
these servers.

2 years agoMerge branch 'aram/dns-getdb-flags-fix' into 'main'
Arаm Sаrgsyаn [Fri, 2 Feb 2024 15:05:58 +0000 (15:05 +0000)] 
Merge branch 'aram/dns-getdb-flags-fix' into 'main'

Fix the DNS_GETDB_STALEFIRST flag

See merge request isc-projects/bind9!8683

2 years agoAdd a CHANGES note for [GL !8683]
Aram Sargsyan [Wed, 31 Jan 2024 13:16:21 +0000 (13:16 +0000)] 
Add a CHANGES note for [GL !8683]

2 years agoImprove the definition of the DNS_GETDB_* flags
Aram Sargsyan [Wed, 31 Jan 2024 13:12:27 +0000 (13:12 +0000)] 
Improve the definition of the DNS_GETDB_* flags

Use the (1 << N) form for defining the flags, in order to avoid
errors like the one fixed in the previous commit.

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

2 years agoFix the DNS_GETDB_STALEFIRST flag
Aram Sargsyan [Wed, 31 Jan 2024 13:01:13 +0000 (13:01 +0000)] 
Fix the DNS_GETDB_STALEFIRST flag

The DNS_GETDB_STALEFIRST flag is defined as 0x0C, which is the
combination of the DNS_GETDB_PARTIAL (0x04) and the
DNS_GETDB_IGNOREACL (0x08) flags (0x04 | 0x08 == 0x0C) , which is
an obvious error.

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

2 years agoUpdate BIND version for release v9.19.21
Michal Nowak [Fri, 2 Feb 2024 09:56:43 +0000 (10:56 +0100)] 
Update BIND version for release

2 years agoAdd a CHANGES marker
Michal Nowak [Fri, 2 Feb 2024 09:55:35 +0000 (10:55 +0100)] 
Add a CHANGES marker

2 years agoMerge branch 'michal/prepare-documentation-for-bind-9.19.21' into 'v9.19.21-release'
Michal Nowak [Fri, 2 Feb 2024 09:54:26 +0000 (09:54 +0000)] 
Merge branch 'michal/prepare-documentation-for-bind-9.19.21' into 'v9.19.21-release'

Prepare documentation for BIND 9.19.21

See merge request isc-private/bind9!643

2 years agoPrepare release notes for BIND 9.19.21
Michał Kępień [Fri, 2 Feb 2024 08:21:49 +0000 (09:21 +0100)] 
Prepare release notes for BIND 9.19.21

2 years agoMerge branch 'ondrej/dns-validator-async' into 'v9.19.21-release'
Michał Kępień [Thu, 1 Feb 2024 20:47:06 +0000 (20:47 +0000)] 
Merge branch 'ondrej/dns-validator-async' into 'v9.19.21-release'

[CVE-2023-50387] Fix KeyTrap

See merge request isc-private/bind9!606

2 years agoAdd CHANGES and release note for [GL #4424]
Ondřej Surý [Tue, 16 Jan 2024 10:46:29 +0000 (11:46 +0100)] 
Add CHANGES and release note for [GL #4424]

2 years agoMake the dns_validator validations asynchronous and limit it
Ondřej Surý [Mon, 11 Dec 2023 15:50:12 +0000 (16:50 +0100)] 
Make the dns_validator validations asynchronous and limit it

Instead of running all the cryptographic validation in a tight loop,
spread it out into multiple event loop "ticks", but moving every single
validation into own isc_async_run() asynchronous event.  Move the
cryptographic operations - both verification and DNSKEY selection - to
the offloaded threads (isc_work_enqueue), this further limits the time
we spend doing expensive operations on the event loops that should be
fast.

Limit the impact of invalid or malicious RRSets that contain crafted
records causing the dns_validator to do many validations per single
fetch by adding a cap on the maximum number of validations and maximum
number of validation failures that can happen before the resolving
fails.

2 years agoMerge branch '4234-confidential-parser-regression-main' into 'v9.19.21-release'
Michał Kępień [Thu, 1 Feb 2024 20:22:37 +0000 (20:22 +0000)] 
Merge branch '4234-confidential-parser-regression-main' into 'v9.19.21-release'

fix a message parsing regression

See merge request isc-private/bind9!632

2 years agoMerge branch '4553-return-value-for-checkds-shadows' into 'main'
Matthijs Mekking [Thu, 1 Feb 2024 11:40:59 +0000 (11:40 +0000)] 
Merge branch '4553-return-value-for-checkds-shadows' into 'main'

Don't also skip keymgr run if checkds is skipped

Closes #4553

See merge request isc-projects/bind9!8681

2 years agoDon't also skip keymgr run if checkds is skipped
Matthijs Mekking [Wed, 31 Jan 2024 10:44:07 +0000 (11:44 +0100)] 
Don't also skip keymgr run if checkds is skipped

Checking the DS at the parent only happens if dns_zone_getdnsseckeys()
returns success. However, if this function somehow fails, it can also
prevent the keymgr from running.

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

2 years agoMerge branch '4551-dnssec-keygen-does-not-generate-tsig-keys' into 'main'
Matthijs Mekking [Thu, 1 Feb 2024 10:53:41 +0000 (10:53 +0000)] 
Merge branch '4551-dnssec-keygen-does-not-generate-tsig-keys' into 'main'

dnssec-keygen man page still says it can do TSIG

Closes #4551

See merge request isc-projects/bind9!8678

2 years agoPut reference to RFC 2845 in tsig-keygen man page
Matthijs Mekking [Thu, 1 Feb 2024 10:20:33 +0000 (11:20 +0100)] 
Put reference to RFC 2845 in tsig-keygen man page

2 years agodnssec-keygen man page still says it can do TSIG
Matthijs Mekking [Wed, 31 Jan 2024 08:33:17 +0000 (09:33 +0100)] 
dnssec-keygen man page still says it can do TSIG

Remove text in man page that says the program can also be used for
generate TSIG keys, this was removed in 9.13.0 but this text was still
not yet removed.

2 years agoMerge branch '362-check-fetch-quota-param' into 'main'
Evan Hunt [Thu, 1 Feb 2024 02:54:02 +0000 (02:54 +0000)] 
Merge branch '362-check-fetch-quota-param' into 'main'

check range of fetch-quota-param parameters

Closes #362

See merge request isc-projects/bind9!8444

2 years agoCHANGES for [GL #362]
Evan Hunt [Tue, 31 Oct 2023 10:25:37 +0000 (11:25 +0100)] 
CHANGES for [GL #362]

2 years agocheck range of fetch-quota-param parameters
Evan Hunt [Tue, 31 Oct 2023 10:21:33 +0000 (11:21 +0100)] 
check range of fetch-quota-param parameters

the 'low', 'high' and 'discount' parameters to 'fetch-quota-param'
are meant to be ratios with values between zero and one, but higher
values can be assigned. this could potentially lead to an assertion
in maybe_adjust_quota().

2 years agoAdd a CHANGES entry
Michał Kępień [Wed, 31 Jan 2024 10:52:19 +0000 (11:52 +0100)] 
Add a CHANGES entry

2 years agofix another message parsing regression
Aram Sargsyan [Fri, 19 Jan 2024 14:26:17 +0000 (14:26 +0000)] 
fix another message parsing regression

The fix for CVE-2023-4408 introduced a regression in the message
parser, which could cause a crash if an rdata type that can only
occur in the question was found in another section.

Use 'dns__message_putassociatedrdataset()' instead of
'dns__message_puttemprdataset()', because after calling the
'dns_rdatalist_tordataset()' function earlier the 'rdataset'
is associated.

2 years agofix a message parsing regression
Evan Hunt [Tue, 16 Jan 2024 23:58:53 +0000 (15:58 -0800)] 
fix a message parsing regression

the fix for CVE-2023-4408 introduced a regression in the message
parser, which could cause a crash if duplicate rdatasets were found
in the question section. this commit ensures that rdatasets are
correctly disassociated and freed when this occurs.

2 years agoMerge branch 'michal/shift-CHANGES-entries' into 'main'
Michał Kępień [Wed, 31 Jan 2024 10:19:29 +0000 (10:19 +0000)] 
Merge branch 'michal/shift-CHANGES-entries' into 'main'

Shift CHANGES entries by two

See merge request isc-projects/bind9!8679

2 years agoShift CHANGES entries by two
Michał Kępień [Wed, 31 Jan 2024 10:11:11 +0000 (11:11 +0100)] 
Shift CHANGES entries by two

Account for additional entries that will be included in February 2024
releases.

2 years agoMerge branch 'matthijs-fix-kasp-test' into 'main'
Matthijs Mekking [Mon, 29 Jan 2024 08:46:57 +0000 (08:46 +0000)] 
Merge branch 'matthijs-fix-kasp-test' into 'main'

Make max search depth variable in kasp system test

See merge request isc-projects/bind9!8674

2 years agoMake max search depth variable in kasp system test
Matthijs Mekking [Fri, 26 Jan 2024 10:57:25 +0000 (11:57 +0100)] 
Make max search depth variable in kasp system test

In the second test we are looking for key files and extract the key
id numbers. Because keys can be in different directories, we needed
to change the maxdepth when searching for keys.

For the second kasp system test, check that 'dnssec-keygen -k' (default
policy) creates valid files, the 'get_keyids' returned more than one
keytag, namely the ones that are inside the keys/ directory, that were
created for the predecessor test, check that 'dnssec-keygen -k'
(configuredd policy) creates valid files.

This caused the system test to spew out errors that key files were
missing (we were looking for key files in the current directory, but
when looking for key id numbers we included the keys/ directory). It
could also cause the next test to fail, check that 'dnssec-settime' by
default does not edit key state file, because the STATE_FILE environment
variable was overwritten with the key file path of one of the keys that
were created with the configured policy.

We fix this by adjusting the maxdepth for the test in question. Other
tests don't need adjusting because they use unique zone names.

2 years agoMerge branch 'mnowak/drop-freebsd-12' into 'main'
Michal Nowak [Fri, 26 Jan 2024 09:44:17 +0000 (09:44 +0000)] 
Merge branch 'mnowak/drop-freebsd-12' into 'main'

Drop FreeBSD 12

See merge request isc-projects/bind9!8670

2 years agoDrop FreeBSD 12
Michal Nowak [Thu, 25 Jan 2024 12:46:57 +0000 (13:46 +0100)] 
Drop FreeBSD 12

Support for FreeBSD 12.4, the last FreeBSD 12.x release, ended on
December 31, 2023.

Link: https://www.freebsd.org/security/unsupported/
Move the --with-readline=editline ./configure option to FreeBSD 14.

2 years agoMerge branch '1129-hsm-kasp' into 'main'
Matthijs Mekking [Thu, 25 Jan 2024 16:31:59 +0000 (16:31 +0000)] 
Merge branch '1129-hsm-kasp' into 'main'

HSM support for dnssec-policy

Closes #1129

See merge request isc-projects/bind9!5924

2 years agoReplace keystore attach/detach with ISC_REFCOUNT_IMPL/ISC_REFCOUNT_DECL
Matthijs Mekking [Wed, 3 Jan 2024 15:24:53 +0000 (16:24 +0100)] 
Replace keystore attach/detach with ISC_REFCOUNT_IMPL/ISC_REFCOUNT_DECL

This is now the default way to implement attaching to/detaching from
a pointer.

Also update cfg_keystore_fromconfig() to allow NULL value for the
keystore pointer. In most cases we detach it immediately after the
function call.

2 years agoUpdate pkcs11 documentation
Matthijs Mekking [Mon, 27 Nov 2023 10:54:35 +0000 (11:54 +0100)] 
Update pkcs11 documentation

Update the minimum required version of pkcs11-provider that contains the
fixes needed in order to make it work with dnssec-policy.

Update documentation to not recommend using engine_pkcs11 in conjunction
with dnssec-policy.

2 years agoRefactor dns_keystore_directory()
Matthijs Mekking [Fri, 17 Nov 2023 16:09:00 +0000 (17:09 +0100)] 
Refactor dns_keystore_directory()

Add a default key-directory parameter to the function that can
be returned if there is no keystore, or if the keystore directory
is NULL (the latter is also true for the built-in keystore).

2 years agoRename "uri" to "pkcs11-uri"
Matthijs Mekking [Fri, 17 Nov 2023 15:28:01 +0000 (16:28 +0100)] 
Rename "uri" to "pkcs11-uri"

The name "uri" was considered to be too generic and could potentially
clash with a future URI configuration option. Renamed to "pkcs11-uri".

Note that this option name was also preferred over "pkcs11uri", the
dash is considered to be the more clearer form.

2 years agoAdd test case with special characters in zone name
Matthijs Mekking [Fri, 17 Nov 2023 09:55:00 +0000 (10:55 +0100)] 
Add test case with special characters in zone name

Add a zone to the system test that has special characters to
ensure it does not mess up PKCS#11 labels when creating keys.

2 years agoBetter PKCS#11 label creation
Matthijs Mekking [Fri, 17 Nov 2023 09:45:05 +0000 (10:45 +0100)] 
Better PKCS#11 label creation

When using the same PKCS#11 URI for a zone that uses different
DNSSEC policies, the PKCS#11 label could collide, i.e. the same
label could be used for different keys. Add the policy name to
the label to make it more unique.

Also, the zone name could contain characters that are interpreted
as special characters when parsing the PKCS#11 URI string. Mangle
the zone name through 'dns_name_tofilenametext()' to make it
PKCS#11 safe.

Move the creation to a separate function for clarity.

Furthermore, add a log message whenever a PKCS#11 object has been
successfully created.

2 years agoTest dnssec-policy/hsm with multiple views
Matthijs Mekking [Thu, 16 Nov 2023 14:37:34 +0000 (15:37 +0100)] 
Test dnssec-policy/hsm with multiple views

Add test cases for zones in different views that are using PKCS#11
tokens to store its keys.

If it is using the same DNSSEC policy, only one PKCS#11 token should be
created and the same key should be used for the zone in both views.

If it is using a different DNSSEC policy, multiple PKCS#11 token should
be created and each view should use their respective key.

2 years agoRemove "error reading" grep from kasp system test
Matthijs Mekking [Thu, 16 Nov 2023 14:24:19 +0000 (15:24 +0100)] 
Remove "error reading" grep from kasp system test

This log may still occur if there is a DNSKEY in the unsigned zone.
This may happen in a multi-signer setup for example.

Ideally this should not log a warning, but that requires looking up
keys a different way (by searching for key files only). However, that
requires adapting a bunch of system tests, and is out of scope for now.

2 years agoMinor fixes in enginepkcs11 system test
Matthijs Mekking [Thu, 16 Nov 2023 11:10:50 +0000 (12:10 +0100)] 
Minor fixes in enginepkcs11 system test

- Shell function body should be in between curly braces.
- Some erroneous '|| return 1' are replaced with '|| ret=1'.
- Fix a variable name (was 'ret', should be '_ret').
- Clean up when setting up a new test.

2 years agoThe use of isc_dir_t in keymgr is not needed
Matthijs Mekking [Mon, 13 Nov 2023 13:40:59 +0000 (14:40 +0100)] 
The use of isc_dir_t in keymgr is not needed

The internal keymgr used 'isc_dir_open(&dir)' and 'isc_dir_close(&dir)',
but was not using the variable 'dir`, other than checking if the
directory can be opened. Errors like these will be be caught already
in the dst_api function calls.

2 years agoNo longer need to get generated key from label
Matthijs Mekking [Mon, 16 Oct 2023 11:24:10 +0000 (13:24 +0200)] 
No longer need to get generated key from label

The pkcs11-provider did not yet support getting X/Y coordinates
on newly generated EC PKEY keys, thus we attempted to get the
key from the label after it was generated in the keystore.

This has been fixed in:

  https://github.com/latchset/pkcs11-provider/pull/293

Thus now we should be able to use the generated key structure
immediately.

2 years agoOnly run pkcs11engine test if pkcs11-provider is available
Matthijs Mekking [Tue, 10 Oct 2023 13:21:58 +0000 (15:21 +0200)] 
Only run pkcs11engine test if pkcs11-provider is available

The bullseye and bookworm images are not set up with pkcs11-provider,
so we need to add an additional prerequisite for running the
pkcs11engine test. Check the path of OPENSSL_CONF.

2 years agoSpecify key usage to be digital signature
Matthijs Mekking [Tue, 10 Oct 2023 13:18:11 +0000 (15:18 +0200)] 
Specify key usage to be digital signature

If not set, the created keys allows signing plus decrypt which is bad
practice. Setting the key usage explicitly will generate keys that
allow only signing.

2 years agoCreate keys with PKCS#11 URI instead of object
Matthijs Mekking [Wed, 6 Sep 2023 12:09:46 +0000 (14:09 +0200)] 
Create keys with PKCS#11 URI instead of object

The pkcs11-provider has changed to take a PKCS#11 URI instead of an
object identifier. Change the BIND 9 code accordingly to pass through
the label instead of just the object identifier.

See: https://github.com/latchset/pkcs11-provider/pull/284

2 years agoFix tsan errors
Matthijs Mekking [Tue, 29 Aug 2023 13:13:22 +0000 (15:13 +0200)] 
Fix tsan errors

When working internally on the zone, we can access the zone's
variables directly.

2 years agoRefactor findzonekeys
Matthijs Mekking [Tue, 20 Jun 2023 13:44:17 +0000 (15:44 +0200)] 
Refactor findzonekeys

Move dns_dnssec_findzonekeys from the dnssec.{c,h} source code to
zone.{c,h} (the header file already commented that this should be done
inside dns_zone_t).

Alter the function in such a way, that keys are searched for in the
key stores if a 'dnssec-policy' (kasp) is attached to the zone,
otherwise keep using the zone's key-directory.

2 years agodnssec-keygen: -K keydir takes priority
Matthijs Mekking [Thu, 13 Apr 2023 09:17:43 +0000 (11:17 +0200)] 
dnssec-keygen: -K keydir takes priority

When using dnssec-policy with dnssec-keygen in combination with setting
the key-directory on the command line, the commandline argument takes
priority over the key-directory from the default named.conf.

2 years agoAdd documentation for key-store
Matthijs Mekking [Thu, 17 Mar 2022 09:31:03 +0000 (10:31 +0100)] 
Add documentation for key-store

Add grammar and statement sections to the ARM. Add a note about
when changing dnssec-policy you should take into account the key
directory paths.

2 years agoAdd CHANGES and release note for #1129
Matthijs Mekking [Thu, 17 Mar 2022 09:03:02 +0000 (10:03 +0100)] 
Add CHANGES and release note for #1129

Newsworthy.

2 years agoTest dnssec-policy with multiple key stores
Matthijs Mekking [Tue, 15 Mar 2022 15:10:34 +0000 (16:10 +0100)] 
Test dnssec-policy with multiple key stores

Make sure that if a dnssec-policy uses multiple key stores, the keys
have the right attributes and are stored in their appropriate directory.

2 years agoAdd support for key-store to dnssec-keygen
Matthijs Mekking [Tue, 15 Mar 2022 14:54:56 +0000 (15:54 +0100)] 
Add support for key-store to dnssec-keygen

If the provided policy in the configuration file uses a key-store,
use that to generate the key, instead of 'dst_key_generate()'.

2 years agoTest key-store with non-default directory
Matthijs Mekking [Fri, 11 Mar 2022 14:33:08 +0000 (15:33 +0100)] 
Test key-store with non-default directory

Add a test case where dnssec-policy uses key stores with a directory
other than the zone's key-directory.

This requires changing the kasp shell script to take into account that
keys can be in different directories. When looking for keys, the
'find' command now takes a maxdepth of 3 to also look for keys in
subdirectories. Note this maxdepth value is arbitrary, the added
'keystore.kasp' test only requires a maxdepth of 2.

Because of this change, the dnssec-keygen tests no longer work because
they are for the same zone (although different directories). Change
the test to use a different zone ('kasp2' instead of 'kasp').

2 years agoUse dst_key's directory when writing key files
Matthijs Mekking [Wed, 9 Mar 2022 10:33:03 +0000 (11:33 +0100)] 
Use dst_key's directory when writing key files

When writing key files to disk, use the internally stored directory.

Add an access function 'dst_key_directory()'.

Most calls to keymgr functions no longer need to provide the
key-directory value. Only 'dns_keymgr_run' still needs access to
the zone's key-directory in case the key-store is set to the built-in
key-directory.

2 years agoAdd directory to dst_key structure
Matthijs Mekking [Wed, 9 Mar 2022 10:27:03 +0000 (11:27 +0100)] 
Add directory to dst_key structure

Store key directory when reading the key from file. This is the
directory it was read from and can be used when saving the key back
to disk.

2 years agoRefactor findmatchingkeys and keylistfromrdataset
Matthijs Mekking [Wed, 9 Mar 2022 09:55:48 +0000 (10:55 +0100)] 
Refactor findmatchingkeys and keylistfromrdataset

Refactor dns_dnssec_findmatchingkeys and dns_dnssec_keylistfromrdataset
to take into account the key store directories in case the zone is using
dnssec-policy (kasp). Add 'kasp' and 'keystores' parameters.

This requires the keystorelist to be stored inside the zone structure.

The calls to these functions in the DNSSEC tools can use NULL as the
kasp value, as dnssec-signzone does not (yet) support dnssec-policy,
and key collision is checked inside the directory where it is created.

2 years agoAdd tests for key-store with engine_pkcs11
Matthijs Mekking [Mon, 28 Feb 2022 12:51:47 +0000 (13:51 +0100)] 
Add tests for key-store with engine_pkcs11

Add cases for each algorithm to test the interaction between
dnssec-policy and engine_pkcs11. Ensure that named creates keys on
startup.

Also test dnssec-keygen when using a dnssec-policy with a PKCS#11
based key-store.

2 years agoCreate private keys with PKCS#11 object
Matthijs Mekking [Mon, 28 Feb 2022 10:50:43 +0000 (11:50 +0100)] 
Create private keys with PKCS#11 object

If there is a keystore configured with a PKCS#11 URI, zones that
are using a dnssec-policy that uses such a keystore should create keys
via the PKCS#11 interface. Those keys are generally stored inside an
HSM.

Some changes to the code are required, to store the engine reference
into the keystore.

2 years agoAdd object parameter to dst_key_generate()
Matthijs Mekking [Wed, 30 Aug 2023 12:59:44 +0000 (14:59 +0200)] 
Add object parameter to dst_key_generate()

Add a parameter to store a possible PKCS#11 object that can later be used to
identify a key with a PKCS#11 URI string (RFC 7512).

2 years agoStore key store reference instead of name
Matthijs Mekking [Fri, 18 Feb 2022 14:03:49 +0000 (15:03 +0100)] 
Store key store reference instead of name

When creating the kasp structure, instead of storing the name of the
key store on keys, store a reference to the key store object instead.

This requires to build the keystore list prior to creating the kasp
structures, in the dnssec tools, the check code and the server code.

We will create a builtin keystore called "key-directory" which means
use the zone's key-directory as the key store.

The check code changes, because now the keystore is looked up before
creating the kasp structure (and if the keystore is not found, this
is an error). Instead of looking up the keystore after all
'dnssec-policy' clauses have been read.

2 years agoFix a checkconf bug
Matthijs Mekking [Thu, 10 Feb 2022 15:56:00 +0000 (16:56 +0100)] 
Fix a checkconf bug

The check for printing zone list failed because of these additional
lines in the output:

good.conf:22: dnssec-policy: key algorithm 13 has predefined length; \
  ignoring length value 256

I am not sure why this failure hasn't happened before already.

2 years agoCheck if key-store directory is not reused
Matthijs Mekking [Thu, 10 Feb 2022 15:51:32 +0000 (16:51 +0100)] 
Check if key-store directory is not reused

Similar to key-directory, check for zones in different views and
different key and signing policies. Zones must be using different key
directories to store key files on disk.

Now that a key directory can be linked with a dnssec-policy key, the
'keydirexist' checking needs to be reshuffled.

Add tests for bad configuration examples, named-checkconf should catch
those. Also add test cases for a mix of key-directory and key-store
directory.

2 years agoCheck if key-store directory exists
Matthijs Mekking [Wed, 9 Feb 2022 11:19:06 +0000 (12:19 +0100)] 
Check if key-store directory exists

Similar to key-directory, check if the key-store directory exists and
if it is an actual directory.

This commit fixes an accidental test bug in checkconf where if
the "warn key-dir" test failed, the result was ignored.

2 years agoCheck if key-store exists
Matthijs Mekking [Wed, 9 Feb 2022 10:19:21 +0000 (11:19 +0100)] 
Check if key-store exists

Add checkconf check to ensure that the used key-store in the keys
section exists. Error if that is not the case. We also don't allow
the special keyword 'key-directory' as that is internally used to
signal that the zone's key-directory should be used.

2 years agoParse key-store config
Matthijs Mekking [Tue, 25 Jan 2022 09:30:04 +0000 (10:30 +0100)] 
Parse key-store config

Add the code that actually stores the key-store configuration into
structures, also store the reference into the kasp key.

2 years agoAdd code for creating keystore from config
Matthijs Mekking [Tue, 25 Jan 2022 09:08:43 +0000 (10:08 +0100)] 
Add code for creating keystore from config

Add code for configuring keystore objects. Add this to the "kaspconf"
code, as it is related to 'dnssec-policy' and it is too small to create
a separate file for it.

2 years agoAdd code to store key-stores
Matthijs Mekking [Tue, 25 Jan 2022 08:25:03 +0000 (09:25 +0100)] 
Add code to store key-stores

New files to define a structure and functions for dealing with
key-stores.