Commit Graph

33306 Commits

Author SHA1 Message Date
Ondřej Surý
23c3bcc711 Stop including dnstap headers from <dns/dnstap.h>
The <fstrm.h> and <protobuf-c/protobuf-c.h> headers are only directly
included where used and we stopped exposing those headers from libdns
headers.
2021-02-16 01:04:46 +00:00
Ondřej Surý
dce292e7f4 Stop including lmdb.h from <dns/view.h>
The lmdb.h doesn't have to be included from the dns/view.h header as it
is separately included where used.  This stops exposing the inclusion of
lmdb.h from the libdns headers.
2021-02-16 01:04:46 +00:00
Ondřej Surý
d1448a4c2a Move the <isc/readline.h> header to bin/dig/readline.h
The <isc/readline.h> header provided a compatibility shim to use when
other non-GNU readline libraries are in use.  The two places where
readline library is being used is nslookup and nsupdate, so the header
file has been moved to bin/dig directory and it's directly included from
bin/nsupdate.

This also conceals any readline headers exposed from the libisc headers.
2021-02-16 01:04:46 +00:00
Ondřej Surý
00b5f4c389 Remove the extra CFLAGS from libisc_CFLAGS and libdns_CFLAGS
The extra library CFLAGS were causing the headers to be included in
wrong order possibly pulling header files from previously installed
BIND 9 version.

This commit cleans up the extra <foo>_CFLAGS from the includes in favor
of not exposing 3rd party headers in our own header files.
2021-02-16 01:04:46 +00:00
Diego dos Santos Fronza
5f1a76c710 Merge branch '2041-bug-reconfig-auto-dnssec-high-thread-number-leak-resources-and-crash-named' into 'main'
Resolve "BUG reconfig+auto-dnssec+high thread number leak resources and crash named"

Closes #2041

