Commit Graph

32975 Commits

Author SHA1 Message Date
Mark Andrews
7b93ff93d6 Rewrite managed-key journal immediately
Both managed keys and regular zone journals need to be updated
immediately when a recoverable error is discovered.

(cherry picked from commit 0fbdf189c7)
2021-04-07 21:29:07 +02:00
Mark Andrews
511ea2d3f3 Update dns_journal_compact() to handle bad transaction headers
Previously, dns_journal_begin_transaction() could reserve the wrong
amount of space.  We now check that the transaction is internally
consistent when upgrading / downgrading a journal and we also handle the
bad transaction headers.

(cherry picked from commit 83310ffd92)
2021-04-07 21:29:06 +02:00
Mark Andrews
6da2e05df9 Compute transaction size based on journal/transaction type
previously the code assumed that it was a new transaction.

(cherry picked from commit 520509ac7e)
2021-04-07 21:29:06 +02:00
Mark Andrews
d9ad7ccf2d Use journal_write_xhdr() to write the dummy transaction header
Instead of journal_write(), use correct format call journal_write_xhdr()
to write the dummy transaction header which looks at j->header_ver1 to
determine which transaction header to write instead of always writing a
zero filled journal_rawxhdr_t header.

(cherry picked from commit 5a6112ec8f)
2021-04-07 21:29:06 +02:00
Diego dos Santos Fronza
25750e6436 Merge branch '2582-threadsanitizer-data-race-lib-dns-zone-c-10272-7-in-zone_maintenance-v9_16' into 'v9_16'
Resolve TSAN data race in zone_maintenance

See merge request isc-projects/bind9!4866
2021-04-07 13:25:17 +00:00
Diego Fronza
5d391f07c0 Resolve TSAN data race in zone_maintenance
Fix race between zone_maintenance and dns_zone_notifyreceive functions,
zone_maintenance was attempting to read a zone flag calling
DNS_ZONE_FLAG(zone, flag) while dns_zone_notifyreceive was updating
a flag in the same zone calling DNS_ZONE_SETFLAG(zone, ...).

The code reading the flag in zone_maintenance was not protected by the
zone's lock, to avoid a race the zone's lock is now being acquired
before an attempt to read the zone flag is made.
2021-04-07 13:22:36 +00:00
Matthijs Mekking
834379b807 Merge branch '2608-stale-answer-client-timeout-default-off-v9_16' into 'v9_16'
Change default stale-answer-client-timeout to off (9.16)

See merge request isc-projects/bind9!4867
2021-04-07 13:16:03 +00:00
Matthijs Mekking
c63b533690 Change default stale-answer-client-timeout to off
Using "stale-answer-client-timeout" turns out to have unforeseen
negative consequences, and thus it is better to disable the feature
by default for the time being.

(cherry picked from commit e443279bbf)
2021-04-07 14:46:55 +02:00
Matthijs Mekking
cae34f759a Merge branch '2594-servestale-staleonly-recursion-race-v9_16' into 'v9_16'
Serve-stale "staleonly" recursion race condition

See merge request isc-projects/bind9!4860
2021-04-02 12:05:27 +00:00
Matthijs Mekking
194a72b3f1 If RPZ config'd, bail stale-answer-client-timeout
When we are recursing, RPZ processing is not allowed. But when we are
performing a lookup due to "stale-answer-client-timeout", we are still
recursing. This effectively means that RPZ processing is disabled on
such a lookup.

In this case, bail the "stale-answer-client-timeout" lookup and wait
for recursion to complete, as we we can't perform the RPZ rewrite
rules reliably.

(cherry picked from commit 3d3a6415f7)
2021-04-02 13:29:27 +02:00
Matthijs Mekking
29bcd113ea Rename "staleonly"
The dboption DNS_DBFIND_STALEONLY caused confusion because it implies
we are looking for stale data **only** and ignore any active RRsets in
the cache. Rename it to DNS_DBFIND_STALETIMEOUT as it is more clear
the option is related to a lookup due to "stale-answer-client-timeout".

Rename other usages of "staleonly", instead use "lookup due to...".
Also rename related function and variable names.

(cherry picked from commit 839df94190)
2021-04-02 13:29:17 +02:00
Matthijs Mekking
34dd6521b1 Restore the RECURSIONOK attribute after staleonly
When doing a staleonly lookup we don't want to fallback to recursion.
After all, there are obviously problems with recursion, otherwise we
wouldn't do a staleonly lookup.

When resuming from recursion however, we should restore the
RECURSIONOK flag, allowing future required lookups for this client
to recurse.

