Commit Graph

32761 Commits

Author SHA1 Message Date
Mark Andrews
b8fc8742e5 Re-order include directories
${FSTRM_CFLAGS} ${PROTOBUF_C_CFLAGS} ${OPENSSL_CFLAGS} ${LMDB_CFLAGS}
need to appear after all directories in the build tree.
2021-02-16 12:08:21 +11:00
Diego dos Santos Fronza
f24ad1eec7 Merge branch '2041-bug-reconfig-auto-dnssec-high-thread-number-leak-resources-and-crash-named-v9_16' into 'v9_16'
Resolve "BUG reconfig+auto-dnssec+high thread number leak resources and crash named"

See merge request isc-projects/bind9!4677
2021-02-15 20:45:57 +00:00
Diego Fronza
f4aa840f52 Add CHANGES note for [GL #2041] 2021-02-15 12:04:29 -03:00
Diego Fronza
80c1a44643 Test reconfig after adding inline signed zones won't crash named
This test ensures that named won't crash after many inline-signed zones
are added to configurarion, followed by a rndc reconfig.
2021-02-15 11:53:24 -03:00
Diego Fronza
d89a8bf696 Fix dangling references to outdated views after reconfig
This commit fix a leak which was happening every time an inline-signed
zone was added to the configuration, followed by a rndc reconfig.

During the reconfig process, the secure version of every inline-signed
zone was "moved" to a new view upon a reconfig and it "took the raw
version along", but only once the secure version was freed (at shutdown)
was prev_view for the raw version detached from, causing the old view to
be released as well.

This caused dangling references to be kept for the previous view, thus
keeping all resources used by that view in memory.
2021-02-15 11:52:50 -03:00
Petr Špaček
87717f4006 Merge branch 'pspacek/ci-python-allthetime-v9_16' into 'v9_16'
[v9_16]  Run Python linters in CI even outside of merge requests

See merge request isc-projects/bind9!4675
2021-02-15 08:58:12 +00:00
Petr Špaček
441d2e310e Run Python linters in CI even outside of merge requests
Previously it did not get run on scheduled CI pipelines.

(cherry picked from commit 74d7cddc4c)
2021-02-12 15:51:05 +01:00
Michal Nowak
9a80a1b17e Merge branch 'mnowak/check-for-unrecognized-options-v9_16' into 'v9_16'
[v9_16] Check for unrecognized configure options

See merge request isc-projects/bind9!4568
2021-02-12 13:31:39 +00:00
Michal Nowak
ec278d628d Add --enable-option-checking=fatal to ./configure in CI
The --enable-option-checking=fatal option prevents ./configure from
proceeding when an unknown option is used in the ./configure step in CI.
This change will avoid adding unsupported ./configure options or options
with typo or typo in pairwise testing "# [pairwise: ...]" marker.

(cherry picked from commit 4295c82e45)
2021-02-12 14:16:26 +01:00
Michal Nowak
3e22c588ae Merge branch '2312-lint-generated-manual-pages-v9_16' into 'v9_16'
[v9_16] Lint manual pages

See merge request isc-projects/bind9!4673
2021-02-12 12:21:55 +00:00
Michal Nowak
69a51f311a Lint manual pages
As we generate manual pages from reStructuredText sources, we don't have
absolute control on manual page output and therefore 'mandoc -Tlint' may
always report warnings we can't eliminate. In light of this some mandoc
warnings need to be ignored.

(cherry picked from commit 22fdcb30db)
2021-02-12 12:58:18 +01:00
Mark Andrews
6bd42bc124 Merge branch '2421-cid-316509-untrusted-value-as-argument-tainted_scalar-v9_16' into 'v9_16'
Resolve "CID 316509: Untrusted value as argument (TAINTED_SCALAR)"

See merge request isc-projects/bind9!4671
2021-02-12 00:01:28 +00:00
Mark Andrews
6e30caed57 Silence Insecure data handling (TAINTED_SCALAR)
Coverity assumes that the memory holding any value read using byte
swapping is tainted.  As we store the NSEC3PARAM records in wire
form and iterations is byte swapped the memory holding the record
is marked as tainted.  nsec3->salt_length is marked as tainted
transitively. To remove the taint the value need to be range checked.
For a correctly formatted record region.length should match
nsec3->salt_length and provides a convenient value to check the field
against.

    *** CID 316507:  Insecure data handling  (TAINTED_SCALAR)
    /lib/dns/rdata/generic/nsec3param_51.c: 241 in tostruct_nsec3param()
    235     	region.length = rdata->length;
    236     	nsec3param->hash = uint8_consume_fromregion(&region);
    237     	nsec3param->flags = uint8_consume_fromregion(&region);
    238     	nsec3param->iterations = uint16_consume_fromregion(&region);
    239
    240     	nsec3param->salt_length = uint8_consume_fromregion(&region);
    >>>     CID 316507:  Insecure data handling  (TAINTED_SCALAR)
    >>>     Passing tainted expression "nsec3param->salt_length" to "mem_maybedup", which uses it as an offset.
    241     	nsec3param->salt = mem_maybedup(mctx, region.base,
    242     					nsec3param->salt_length);
    243     	if (nsec3param->salt == NULL) {
    244     		return (ISC_R_NOMEMORY);
    245     	}
    246     	isc_region_consume(&region, nsec3param->salt_length);

(cherry picked from commit c40133d840)
2021-02-12 10:43:19 +11:00
Mark Andrews
8302e9fb69 Silence Untrusted value as argument (TAINTED_SCALAR)
Coverity assumes that the memory holding any value read using byte
swapping is tainted.  As we store the NSEC3 records in wire form
and iterations is byte swapped the memory holding the record is
marked as tainted.  nsec3->salt_length and nsec3->next_length are
marked as tainted transitively. To remove the taint the values need
to be range checked.  Valid values for these should never exceed
region.length so that is becomes a reasonable value to check against.

    *** CID 316509:    (TAINTED_SCALAR)
    /lib/dns/rdata/generic/nsec3_50.c: 312 in tostruct_nsec3()
    306     	if (nsec3->salt == NULL) {
    307     		return (ISC_R_NOMEMORY);
    308     	}
    309     	isc_region_consume(&region, nsec3->salt_length);
    310
    311     	nsec3->next_length = uint8_consume_fromregion(&region);
    >>>     CID 316509:    (TAINTED_SCALAR)
    >>>     Passing tainted expression "nsec3->next_length" to "mem_maybedup", which uses it as an offset.
    312     	nsec3->next = mem_maybedup(mctx, region.base, nsec3->next_length);
    313     	if (nsec3->next == NULL) {
    314     		goto cleanup;
    315     	}
    316     	isc_region_consume(&region, nsec3->next_length);
    317
    /lib/dns/rdata/generic/nsec3_50.c: 305 in tostruct_nsec3()
    299     	region.length = rdata->length;
    300     	nsec3->hash = uint8_consume_fromregion(&region);
    301     	nsec3->flags = uint8_consume_fromregion(&region);
    302     	nsec3->iterations = uint16_consume_fromregion(&region);
    303
    304     	nsec3->salt_length = uint8_consume_fromregion(&region);
    >>>     CID 316509:    (TAINTED_SCALAR)
    >>>     Passing tainted expression "nsec3->salt_length" to "mem_maybedup", which uses it as an offset.
    305     	nsec3->salt = mem_maybedup(mctx, region.base, nsec3->salt_length);
    306     	if (nsec3->salt == NULL) {
    307     		return (ISC_R_NOMEMORY);
    308     	}
    309     	isc_region_consume(&region, nsec3->salt_length);
    310

(cherry picked from commit fd8d1337a5)
2021-02-12 10:43:19 +11:00
Michal Nowak
d52e67211a Merge branch 'mnowak/enable-libns-tests-to-run-under-asan-v9_16' into 'v9_16'
[v9_16] Drop AddressSanitizer constraint from libns unit tests

See merge request isc-projects/bind9!4667
2021-02-10 10:37:12 +00:00
Michal Nowak
001413ed50 Drop AddressSanitizer constraint from libns unit tests
The AddressSanitizer constraint in some libns unit tests does not seem
to be necessary anymore, these tests run fine under AddressSanitizer.

(cherry picked from commit 613be8706e)
2021-02-10 11:03:27 +01:00
Matthijs Mekking
33ef49d828 Merge branch '1810-refactor-ecdsa-eddsa-system-tests-v9_16' into 'v9_16'
Resolve "Refactor ecdsa and eddsa tests after testcrypto.sh changes"

See merge request isc-projects/bind9!4666
2021-02-09 16:07:55 +00:00
Matthijs Mekking
1a32cf543b Update copyrights for [#1810]
(cherry picked from commit 51827ddcd3)
2021-02-09 16:06:50 +01:00
Matthijs Mekking
40e56b0dcc Refactor ecdsa system test
Similar to eddsa system test.

(cherry picked from commit 650b0d4691)
2021-02-09 16:06:50 +01:00
Matthijs Mekking
4538d8ddf2 Refactor eddsa system test
Test for Ed25519 and Ed448. If both algorithms are not supported, skip
test. If only one algorithm is supported, run test, skip the
unsupported algorithm. If both are supported, run test normally.

Create new ns3. This will test Ed448 specifically, while now ns2 only
tests Ed25519. This moves some files from ns2/ to ns3/.

(cherry picked from commit 8bf31d0592)
2021-02-09 16:06:50 +01:00
Matthijs Mekking
5af3a46ac0 Fix testcrypto.sh
Testing Ed448 was actually testing Ed25519.

(cherry picked from commit 572d7ec3b7)
2021-02-09 15:25:25 +01:00
Michal Nowak
49947b65ed Merge branch 'mnowak/check-asan-errors-in-configure-v9_16' into 'v9_16'
[v9_16] Check config.log for ASAN errors

See merge request isc-projects/bind9!4664
2021-02-09 11:12:10 +00:00
Michal Nowak
2fa5727446 Check config.log for ASAN errors
./configure checks might produce a false negative error due to ASAN
errors and thus disable some options.

(cherry picked from commit 0db934d401)
2021-02-09 12:06:05 +01:00
Matthijs Mekking
28e802a0e4 Merge branch '2434-fetch-limit-serve-stale-v9_16' into 'v9_16'
Resolve "Serve stale when fetch limits are hit" (9.16)

See merge request isc-projects/bind9!4627
2021-02-08 16:37:39 +00:00
Matthijs Mekking
70fbbedc24 Adjust serve-stale test
The number of queries to use in the burst can be reduced, as we have
a very low fetch limit of 1.

The dig command in 'wait_for_fetchlimits()' should time out sooner as
we expect a SERVFAIL to be returned promptly.

Enabling serve-stale can be done before hitting fetch-limits. This
reduces the chance that the resolver queries time out and fetch count
is reset. The chance of that happening is already slim because
'resolver-query-timeout' is 10 seconds, but better to first let the
data become stale rather than doing that while attempting to resolve.

(cherry picked from commit 00f575e7ef)
2021-02-08 16:10:12 +01:00
Matthijs Mekking
2afaff75ed Use stale on error also when unable to recurse
The 'query_usestale()' function was only called when in
'query_gotanswer()' and an unexpected error occurred. This may have
been "quota reached", and thus we were in some cases returning
stale data on fetch-limits (and if serve-stale enabled of course).

But we can also hit fetch-limits when recursing because we are
following a referral (in 'query_notfound()' and
'query_delegation_recurse()'). Here we should also check for using
stale data in case an error occurred.

Specifically don't check for using stale data when refetching a
zero TTL RRset from cache.

Move the setting of DNS_DBFIND_STALESTART into the 'query_usestale()'
function to avoid code duplication.

(cherry picked from commit 8bcd7fe69e)
2021-02-08 16:10:03 +01:00
Matthijs Mekking
e02ce9e833 Add notes and change entry for [#2434]
This concludes the serve-stale improvements.

(cherry picked from commit ed8421693c)
2021-02-08 16:09:36 +01:00
Matthijs Mekking
2e28e5587e Add test for serve-stale /w fetch-limits
Add a test case when fetch-limits are reached and we have stale data
in cache.

This test starts with a positive answer for 'data.example/TXT' in
cache.

1. Reload named.conf to set fetch limits.
2. Disable responses from the authoritative server.
3. Now send a batch of queries to the resolver, until hitting the
   fetch limits. We can detect this by looking at the response RCODE,
   at some point we will see SERVFAIL responses.
4. At that point we will turn on serve-stale.
5. Clients should see stale answers now.
6. An incoming query should not set the stale-refresh-time window,
   so a following query should still get a stale answer because of a
   resolver failure (and not because it was in the stale-refresh-time
   window).

(cherry picked from commit 11b74fc176)
2021-02-08 16:07:43 +01:00
Matthijs Mekking
dbf5428629 Only start stale refresh window when resuming
If we did not attempt a fetch due to fetch-limits, we should not start
the stale-refresh-time window.

Introduce a new flag DNS_DBFIND_STALESTART to differentiate between
a resolver failure and unexpected error. If we are resuming, this
indicates a resolver failure, then start the stale-refresh-time window,
otherwise don't start the stale-refresh-time window, but still fall
back to using stale data.

(This commit also wraps some docstrings to 80 characters width)

(cherry picked from commit aabdedeae3)
2021-02-08 16:07:43 +01:00
Matthijs Mekking
809ec0a224 Use stale data also if we are not resuming
Before this change, BIND will only fallback to using stale data if
there was an actual attempt to resolve the query. Then on a timeout,
the stale data from cache becomes eligible.

This commit changes this so that on any unexpected error stale data
becomes eligble (you would still have to have 'stale-answer-enable'
enabled of course).

If there is no stale data, this may return in an error again, so don't
loop on stale data lookup attempts. If the DNS_DBFIND_STALEOK flag is
set, this means we already tried to lookup stale data, so if that is
the case, don't use stale again.

(cherry picked from commit c6fd02aed5)
2021-02-08 16:07:43 +01:00
Mark Andrews
6642078698 Merge branch '2468-cid-318094-null-pointer-dereferences-reverse_inull-v9_16' into 'v9_16'
Remove redundant 'version == NULL' check

See merge request isc-projects/bind9!4663
2021-02-08 05:39:01 +00:00
Mark Andrews
8092b7eec6 Remove redundant 'version == NULL' check
*** CID 318094:  Null pointer dereferences  (REVERSE_INULL)
    /lib/dns/rbtdb.c: 1389 in newversion()
    1383     	version->xfrsize = rbtdb->current_version->xfrsize;
    1384     	RWUNLOCK(&rbtdb->current_version->rwlock, isc_rwlocktype_read);
    1385     	rbtdb->next_serial++;
    1386     	rbtdb->future_version = version;
    1387     	RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
    1388
       CID 318094:  Null pointer dereferences  (REVERSE_INULL)
       Null-checking "version" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    1389     	if (version == NULL) {
    1390     		return (result);
    1391     	}
    1392
    1393     	*versionp = version;
    1394

(cherry picked from commit 456d53d1fb)
2021-02-08 16:17:52 +11:00
Mark Andrews
6781bf3eac Merge branch '1697-isc_rwlock_init-can-no-longer-fail-in-master-clean-up-calls-v9_16' into 'v9_16'
Cleanup redundant isc_rwlock_init() result checks

See merge request isc-projects/bind9!4662
2021-02-08 05:13:40 +00:00
Mark Andrews
a900d79ea8 Cleanup redundant isc_rwlock_init() result checks
(cherry picked from commit 3b11bacbb7)
2021-02-08 15:13:49 +11:00
Mark Andrews
7358a58db4 Merge branch '2469-cid-281461-untrusted-loop-bound-v9_16' into 'v9_16'
Attempt to silence untrusted loop bound

See merge request isc-projects/bind9!4661
2021-02-08 03:59:47 +00:00
Mark Andrews
c2a5b88275 Attempt to silence untrusted loop bound
Assign hit_len + key_len to len and test the result
rather than recomputing and letting the compiler simplify.

    213        isc_region_consume(&region, 2); /* hit length + algorithm */
        9. tainted_return_value: Function uint16_fromregion returns tainted data. [show details]
        10. tainted_data_transitive: Call to function uint16_fromregion with tainted argument *region.base returns tainted data.
        11. tainted_return_value: Function uint16_fromregion returns tainted data.
        12. tainted_data_transitive: Call to function uint16_fromregion with tainted argument *region.base returns tainted data.
        13. var_assign: Assigning: key_len = uint16_fromregion(&region), which taints key_len.
    214        key_len = uint16_fromregion(&region);
        14. lower_bounds: Casting narrower unsigned key_len to wider signed type int effectively tests its lower bound.
        15. Condition key_len == 0, taking false branch.
    215        if (key_len == 0) {
    216                RETERR(DNS_R_FORMERR);
    217        }
        16. Condition !!(_r->length >= _l), taking true branch.
        17. Condition !!(_r->length >= _l), taking true branch.
    218        isc_region_consume(&region, 2);
        18. lower_bounds: Casting narrower unsigned key_len to wider signed type int effectively tests its lower bound.
        19. Condition region.length < (unsigned int)(hit_len + key_len), taking false branch.
    219        if (region.length < (unsigned)(hit_len + key_len)) {
    220                RETERR(DNS_R_FORMERR);
    221        }
    222
        20. lower_bounds: Casting narrower unsigned key_len to wider signed type int effectively tests its lower bound.
        21. Condition _r != 0, taking false branch.
    223        RETERR(mem_tobuffer(target, rr.base, 4 + hit_len + key_len));
        22. lower_bounds: Casting narrower unsigned key_len to wider signed type int effectively tests its lower bound.
        23. var_assign_var: Compound assignment involving tainted variable 4 + hit_len + key_len to variable source->current taints source->current.
    224        isc_buffer_forward(source, 4 + hit_len + key_len);
    225
    226        dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);

    CID 281461 (#1 of 1): Untrusted loop bound (TAINTED_SCALAR)
        24. tainted_data: Using tainted variable source->active - source->current as a loop boundary.
    Ensure that tainted values are properly sanitized, by checking that their values are within a permissible range.
    227        while (isc_buffer_activelength(source) > 0) {
    228                dns_name_init(&name, NULL);
    229                RETERR(dns_name_fromwire(&name, source, dctx, options, target));
    230        }

(cherry picked from commit 2f946c831a)
2021-02-08 14:05:11 +11:00
Michal Nowak
aa98a53cc0 Merge branch 'mnowak/check-arm-pdf-validity-v9_16' into 'v9_16'
[v9_16] Check PDF file structure with QPDF

See merge request isc-projects/bind9!4651
2021-02-03 17:01:43 +00:00
Michal Nowak
9f7669cab3 Check PDF file structure with QPDF
"qpdf --check" checks file structure of generated ARM PDF.

(cherry picked from commit 359708b9d6)
2021-02-03 17:50:08 +01:00
Matthijs Mekking
241c4bd613 Merge branch '2377-allow-a-records-below-an-_spf-label-as-a-check-names-exception-v9_16' into 'v9_16'
Resolve "Allow A records below an '_spf' label as a check-names exception"

See merge request isc-projects/bind9!4650
2021-02-03 16:48:58 +00:00
Mark Andrews
4bd8bcf236 Add release note entry
(cherry picked from commit 1294918702)
2021-02-03 16:32:43 +01:00
Mark Andrews
86f7b64408 Add CHANGES
(cherry picked from commit 2b5091ac17)
2021-02-03 16:26:40 +01:00
Mark Andrews
7976a7264a Check that A record is accepted with _spf label present
(cherry picked from commit a3b2b86e7f)
2021-02-03 16:26:32 +01:00
Mark Andrews
6da9f238d4 Allow A records below '_spf' labels as recommend by RFC7208
(cherry picked from commit 63c16c8506)
2021-02-03 16:26:25 +01:00
Matthijs Mekking
5710207191 Merge branch '2375-dnssec-policy-three-is-a-crowd-rollover-bug-v9_16' into 'v9_16'
Resolve "three is a crowd" dnssec-policy key rollover bug (9.16)

See merge request isc-projects/bind9!4649
2021-02-03 15:11:10 +00:00
Matthijs Mekking
76f7f598b3 Add kasp test todo for [#2375]
This bugfix has been manually verified but is missing a unit test.
Created GL #2471 to track this.

(cherry picked from commit 189f5a3f28)
2021-02-03 15:48:29 +01:00
Matthijs Mekking
ce2a37a990 Use NUM_KEYSTATES constant where appropriate
We use the number 4 a lot when working on key states. Better to use
the NUM_KEYSTATES constant instead.

(cherry picked from commit 98ace6d97d)
2021-02-03 15:48:20 +01:00
Matthijs Mekking
c0e98d8adb Add change and release note for [#2375]
News worthy.

(cherry picked from commit 7947f7f9c6)
2021-02-03 15:48:09 +01:00
Matthijs Mekking
a8fba11da9 Cleanup keymgr.c
Three small cleanups:

1. Remove an unused keystr/dst_key_format.
2. Initialize a dst_key_state_t state with NA.
3. Update false comment about local policy (local policy only adds
   barrier on transitions to the RUMOURED state, not the UNRETENTIVE
   state).

(cherry picked from commit 189d9a2d21)
2021-02-03 15:47:40 +01:00
Matthijs Mekking
ceac392e19 Fix DS/DNSKEY hidden or chained functions
There was a bug in function 'keymgr_ds_hidden_or_chained()'.

The funcion 'keymgr_ds_hidden_or_chained()' implements (3e) of rule2
as defined in the "Flexible and Robust Key Rollover" paper. The rules
says: All DS records need to be in the HIDDEN state, or if it is not
there must be a key with its DNSKEY and KRRSIG in OMNIPRESENT, and
its DS in the same state as the key in question. In human langauge,
if all keys have their DS in HIDDEN state you can do what you want,
but if a DS record is available to some validators, there must be
a chain of trust for it.

Note that the barriers on transitions first check if the current
state is valid, and then if the next state is valid too. But
here we falsely updated the 'dnskey_omnipresent' (now 'dnskey_chained')
with the next state. The next state applies to 'key' not to the state
to be checked. Updating the state here leads to (true) always, because
the key that will move its state will match the falsely updated
expected state. This could lead to the assumption that Key 2 would be
a valid chain of trust for Key 1, while clearly the presence of any
DS is uncertain.

The fix here is to check if the DNSKEY and KRRSIG are in OMNIPRESENT
state for the key that does not have its DS in the HIDDEN state, and
only if that is not the case, ensure that there is a key with the same
algorithm, that provides a valid chain of trust, that is, has its
DNSKEY, KRRSIG, and DS in OMNIPRESENT state.

The changes in 'keymgr_dnskey_hidden_or_chained()' are only cosmetical,
renaming 'rrsig_omnipresent' to 'rrsig_chained' and removing the
redundant initialization of the DST_KEY_DNSKEY expected state to NA.

(cherry picked from commit 291bcc3721)
2021-02-03 15:47:30 +01:00
Matthijs Mekking
6ff0e99fa7 Update keymgr_key_is_successor() calls
The previous commit changed the function definition of
'keymgr_key_is_successor()', this commit updates the code where
this function is called.

In 'keymgr_key_exists_with_state()' the logic is also updated slightly
to become more readable. First handle the easy cases:
- If the key does not match the state, continue with the next key.
- If we found a key with matching state, and there is no need to
  check the successor relationship, return (true).
- Otherwise check the successor relationship.

In 'keymgr_key_has_successor()' it is enough to check if a key has
a direct successor, so instead of calling 'keymgr_key_is_successor()',
we can just check 'keymgr_direct_dep()'.

In 'dns_keymgr_run()', we want to make sure that there is no
dependency on the keys before retiring excess keys, so replace
'keymgr_key_is_successor()' with 'keymgr_dep()'.

(cherry picked from commit 600915d1b2)
2021-02-03 15:47:23 +01:00