See merge request isc-projects/bind9!4669
2021-02-15 18:12:17 +00:00
Diego Fronza
757be6ec16 Add CHANGES note for [GL #2041] 2021-02-15 12:02:31 -03:00
Diego Fronza
43b0b20b43 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:15:20 -03:00
Diego Fronza
30729c7013 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:15:20 -03:00
Michal Nowak
fe6bd687d7 Merge branch 'mnowak/merge-skipped-and-untested-system-test-results' into 'main'
Merge UNTESTED and SKIPPED system test results

See merge request isc-projects/bind9!4517
2021-02-15 11:52:46 +00:00
Michal Nowak
3cc3f1712b Add CHANGES note for [GL !4517] 2021-02-15 11:20:18 +01:00
Michal Nowak
cfd0f7d2eb Do not build geoip_test when GeoIP is not available 2021-02-15 11:19:15 +01:00
Michal Nowak
fa505bfb0e Record skipped unit test as skipped in Automake framework 2021-02-15 11:18:03 +01:00
Michal Nowak
29d7c6e449 Merge UNTESTED and SKIPPED system test results
Descriptions of UNTESTED and SKIPPED system test results are very
similar to one another and it may be confusing when to pick one and
when the other. Merging these two system test results removes the
confusion and also makes system test more aligned with Automake,
which does not know about UNTESTED test result.
2021-02-15 11:15:20 +01:00
Michal Nowak
fbdd464038 Record skipped test as skipped in testsuite summary
When system test execution was ported to Automake, SKIPPED and UNTESTED
system test result were not made to match Automake expectations,
therefore a skipped test is recorded by Automake as "PASS":

    $ make check TESTS=cpu V=1
    I:cpu:cpu test only runs on Linux, skipping test
    I:cpu:Prerequisites missing, skipping test.
    R:cpu:SKIPPED
    E:cpu:2020-12-16T11:36:58+0000
    PASS: cpu
    ====================================================================
    Testsuite summary for BIND 9.17.7
    ====================================================================
    # TOTAL: 1
    # PASS:  1

For a test to be recorded by Automake as skipped, the test, or it's test
driver, needs to exit with code 77:

    $ make check TESTS=cpu V=1
    I:cpu:cpu test only runs on Linux, skipping test
    I:cpu:Prerequisites missing, skipping test.
    R:cpu:SKIPPED
    E:cpu:2020-12-16T11:39:10+0000
    SKIP: cpu
    ====================================================================
    Testsuite summary for BIND 9.17.7
    ====================================================================
    # TOTAL: 1
    # PASS:  0
    # SKIP:  1
2021-02-15 11:15:20 +01:00
Mark Andrews
8c1df63312 Merge branch '2443-cid-316608-memory-corruptions-overrun' into 'main'
Resolve "CID 316608:  Memory - corruptions  (OVERRUN)"

Closes #2443

See merge request isc-projects/bind9!4623
2021-02-14 23:02:44 +00:00
Mark Andrews
59bf6e71e2 Address theoretical buffer overrun in recent change
The strlcat() call was wrong.

    *** CID 316608:  Memory - corruptions  (OVERRUN)
    /lib/dns/resolver.c: 5017 in fctx_create()
    5011     	 * Make fctx->info point to a copy of a formatted string
    5012     	 * "name/type".
    5013     	 */
    5014     	dns_name_format(name, buf, sizeof(buf));
    5015     	dns_rdatatype_format(type, typebuf, sizeof(typebuf));
    5016     	p = strlcat(buf, "/", sizeof(buf));
    >>>     CID 316608:  Memory - corruptions  (OVERRUN)
    >>>     Calling "strlcat" with "buf + p" and "1036UL" is suspicious because "buf" points into a buffer of 1036 bytes and the function call may access "(char *)(buf + p) + 1035UL". [Note: The source code implementation of the function has been overridden by a builtin model.]
    5017     	strlcat(buf + p, typebuf, sizeof(buf));
    5018     	fctx->info = isc_mem_strdup(mctx, buf);
    5019
    5020     	FCTXTRACE("create");
    5021     	dns_name_init(&fctx->name, NULL);
    5022     	dns_name_dup(name, mctx, &fctx->name);
2021-02-14 22:41:46 +00:00
Petr Špaček
1d1408567f Merge branch 'pspacek/ci-python-allthetime' into 'main'
Run Python linters in CI even outside of merge requests

See merge request isc-projects/bind9!4540
2021-02-12 13:23:47 +00:00
Petr Špaček
74d7cddc4c Run Python linters in CI even outside of merge requests
Previously it did not get run on scheduled CI pipelines.
2021-02-12 14:21:23 +01:00
Michal Nowak
11df3ef0c3 Merge branch 'mnowak/check-for-unrecognized-options' into 'main'
Check for unrecognized configure options

See merge request isc-projects/bind9!4567
2021-02-12 13:14:41 +00:00
Michal Nowak
4295c82e45 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.
2021-02-12 13:56:38 +01:00
Michal Nowak
40600d6bf6 Merge branch '2312-lint-generated-manual-pages' into 'main'
Lint manual pages

Closes #2312

See merge request isc-projects/bind9!4475
2021-02-12 11:54:18 +00:00
Michal Nowak
22fdcb30db 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.
2021-02-12 12:15:02 +01:00
Michal Nowak
2a8b4f2a79 Build man pages when "make doc" is run
Man pages are currently only generated from reStructuredText sources
when "make man" is run in the doc/man/ directory.  Tweak
doc/man/Makefile.am so that running "make doc" in the top-level
directory also causes man pages to be generated, so that all potential
documentation building problems can be detected by a single make
invocation.
2021-02-12 12:15:01 +01:00
Mark Andrews
5750f89351 Merge branch '2421-cid-316509-untrusted-value-as-argument-tainted_scalar' into 'main'
Resolve "CID 316509: Untrusted value as argument (TAINTED_SCALAR)"

Closes #2423 and #2421

See merge request isc-projects/bind9!4606
2021-02-11 23:39:18 +00:00
Mark Andrews
c40133d840 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);
2021-02-12 10:19:27 +11:00
Mark Andrews
fd8d1337a5 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
2021-02-12 10:19:21 +11:00
Michal Nowak
698d6372aa Merge branch 'mnowak/enable-libns-tests-to-run-under-asan' into 'main'
Drop AddressSanitizer constraint from libns unit tests

See merge request isc-projects/bind9!4622
2021-02-10 10:02:16 +00:00
Michal Nowak
613be8706e 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.
2021-02-10 09:54:32 +00:00
Mark Andrews
1c428cc157 Merge branch '2460-incorrect-size-passed-to-isc_mem_put' into 'main'
Resolve "Incorrect size passed to isc_mem_put"

Closes #2460