(cherry picked from commit 3f81d79ffb)
2021-04-02 13:29:09 +02:00
Matthijs Mekking
114dc7888a Remove result exception on staleonly lookup
When implementing "stale-answer-client-timeout", we decided that
we should only return positive answers prematurely to clients. A
negative response is not useful, and in that case it is better to
wait for the recursion to complete.

To do so, we check the result and if it is not ISC_R_SUCCESS, we
decide that it is not good enough. However, there are more return
codes that could lead to a positive answer (e.g. CNAME chains).

This commit removes the exception and now uses the same logic that
other stale lookups use to determine if we found a useful stale
answer (stale_found == true).

This means we can simplify two test cases in the serve-stale system
test: nodata.example is no longer treated differently than data.example.

(cherry picked from commit aaed7f9d8c)
2021-04-02 13:28:59 +02:00
Matthijs Mekking
4b25333037 Add notes and changes for [#2594]
Pretty newsworthy.

(cherry picked from commit e44bcc6f53)
2021-04-02 13:28:48 +02:00
Matthijs Mekking
06823aa255 Remove INSIST on NS_QUERYATTR_ANSWERED
The NS_QUERYATTR_ANSWERED attribute is to prevent sending a response
twice. Without the attribute, this may happen if a staleonly lookup
found a useful answer and sends a response to the client, and later
recursion ends and also tries to send a response.

The attribute was also used to mask adding a duplicate RRset. This is
considered harmful. When we created a response to the client with a
stale only lookup (regardless if we actually have send the response),
we should clear the rdatasets that were added during that lookup.

Mark such rdatasets with the a new attribute,
DNS_RDATASETATTR_STALE_ADDED. Set a query attribute
NS_QUERYATTR_STALEOK if we may have added rdatasets during a stale
only lookup. Before creating a response on a normal lookup, check if
we can expect rdatasets to have been added during a staleonly lookup.
If so, clear the rdatasets from the message with the attribute
DNS_RDATASETATTR_STALE_ADDED set.

(cherry picked from commit 3d5429f61f)
2021-04-02 13:28:08 +02:00
Matthijs Mekking
33d61b9651 Simplify when to detach the client
With stale-answer-client-timeout, we may send a response to the client,
but we may want to hold on to the network manager handle, because
recursion is going on in the background, or we need to refresh a
stale RRset.

Simplify the setting of 'nodetach':
* During a staleonly lookup we should not detach the nmhandle, so just
  set it prior to 'query_lookup()'.
* During a staleonly "stalefirst" lookup set the 'nodetach' to true
  if we are going to refresh the RRset.

Now there is no longer the need to clear the 'nodetach' if we go
through the "dbfind_stale", "stale_refresh_window", or "stale_only"
paths.

(cherry picked from commit 48b0dc159b)
2021-04-02 13:28:01 +02:00
Matthijs Mekking
b1496d19d5 Refactor stale lookups, ignore active RRsets
When doing a staleonly lookup, ignore active RRsets from cache. If we
don't, we may add a duplicate RRset to the message, and hit an
assertion failure in query.c because adding the duplicate RRset to the
ANSWER section failed.

This can happen on a race condition. When a client query is received,
the recursion is started. When 'stale-answer-client-timeout' triggers
around the same time the recursion completes, the following sequence
of events may happen:
1. Queue the "try stale" fetch_callback() event to the client task.
2. Add the RRsets from the authoritative response to the cache.
3. Queue the "fetch complete" fetch_callback() event to the client task.
4. Execute the "try stale" fetch_callback(), which retrieves the
   just-inserted RRset from the database.
5. In "ns_query_done()" we are still recursing, but the "staleonly"
   query attribute has already been cleared. In other words, the
   query will resume when recursion ends (it already has ended but is
   still on the task queue).
6. Execute the "fetch complete" fetch_callback(). It finds the answer
   from recursion in the cache again and tries to add the duplicate to
   the answer section.

This commit changes the logic for finding stale answers in the cache,
such that on "stale_only" lookups actually only stale RRsets are
considered. It refactors the code so that code paths for "dbfind_stale",
"stale_refresh_window", and "stale_only" are more clear.

First we call some generic code that applies in all three cases,
formatting the domain name for logging purposes, increment the
trystale stats, and check if we actually found stale data that we can
use.

The "dbfind_stale" lookup will return SERVFAIL if we didn't found a
usable answer, otherwise we will continue with the lookup
(query_gotanswer()). This is no different as before the introduction of
"stale-answer-client-timeout" and "stale-refresh-time".

The "stale_refresh_window" lookup is similar to the "dbfind_stale"
lookup: return SERVFAIL if we didn't found a usable answer, otherwise
continue with the lookup (query_gotanswer()).

Finally the "stale_only" lookup.

If the "stale_only" lookup was triggered because of an actual client
timeout (stale-answer-client-timeout > 0), and if database lookup
returned a stale usable RRset, trigger a response to the client.
Otherwise return and wait until the recursion completes (or the
resolver query times out).

If the "stale_only" lookup is a "stale-anwer-client-timeout 0" lookup,
preferring stale data over a lookup. In this case if there was no stale
data, or the data was not a positive answer, retry the lookup with the
stale options cleared, a.k.a. a normal lookup. Otherwise, continue
with the lookup (query_gotanswer()) and refresh the stale RRset. This
will trigger a response to the client, but will not detach the handle
because a fetch will be created to refresh the RRset.

(cherry picked from commit 92f7a67892)
2021-04-02 13:27:52 +02:00
Matthijs Mekking
fcf8fb4f39 Keep track of allow client detach
The stale-answer-client-timeout feature introduced a dependancy on
when a client may be detached from the handle. The dboption
DNS_DBFIND_STALEONLY was reused to track this attribute. This overloads
the meaning of this database option, and actually introduced a bug
because the option was checked in other places. In particular, in
'ns_query_done()' there is a check for 'RECURSING(qctx->client) &&
(!QUERY_STALEONLY(&qctx->client->query) || ...' and the condition is
satisfied because recursion has not completed yet and
DNS_DBFIND_STALEONLY is already cleared by that time (in
query_lookup()), because we found a useful answer and we should detach
the client from the handle after sending the response.

Add a new boolean to the client structure to keep track of client
detach from handle is allowed or not. It is only disallowed if we are
in a staleonly lookup and we didn't found a useful answer.

(cherry picked from commit fee164243f)
2021-04-02 13:27:43 +02:00
Ondřej Surý
bcae8ec0ef Merge branch '2607-remove-custom-spnego-v9_16' into 'v9_16'
Remove custom ISC SPNEGO implementation (v9.16)

See merge request isc-projects/bind9!4855
2021-04-01 14:14:13 +00:00
Mark Andrews
99132eda0e Add CHANGES and release note for GL #2607 2021-04-01 16:11:25 +02:00
Ondřej Surý
565a6a5679 Move the dummy shims to single ifndef GSSAPI block
Previously, every function had it's own #ifdef GSSAPI #else #endif block
that defined shim function in case GSSAPI was not being used.  Now the
dummy shim functions have be split out into a single #else #endif block
at the end of the file.

This makes the gssapictx.c similar to 9.17.x code, making the backports
and reviews easier.
2021-04-01 10:42:32 +02:00
Mark Andrews
3fd30e1634 Add Heimdal compatibility support
The Heimdal Kerberos library handles the OID sets in a different manner.
Unify the handling of the OID sets between MIT and Heimdal
implementations by dynamically creating the OID sets instead of using
static predefined set.  This is how upstream recommends to handle the
OID sets.
2021-04-01 10:42:32 +02:00
Mark Andrews
6b0b0c6aba Request krb5 CFLAGS and LIBS from $KRB5_CONFIG
The GSSAPI now needs both gssapi and krb5 libraries, so we need to
request both CFLAGS and LIBS from the configure script.
2021-04-01 10:42:32 +02:00
Mark Andrews
a875dcc669 Remove custom ISC SPNEGO implementation
The custom ISC SPNEGO mechanism implementation is no longer needed on
the basis that all major Kerberos 5/GSSAPI (mit-krb5, heimdal and
Windows) implementations support SPNEGO mechanism since 2006.

This commit removes the custom ISC SPNEGO implementation, and removes
the option from both autoconf and win32 Configure script.  Unknown
options are being ignored, so this doesn't require any special handling.
2021-04-01 10:42:32 +02:00
Mark Andrews
216a97188d Handle expected signals in tsiggss authsock.pl script
When the authsock.pl script would be terminated with a signal,
it would leave the pidfile around.  This commit adds a signal
handler that cleanups the pidfile on signals that are expected.
2021-04-01 09:58:19 +02:00
Michal Nowak
f8c6872beb Merge branch 'mnowak/web-run-gcc-tarball-ci-job-v9_16' into 'v9_16'
[v9_16] Run gcc:tarball CI job in web-triggered pipelines

See merge request isc-projects/bind9!4852
2021-03-31 15:03:57 +00:00
Michal Nowak
fd8ce68189 Run gcc:tarball CI job in web-triggered pipelines
The gcc:tarball CI job may identify problems with tarballs created by
"make dist" of the tarball-create CI job. Enabling the gcc:tarball CI
job in web-triggered pipelines provides developers with a test vector.

(cherry picked from commit 4d5d3b75da)
2021-03-31 16:53:51 +02:00
Ondřej Surý
6e4eaa780d Merge branch 'cherry-pick-19b69e9a' into 'v9_16'
Do not require config.h to use isc/util.h (v9.16)

See merge request isc-projects/bind9!4842
2021-03-26 19:00:03 +00:00
Ondřej Surý
ee7283b3ee Merge branch 'bind-dyndb-ldap-v9.16.13' into 'main'
Do not require config.h to use isc/util.h

See merge request isc-projects/bind9!4840

(cherry picked from commit 19b69e9a3b)

81eb3396 Do not require config.h to use isc/util.h
2021-03-26 18:48:06 +00:00
Diego dos Santos Fronza
1c7b15151b Merge branch '2490-dig-tcp-does-not-honor-tries-1-nor-retry-0-v9_16' into 'v9_16'
Resolve "dig +tcp does not honor +tries=1 nor +retry=0"

See merge request isc-projects/bind9!4839
2021-03-25 17:59:37 +00:00
Diego Fronza
ec83e02ed2 Add CHANGES note for [GL #2490] 2021-03-25 14:35:16 -03:00
Diego Fronza
db2c180feb Update dig's man page
Adjusted man page entries for +tries and +retry options to reflect the
fact that now those options apply to TCP as well.
2021-03-25 14:33:50 -03:00
Diego Fronza
9c2d52bcdb Added tests for tries=1 and retry=0 on TCP EOF
Added tests to ensure that dig won't retry sending a query over tcp
(+tcp) when a TCP connection is closed prematurely (EOF is read) if
either +tries=1 or retry=0 is specified on the command line.
2021-03-25 14:33:08 -03:00
Diego Fronza
d299f0e9ab Adjusted dig system tests
Now that premature EOF on tcp connections take +tries and +retry into
account, the dig system tests handling TCP EOF with +tries=1 were
expecting dig to do a second attempt in handling the tcp query, which
doesn't happen anymore.

To make the test work as expected +tries value was adjusted to 2, to
make it behave as before after the new update on dig.
2021-03-25 14:32:46 -03:00
Diego Fronza
1e5f3e6fa3 Don't retry +tcp queries on failure if tries=1 or retries=0
Before this commit, a premature EOF (connection closed) on tcp queries
was causing dig to automatically attempt to send the query again, even
if +tries=1 or +retries=0 was provided on command line.

This commit fix the problem by taking into account the no. of retries
specified by the user when processing a premature EOF on tcp
connections.
2021-03-25 14:32:37 -03:00
Matthijs Mekking
b813eab387 Merge branch '2488-refresh-keys-after-rndc-rollover-v9_16' into 'v9_16'
Resolve "Update key refresh timer after 'rndc dnssec -rollover'"

See merge request isc-projects/bind9!4833
2021-03-22 15:27:29 +00:00
Matthijs Mekking
a36257ea60 Fix some intermittent kasp failures
When calling "rndc dnssec -checkds", it may take some milliseconds
before the appropriate changes have been written to the state file.
Add retry_quiet mechanisms to allow the write operation to finish.

Also retry_quiet the check for the next key event. A "rndc dnssec"
command may trigger a zone_rekey event and this will write out
a new "next key event" log line, but it may take a bit longer than
than expected in the tests.

(cherry picked from commit 82d667e1d5)
2021-03-22 15:35:22 +01:00
Matthijs Mekking
d12b40f6fb Rekey immediately after rndc checkds/rollover
Call 'dns_zone_rekey' after a 'rndc dnssec -checkds' or 'rndc dnssec
-rollover' command is received, because such a command may influence
the next key event. Updating the keys immediately avoids unnecessary
rollover delays.

The kasp system test no longer needs to call 'rndc loadkeys' after
a 'rndc dnssec -checkds' or 'rndc dnssec -rollover' command.

(cherry picked from commit 82f72ae249)
2021-03-22 15:35:22 +01:00
Matthijs Mekking
a5c402b67d Merge branch '2517-cds-dnskey-delete-records-prevent-loading-unsigned-zone-v9_16' into 'v9_16'
Resolve "CDS and CDNSKEY DELETE records prevent (re-)loading unsigned zone"

See merge request isc-projects/bind9!4832
2021-03-22 13:27:36 +00:00
Matthijs Mekking
3156c0d103 Add CHANGES and notes for [#2517]
(cherry picked from commit 841e90c6fc)
2021-03-22 13:57:10 +01:00
Matthijs Mekking
1f8c5786f8 Delete CDS/CDNSKEY records when zone is unsigned
CDS/CDNSKEY DELETE records are only useful if they are signed,
otherwise the parent cannot verify these RRsets anyway. So once the DS
has been removed (and signaled to BIND), we can remove the DNSKEY and
RRSIG records, and at this point we can also remove the CDS/CDNSKEY
records.

(cherry picked from commit 6f31f62d69)
2021-03-22 13:57:10 +01:00
Matthijs Mekking
7882c7fbea Allow CDS/CDNSKEY DELETE records in unsigned zone
While not useful, having a CDS/CDNSKEY DELETE record in an unsigned
zone is not an error and "named-checkzone" should not complain.

(cherry picked from commit f211c7c2a1)
2021-03-22 13:31:02 +01:00
Matthijs Mekking
62592d59cb Merge branch 'matthijs-test-keymgr2kasp-v9_16' into 'v9_16'
Test keymgr2kasp (9.16)

See merge request isc-projects/bind9!4830
2021-03-22 11:40:59 +00:00
Matthijs Mekking
fe09becc7e Retry quiet check keys
Change the 'check_keys' function to try three times. Some intermittent
kasp test failures are because we are inspecting the key files
before the actual change has happen. The 'retry_quiet' approach allows
for a bit more time to let the write operation finish.

(cherry picked from commit d5531df79a)
2021-03-22 11:24:55 +01:00
Matthijs Mekking
b24a0da8f4 Update copyrights for keymgr2kasp
This MR introduces a new system test 'keymgr2kasp' to test
migration to 'dnssec-policy'. It moves some existing tests from
the 'kasp' system test to here.

Also a common script 'kasp.sh', to be used in kasp specific tests,
is introduced.

(manually picked from commit 923c2a07bf)
2021-03-22 11:24:55 +01:00
Matthijs Mekking
b81502f4ae Fix keymgr key init bug
The 'keymgr_key_init()' function initializes key states if they have
not been set previously. It looks at the key timing metadata and
determines using the given times whether a state should be set to
RUMOURED or OMNIPRESENT.

However, the DNSKEY and ZRRSIG states were mixed up: When looking
at the Activate timing metadata we should set the ZRRSIG state, and
when looking at the Published timing metadata we should set the
DNSKEY state.

(cherry picked from commit 27e7d5f698)
2021-03-22 11:24:55 +01:00
Matthijs Mekking
68e9603ed8 Test keymgr2kasp state from timing metadata
Add two test zones that migrate to dnssec-policy. Test if the key
states are set accordingly given the timing metadata.

The rumoured.kasp zone has its Publish/Active/SyncPublish times set
not too long ago so the key states should be set to RUMOURED. The
omnipresent.kasp zone has its Publish/Active/SyncPublish times set
long enough to set the key states to OMNIPRESENT.

Slightly change the init_migration_keys function to set the
key lifetime to "none" (legacy keys don't have lifetime). Then in the
test case set the expected key lifetime explicitly.

(cherry picked from commit c40c1ebcb1)
2021-03-22 11:24:55 +01:00
Matthijs Mekking
177ceb6cda Editorial commit keymgr2kasp test
This commit is somewhat editorial as it does not introduce something
new nor fixes anything.

The layout in keymgr2kasp/tests.sh has been changed, with the
intention to make more clear where a test scenario ends and begins.

The publication time of some ZSKs has been changed. It makes a more
clear distinction between publication time and activation time.

(cherry picked from commit f6fa254256)
2021-03-22 11:24:55 +01:00
Matthijs Mekking
e91f53cc6e Introduce kasp.sh
Add a script similar to conf.sh to include common functions and
variables for testing KASP. Currently used in kasp, keymgr2kasp, and
nsec3.

(cherry picked from commit ecb073bdd6)
2021-03-22 11:24:55 +01:00
Matthijs Mekking
2fa68d985f Move kasp migration tests to different directory
The kasp system test was getting pretty large, and more tests are on
the way. Time to split up. Move tests that are related to migrating
to dnssec-policy to a separate directory 'keymgr2kasp'.

(cherry picked from commit 5389172111)
2021-03-22 11:24:55 +01:00