See merge request isc-projects/bind9!4633
2021-02-09 12:49:38 +00:00
Mark Andrews
7a47262626 Add release note for [GL #2460] 2021-02-09 12:30:14 +00:00
Mark Andrews
bef5e723b2 Add CHANGES note for [GL #2460] 2021-02-09 12:30:14 +00:00
Mark Andrews
0a966315b2 Fix wrong length passed to isc_mem_put
If an invalid key name (e.g. "a..b") in a primaries list in named.conf
is specified the wrong size is passed to isc_mem_put resulting in the
returned memory being put on the wrong freed list.

    *** CID 316784:  Incorrect expression  (SIZEOF_MISMATCH)
    /bin/named/config.c: 636 in named_config_getname()
    630     	isc_buffer_constinit(&b, objstr, strlen(objstr));
    631     	isc_buffer_add(&b, strlen(objstr));
    632     	dns_fixedname_init(&fname);
    633     	result = dns_name_fromtext(dns_fixedname_name(&fname), &b, dns_rootname,
    634     				   0, NULL);
    635     	if (result != ISC_R_SUCCESS) {
       CID 316784:  Incorrect expression  (SIZEOF_MISMATCH)
       Passing argument "*namep" of type "dns_name_t *" and argument "8UL /* sizeof (*namep) */" to function "isc__mem_put" is suspicious.
    636     		isc_mem_put(mctx, *namep, sizeof(*namep));
    637     		*namep = NULL;
    638     		return (result);
    639     	}
    640     	dns_name_dup(dns_fixedname_name(&fname), mctx, *namep);
    641
2021-02-09 12:30:14 +00:00
Matthijs Mekking
5c0847e997 Merge branch '1810-refactor-ecdsa-eddsa-system-tests' into 'main'
Resolve "Refactor ecdsa and eddsa tests after testcrypto.sh changes"

Closes #1810

See merge request isc-projects/bind9!4645
2021-02-09 11:59:20 +00:00
Matthijs Mekking
51827ddcd3 Update copyrights for [#1810] 2021-02-09 11:59:08 +00:00
Matthijs Mekking
650b0d4691 Refactor ecdsa system test
Similar to eddsa system test.
2021-02-09 11:59:08 +00:00
Matthijs Mekking
fd7d0f7968 Enable eddsa test
It should be fixed now.
2021-02-09 11:59:08 +00:00
Matthijs Mekking
8bf31d0592 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/.
2021-02-09 11:59:08 +00:00
Matthijs Mekking
572d7ec3b7 Fix testcrypto.sh
Testing Ed448 was actually testing Ed25519.
2021-02-09 11:59:08 +00:00
Michal Nowak
e74187a056 Merge branch 'mnowak/drop-kyua-references-in-.gitlab-ci.yml' into 'main'
Remove remnant Kyua references

See merge request isc-projects/bind9!4638
2021-02-09 11:48:07 +00:00
Michal Nowak
f557480078 Remove remnant Kyua references
Unit tests were ported from Kyua to Automake.  All references to Kyua
thus should be removed from the main branch.
2021-02-09 12:45:53 +01:00
Michal Nowak
566b65e513 Merge branch 'mnowak/check-asan-errors-in-configure' into 'main'
Check config.log for ASAN errors

See merge request isc-projects/bind9!4655
2021-02-09 11:02:20 +00:00
Michal Nowak
0db934d401 Check config.log for ASAN errors
./configure checks might produce a false negative error due to ASAN
errors and thus disable some options.
2021-02-09 11:56:08 +01:00
Matthijs Mekking
8dd1106bda Merge branch '2434-fetch-limit-serve-stale-follow-up' into 'main'
Resolve "Serve stale when fetch limits are hit" (follow-up)

Closes #2434

See merge request isc-projects/bind9!4654
2021-02-08 15:01:07 +00:00
Matthijs Mekking
00f575e7ef 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.
2021-02-08 15:17:09 +01:00
Matthijs Mekking
8bcd7fe69e 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.
2021-02-08 15:17:09 +01:00
Mark Andrews
a415424339 Merge branch '2469-cid-281461-untrusted-loop-bound' into 'main'
Resolve "CID 281461: untrusted loop bound"

Closes #2469

See merge request isc-projects/bind9!4642
2021-02-08 02:55:31 +00:00
Mark Andrews
2f946c831a 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        }
2021-02-08 02:02:29 +00:00
Michal Nowak
64d5dad92a Merge branch 'mnowak/check-arm-pdf-validity' into 'main'
Check PDF file structure with QPDF

See merge request isc-projects/bind9!4620
2021-02-03 16:41:06 +00:00
Michal Nowak
359708b9d6 Check PDF file structure with QPDF
"qpdf --check" checks file structure of generated ARM PDF.
2021-02-03 17:39:58 +01:00
Matthijs Mekking
3648eb2936 Merge branch '2377-allow-a-records-below-an-_spf-label-as-a-check-names-exception' into 'main'
Resolve "Allow A records below an '_spf' label as a check-names exception"

Closes #2377

See merge request isc-projects/bind9!4529
2021-02-03 16:38:48 +00:00