]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
3 years agoFix named failing to start on Solaris systems with hundreds of CPUs
Artem Boldariev [Wed, 19 Oct 2022 12:26:48 +0000 (15:26 +0300)] 
Fix named failing to start on Solaris systems with hundreds of CPUs

This commit fixes a startup issue on Solaris systems with
many (reportedly > 510) CPUs by bumping RLIMIT_NOFILE. This appears to
be a regression from 9.11.

3 years agoMerge branch '3270-use-curl-in-statschannel-system-test' into 'main'
Ondřej Surý [Thu, 20 Oct 2022 12:00:54 +0000 (12:00 +0000)] 
Merge branch '3270-use-curl-in-statschannel-system-test' into 'main'

Replace raw nc usage in statschannel system test with curl

Closes #3270

See merge request isc-projects/bind9!6946

3 years agoReplace some raw nc usage in statschannel system test with curl
Ondřej Surý [Tue, 18 Oct 2022 19:46:16 +0000 (21:46 +0200)] 
Replace some raw nc usage in statschannel system test with curl

For tests where the TCP connection might get interrupted abruptly,
replace the nc with curl as the data sent from server to client might
get lost because of abrupt TCP connection.  This happens when the TCP
connection gets closed during sending the large request to the server.

As we already require curl for other system tests, replace the nc usage
in the statschannel test with curl that actually understands the
HTTP/1.1 protocol, so the same connection is reused for sending the
consequtive requests, but without client-side "pipelining".

For the record, the server doesn't support parallel processing of the
pipelined request, so it's a bit misnomer here, because what we are
actually testing is that we process all requests received in a single
TCP read callback.

3 years agoMerge tag 'v9_19_6'
Michal Nowak [Thu, 20 Oct 2022 09:01:27 +0000 (11:01 +0200)] 
Merge tag 'v9_19_6'

BIND 9.19.6

3 years agoMerge branch '3247-rpz-ip-cd' into 'main'
Evan Hunt [Wed, 19 Oct 2022 20:11:26 +0000 (20:11 +0000)] 
Merge branch '3247-rpz-ip-cd' into 'main'

ensure RPZ lookups handle CD=1 correctly

Closes #3247

See merge request isc-projects/bind9!6944

3 years agoCHANGES for [GL #3247]
Evan Hunt [Tue, 18 Oct 2022 23:39:04 +0000 (16:39 -0700)] 
CHANGES for [GL #3247]

3 years agoadd a test with CD=1 query for pending data
Evan Hunt [Tue, 18 Oct 2022 23:37:07 +0000 (16:37 -0700)] 
add a test with CD=1 query for pending data

this is a regression test for [GL #3247].

3 years agoensure RPZ lookups handle CD=1 correctly
Evan Hunt [Tue, 18 Oct 2022 20:48:52 +0000 (13:48 -0700)] 
ensure RPZ lookups handle CD=1 correctly

RPZ rewrites called dns_db_findext() without passing through the
client database options; as as result, if the client set CD=1,
DNS_DBFIND_PENDINGOK was not used as it should have been, and
cache lookups failed, resulting in failure of the rewrite.

3 years agoMerge branch '3270-serialize-statschannel-http-requests' into 'main'
Ondřej Surý [Wed, 19 Oct 2022 12:47:06 +0000 (12:47 +0000)] 
Merge branch '3270-serialize-statschannel-http-requests' into 'main'

Serialize the HTTP/1.1 statschannel requests

Closes #3270

See merge request isc-projects/bind9!6954

3 years agoSerialize the HTTP/1.1 statschannel requests
Ondřej Surý [Tue, 18 Oct 2022 19:46:16 +0000 (21:46 +0200)] 
Serialize the HTTP/1.1 statschannel requests

The statschannel truncated test still terminates abruptly sometimes and
it doesn't return the answer for the first query.  This might happen
when the second process_request() discovers there's not enough space
before the sending is complete and the connection is terminated before
the client gets the data.

Change the isc_http, so it pauses the reading when it receives the data
and resumes it only after the sending has completed or there's
incomplete request waiting for more data.

This makes the request processing slightly less efficient, but also less
taxing for the server, because previously all requests that has been
received via single TCP read would be processed in the loop and the
sends would be queued after the read callback has processed a full
buffer.

3 years agoMerge branch '3612-fix-mem-functions-with-openssl-1.0.2' into 'main'
Ondřej Surý [Wed, 19 Oct 2022 12:42:20 +0000 (12:42 +0000)] 
Merge branch '3612-fix-mem-functions-with-openssl-1.0.2' into 'main'

Fix the non-developer build with OpenSSL 1.0.2

Closes #3612

See merge request isc-projects/bind9!6952

3 years agoFix the non-developer build with OpenSSL 1.0.2
Ondřej Surý [Wed, 19 Oct 2022 12:13:26 +0000 (14:13 +0200)] 
Fix the non-developer build with OpenSSL 1.0.2

In non-developer build, a wrong condition prevented the
isc__tls_malloc_ex, isc__tls_realloc_ex and isc__tls_free_ex to be
defined.  This was causing FTBFS on platforms with OpenSSL 1.0.2.

3 years agoMerge branch '3270-remove-time-requirement-for-statschannel-truncated-test' into...
Ondřej Surý [Wed, 19 Oct 2022 12:35:38 +0000 (12:35 +0000)] 
Merge branch '3270-remove-time-requirement-for-statschannel-truncated-test' into 'main'

Remove the time requirement for the statschannel truncated test

Closes #3270

See merge request isc-projects/bind9!6951

3 years agoRemove the time requirement for the statschannel truncated test
Ondřej Surý [Wed, 19 Oct 2022 11:52:09 +0000 (13:52 +0200)] 
Remove the time requirement for the statschannel truncated test

The 5 seconds requirement to finish the 'pipelined with truncated
stream' was causing spurious failures in the CI because the job runners
might be very busy and sending 128k of data might simply take some time.

Remove the time requirement altogether, there's actually no reason why
the test SHOULD or even MUST finish under 5 seconds.

3 years agoMerge branch 'tkrizek/system-tests-fixes' into 'main'
Tom Krizek [Wed, 19 Oct 2022 11:01:26 +0000 (11:01 +0000)] 
Merge branch 'tkrizek/system-tests-fixes' into 'main'

Update various system tests and add them to default test suite

See merge request isc-projects/bind9!6942

3 years agoRemove generated controls.conf file from system tests
Tom Krizek [Fri, 7 Oct 2022 14:23:56 +0000 (16:23 +0200)] 
Remove generated controls.conf file from system tests

The controls.conf file shouldn't be used directly without templating it
first. Remove this no longer used hard-coded file to avoid confusion.

3 years agoRevive dupsigs system test
Tom Krizek [Tue, 18 Oct 2022 15:16:27 +0000 (17:16 +0200)] 
Revive dupsigs system test

Correctly source conf.sh in dupsigs test scripts (fix issue introduced
by 093af1c00ac25e4f132fe2442a24e1264aadb28d).

Update dupsigs test for dnssec-dnskey-kskonly default. Since v9.17.20,
the dnssec-dnskey-kskonly is set to yes. Update the test to not expect
the additional RRSIG with ZSK for DNSKEY.

Speed up the test from 20 minutes to 2.5 minutes and make it part of the
default test suite executed in CI.
- decrease number of records to sign from 2000 to 500
- decrease the signing interval by a factor of 6
- shorten the final part of the test after last signing (since nothing
  new happens there)

Finally, clarify misleading comments about (in)sufficient time for zone
re-signing. The time used in the test is in fact sufficient for the
re-signing to happen. If it wasn't, the previous ZSK would end up being
deleted while its signatures would still be present, which is a
situation where duplicate signatures can still happen.

3 years agoRevive the stress system test
Tom Krizek [Fri, 14 Oct 2022 14:59:50 +0000 (16:59 +0200)] 
Revive the stress system test

Ensure the port numbers are dynamically filled in with copy_setports.

Clarify test fail condition.

Make the stress test part of the default test suite since it doesn't
seem to run too long or interfere with other tests any more (the
original note claiming so is more than 20 years old).

Related !6883

3 years agoRevive dialup system test
Tom Krizek [Mon, 10 Oct 2022 15:21:41 +0000 (17:21 +0200)] 
Revive dialup system test

Properly template the port number in config files with copy_setports.

The test takes two minutes on my machine which doesn't seem like a
proper justification to exclude it from the test suite, especially
considering we run these tests in parallel nowadays. The resource usage
doesn't seems significantly increased so it shouldn't interfere with
other system tests.

There also exists a precedent for longer running system tests that are
already part of the default system test suite (e.g. serve-stale takes
almost three minutes on the same machine).

3 years agoMake digdelv test work in different network envs
Tom Krizek [Wed, 5 Oct 2022 13:59:13 +0000 (15:59 +0200)] 
Make digdelv test work in different network envs

When a target server is unreachable, the varying network conditions may
cause different ICMP message (or no message). The host unreachable
message was discovered when attempting to run the test locally while
connected to a VPN network which handles all traffic.

Extend the dig output check with "host unreachable" message to avoid a
false negative test result in certain network environments.

3 years agoMerge branch '3394-cve-2022-2795-test' into 'main'
Michal Nowak [Wed, 19 Oct 2022 10:31:56 +0000 (10:31 +0000)] 
Merge branch '3394-cve-2022-2795-test' into 'main'

Add tests for CVE-2022-2795

Closes #3394

See merge request isc-projects/bind9!6945

3 years agoAdd tests for CVE-2022-2795
Michał Kępień [Tue, 6 Sep 2022 11:36:44 +0000 (13:36 +0200)] 
Add tests for CVE-2022-2795

Add a test ensuring that the amount of work fctx_getaddresses() performs
for any encountered delegation is limited: delegate example.net to a set
of 1,000 name servers in the redirect.com zone, the names of which all
resolve to IP addresses that nothing listens on, and query for a name in
the example.net domain, checking the number of times the findname()
function gets executed in the process; fail if that count is excessively
large.

Since the size of the referral response sent by ans3 is about 20 kB, it
cannot be sent back over UDP (EMSGSIZE) on some operating systems in
their default configuration (e.g. FreeBSD - see the
net.inet.udp.maxdgram sysctl).  To enable reliable reproduction of
CVE-2022-2795 (retry patterns vary across BIND 9 versions) and avoid
false positives at the same time (thread scheduling - and therefore the
number of fetch context restarts - vary across operating systems and
across test runs), extend bin/tests/system/resolver/ans3/ans.pl so that
it also listens on TCP and make "ns1" in the "resolver" system test
always use TCP when communicating with "ans3".

Also add a test (foo.bar.sub.tld1/TXT) that ensures the new limitations
imposed on the resolution process by the mitigation for CVE-2022-2795 do
not prevent valid, glueless delegation chains from working properly.

3 years agoMerge branch 'artem-tls-listener-shutdown-accept-crash-fix' into 'main'
Artem Boldariev [Tue, 18 Oct 2022 15:58:14 +0000 (15:58 +0000)] 
Merge branch 'artem-tls-listener-shutdown-accept-crash-fix' into 'main'

[Backport] TLS Stream: handle successful TLS handshake after listener shutdown

See merge request isc-projects/bind9!6938

3 years agoTLS Stream: handle successful TLS handshake after listener shutdown
Artem Boldariev [Tue, 18 Oct 2022 11:42:10 +0000 (14:42 +0300)] 
TLS Stream: handle successful TLS handshake after listener shutdown

It was possible that accept callback can be called after listener
shutdown. In such a case the callback pointer equals NULL, leading to
segmentation fault. This commit fixes that.

3 years agoMerge branch '3493-compression-buffer-reuse-test' into 'main'
Michal Nowak [Tue, 18 Oct 2022 15:18:54 +0000 (15:18 +0000)] 
Merge branch '3493-compression-buffer-reuse-test' into 'main'

[CVE-2022-2881] test for growth of compressed pipelined responses

See merge request isc-projects/bind9!6933

3 years agotest for growth of compressed pipelined responses
Evan Hunt [Wed, 17 Aug 2022 19:46:02 +0000 (12:46 -0700)] 
test for growth of compressed pipelined responses

add a test to compare the Content-Length of successive compressed
messages on a single HTTP connection that should contain the same
data; fail if the size grows by more than 100 bytes from one query
to the next.

3 years agoMerge branch 'matthijs-fix-dnssec-signing-log-lovel' into 'main'
Matthijs Mekking [Tue, 18 Oct 2022 14:25:19 +0000 (14:25 +0000)] 
Merge branch 'matthijs-fix-dnssec-signing-log-lovel' into 'main'

Change log level when doing rekey

See merge request isc-projects/bind9!6913

3 years agoChange log level when doing rekey
Matthijs Mekking [Fri, 14 Oct 2022 14:38:25 +0000 (16:38 +0200)] 
Change log level when doing rekey

This log happens when BIND checks the parental-agents if the DS has
been published. But if you don't have parental-agents set up, the list
of keys to check will be empty and the result will be ISC_R_NOTFOUND.
This is not an error, so change the log level to debug in this case.

3 years agoMerge branch 'pspacek/cookie-test-no-developer-fixup' into 'main'
Petr Špaček [Tue, 18 Oct 2022 12:22:34 +0000 (12:22 +0000)] 
Merge branch 'pspacek/cookie-test-no-developer-fixup' into 'main'

Fix cookie system test for builds without --enable-developer

See merge request isc-projects/bind9!6904

3 years agoFix cookie system test for builds without --enable-developer
Petr Špaček [Thu, 13 Oct 2022 15:38:23 +0000 (17:38 +0200)] 
Fix cookie system test for builds without --enable-developer

The "connecting via TCP" message comes from FCTXTRACE which is not
available on some builds.

3 years agoMerge branch 'pspacek/ci-no-developer-mode' into 'main'
Petr Špaček [Tue, 18 Oct 2022 11:51:23 +0000 (11:51 +0000)] 
Merge branch 'pspacek/ci-no-developer-mode' into 'main'

Add CI job with --disable-developer

See merge request isc-projects/bind9!6930

3 years agoAllow system tests to run under root user when inside CI
Petr Špaček [Fri, 14 Oct 2022 13:01:19 +0000 (15:01 +0200)] 
Allow system tests to run under root user when inside CI

https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
says variable CI_SERVER="yes" is available in all versions of Gitlab.

3 years agoBuild gcc:oraclelinux9:amd64 CI jobs with --disable-developer
Petr Špaček [Thu, 13 Oct 2022 15:49:36 +0000 (17:49 +0200)] 
Build gcc:oraclelinux9:amd64 CI jobs with --disable-developer

Purpose of this is to guard against tests which rely on querytrace or
other optional features enabled by --enable-developer switch.

3 years agoMerge branch 'ondrej-add-ISC_LIST,LINK_INITIALIZER' into 'main'
Ondřej Surý [Tue, 18 Oct 2022 11:18:04 +0000 (11:18 +0000)] 
Merge branch 'ondrej-add-ISC_LIST,LINK_INITIALIZER' into 'main'

Add ISC_{LIST,LINK}_INITIALIZER for designated initializers

See merge request isc-projects/bind9!6928

3 years agoReplace (void *)-1 with ISC_LINK_TOMBSTONE
Ondřej Surý [Tue, 18 Oct 2022 09:28:03 +0000 (11:28 +0200)] 
Replace (void *)-1 with ISC_LINK_TOMBSTONE

Instead of having "arbitrary" (void *)-1 to define non-linked, add a
ISC_LINK_TOMBSTONE(type) macro that replaces the "magic" value with a
define.

3 years agoAdd ISC_{LIST,LINK}_INITIALIZER for designated initializers
Ondřej Surý [Tue, 18 Oct 2022 09:15:57 +0000 (11:15 +0200)] 
Add ISC_{LIST,LINK}_INITIALIZER for designated initializers

Since we are using designated initializers, we were missing initializers
for ISC_LIST and ISC_LINK, add them, so you can do

    *foo = (foo_t){ .list = ISC_LIST_INITIALIZER };

Instead of:

    *foo = (foo_t){ 0 };
    ISC_LIST_INIT(foo->list);

3 years agoMerge branch 'artem-sync-multilayer-stoplistening' into 'main'
Artem Boldariev [Tue, 18 Oct 2022 09:32:25 +0000 (09:32 +0000)] 
Merge branch 'artem-sync-multilayer-stoplistening' into 'main'

Synchronise stop listening operation for multi-layer transports

Closes #3606

See merge request isc-projects/bind9!6917

3 years agoSynchronise stop listening operation for multi-layer transports
Artem Boldariev [Fri, 14 Oct 2022 17:45:40 +0000 (20:45 +0300)] 
Synchronise stop listening operation for multi-layer transports

This commit introduces a primitive isc__nmsocket_stop() which performs
shutting down on a multilayered socket ensuring the proper order of
the operations.

The shared data within the socket object can be destroyed after the
call completed, as it is guaranteed to not be used from within the
context of other worker threads.

3 years agoMerge branch '3584-placeholder' into 'main'
Arаm Sаrgsyаn [Tue, 18 Oct 2022 08:51:46 +0000 (08:51 +0000)] 
Merge branch '3584-placeholder' into 'main'

Add a CHANGES placeholder for [GL #3584]

See merge request isc-projects/bind9!6927

3 years agoAdd a CHANGES placeholder for [GL #3584]
Aram Sargsyan [Tue, 18 Oct 2022 08:28:53 +0000 (08:28 +0000)] 
Add a CHANGES placeholder for [GL #3584]

3 years agoMerge branch 'pspacek/doc-nsupdate-server-gsstsig' into 'main'
Petr Špaček [Tue, 18 Oct 2022 08:12:47 +0000 (08:12 +0000)] 
Merge branch 'pspacek/doc-nsupdate-server-gsstsig' into 'main'

Document that nsupdate ignores server command in GSS-TSIG mode

See merge request isc-projects/bind9!6878

3 years agoDocument that nsupdate ignores server command in GSS-TSIG mode
Petr Špaček [Fri, 7 Oct 2022 11:40:05 +0000 (13:40 +0200)] 
Document that nsupdate ignores server command in GSS-TSIG mode

This behavior is present since introduction of GSS-TSIG support,
commit 289ae548d52bc8f982d9823af64cafda7bd92232.

3 years agoMerge branch 'fanf-deduplicate-file-line' into 'main'
Tony Finch [Mon, 17 Oct 2022 13:17:57 +0000 (13:17 +0000)] 
Merge branch 'fanf-deduplicate-file-line' into 'main'

De-duplicate __FILE__, __LINE__ plus some error reporting cleanup

See merge request isc-projects/bind9!6914

3 years agoCHANGES for [GL !6914]
Tony Finch [Fri, 14 Oct 2022 16:48:43 +0000 (17:48 +0100)] 
CHANGES for [GL !6914]

[cleanup] Less ceremonial UNEXPECTED_ERROR() and FATAL_ERROR()
reporting macros. [GL !6914]

3 years agoInclude the function name when reporting unexpected errors
Tony Finch [Fri, 14 Oct 2022 16:37:47 +0000 (17:37 +0100)] 
Include the function name when reporting unexpected errors

I.e. print the name of the function in BIND that called the system
function that returned an error. Since it was useful for pthreads
code, it seems worthwhile doing so everywhere.

3 years agoDe-duplicate some calls to strerror_r()
Tony Finch [Fri, 14 Oct 2022 16:18:07 +0000 (17:18 +0100)] 
De-duplicate some calls to strerror_r()

Specifically, when reporting an unexpected or fatal error.

3 years agoDe-duplicate __FILE__, __LINE__
Tony Finch [Fri, 14 Oct 2022 15:07:07 +0000 (16:07 +0100)] 
De-duplicate __FILE__, __LINE__

Mostly generated automatically with the following semantic patch,
except where coccinelle was confused by #ifdef in lib/isc/net.c

@@ expression list args; @@
- UNEXPECTED_ERROR(__FILE__, __LINE__, args)
+ UNEXPECTED_ERROR(args)
@@ expression list args; @@
- FATAL_ERROR(__FILE__, __LINE__, args)
+ FATAL_ERROR(args)

3 years agoMerge branch 'aram/cfg_print_duration-uninitialized-length' into 'main'
Arаm Sаrgsyаn [Mon, 17 Oct 2022 09:15:13 +0000 (09:15 +0000)] 
Merge branch 'aram/cfg_print_duration-uninitialized-length' into 'main'

Fix a logical bug in cfg_print_duration()

See merge request isc-projects/bind9!6880

3 years agoHandle large numbers when parsing/printing a duration
Aram Sargsyan [Mon, 17 Oct 2022 08:45:45 +0000 (08:45 +0000)] 
Handle large numbers when parsing/printing a duration

The isccfg_duration_fromtext() function is truncating large numbers
to 32 bits instead of capping or rejecting them, i.e. 64424509445,
which is 0xf00000005, gets parsed as 32-bit value 5 (0x00000005).

Fail parsing a duration if any of its components is bigger than
32 bits. Using those kind of big numbers has no practical use case
for a duration.

The isccfg_duration_toseconds() function can overflow the 32 bit
seconds variable when calculating the duration from its component
parts.

To avoid that, use 64-bit calculation and return UINT32_MAX if the
calculated value is bigger than UINT32_MAX. Again, a number this big
has no practical use case anyway.

The buffer for the generated duration string is limited to 64 bytes,
which, in theory, is smaller than the longest possible generated
duration string.

Use 80 bytes instead, calculated by the '7 x (10 + 1) + 3' formula,
where '7' is the count of the duration's parts (year, month, etc.), '10'
is their maximum length when printed as a decimal number, '1' is their
indicator character (Y, M, etc.), and 3 is two more indicators (P and T)
and the terminating NUL character.

3 years agoAdd a CHANGES note for [GL !6880]
Aram Sargsyan [Mon, 17 Oct 2022 08:45:34 +0000 (08:45 +0000)] 
Add a CHANGES note for [GL !6880]

3 years agoFix an off-by-one error in cfg_print_duration()
Aram Sargsyan [Mon, 17 Oct 2022 08:45:26 +0000 (08:45 +0000)] 
Fix an off-by-one error in cfg_print_duration()

The cfg_print_duration() checks added previously in the 'duration_test'
unit test uncovered a bug in cfg_print_duration().

When calculating the current 'str' pointer of the generated text in the
buffer 'buf', it erroneously adds 1 byte to compensate for that part's
indicator character. For example, to add 12 minutes, it needs to add
2 + 1 = 3 characters, where 2 is the length of "12", and 1 is the length
of "M" (for minute). The mistake was that the length of the indicator
is already included in 'durationlen[i]', so there is no need to
calculate it again.

In the result of this mistake the current pointer can advance further
than needed and end up after the zero-byte instead of right on it, which
essentially cuts off any further generated text. For example, for a
5 minutes and 30 seconds duration, instead of having this:

    'P', 'T', '5', 'M', '3', '0', 'S', '\0'

The function generates this:

    'P', 'T', '5', 'M', '\0', '3', '0', 'S', '\0'

Fix the bug by adding to 'str' just 'durationlen[i]' instead of
'durationlen[i] + 1'.

3 years agoTest cfg_print_duration() in duration_test.c
Aram Sargsyan [Mon, 17 Oct 2022 08:45:18 +0000 (08:45 +0000)] 
Test cfg_print_duration() in duration_test.c

Currently the 'duration_test' unit test checks only the
cfg_obj_asduration() function.

Extend the test so it checks also the reverse operation using the
cfg_print_duration() function, which is used in named-checkconf.

3 years agoFix a logical bug in cfg_print_duration()
Aram Sargsyan [Mon, 17 Oct 2022 08:45:09 +0000 (08:45 +0000)] 
Fix a logical bug in cfg_print_duration()

The cfg_print_duration() function prints a ISO 8601 duration value
converted from an array of integers, where the parts of the date and
time are stored.

durationlen[6], which holds the "seconds" part of the duration, has
a special case in cfg_print_duration() to ensure that when there are
no values in the duration, the result still can be printed as "PT0S",
instead of just "P", so it can be a valid ISO 8601 duration value.

There is a logical error in one of the two special case code paths,
when it checks that no value from the "date" part is defined, and no
"hour" or "minute" from the "time" part are defined.

Because of the error, durationlen[6] can be used uninitialized, in
which case the second parameter passed to snprintf() (which is the
maximum allowed length) can contain a garbage value.

This can not be exploited because the buffer is still big enough to
hold the maximum possible amount of characters generated by the "%u%c"
format string.

Fix the logical bug, and initialize the 'durationlen' array to zeros
to be a little safer from other similar errors.

3 years agoMerge branch 'mnowak/fix-grep-3.8-warnings' into 'main'
Ondřej Surý [Mon, 17 Oct 2022 07:09:16 +0000 (07:09 +0000)] 
Merge branch 'mnowak/fix-grep-3.8-warnings' into 'main'

Fix GNU Grep 3.8 warnings

See merge request isc-projects/bind9!6786

3 years agoAdd CI check for Grep warnings
Michal Nowak [Fri, 16 Sep 2022 10:05:46 +0000 (12:05 +0200)] 
Add CI check for Grep warnings

3 years agoReplace fgrep and egrep with grep -F/-E
Michal Nowak [Fri, 16 Sep 2022 10:13:52 +0000 (12:13 +0200)] 
Replace fgrep and egrep with grep -F/-E

GNU Grep 3.8 reports the following warnings:

    egrep: warning: egrep is obsolescent; using grep -E
    fgrep: warning: fgrep is obsolescent; using grep -F

3 years agoRemove stray backslashes
Michal Nowak [Fri, 16 Sep 2022 09:50:37 +0000 (11:50 +0200)] 
Remove stray backslashes

GNU Grep 3.8 reports several instances of stray backslashes in matching
patterns:

    grep: warning: stray \ before /
    grep: warning: stray \ before :

3 years agoMerge branch 'fanf-compress-smaller' into 'main'
Ondřej Surý [Mon, 17 Oct 2022 07:00:39 +0000 (07:00 +0000)] 
Merge branch 'fanf-compress-smaller' into 'main'

Simplify and speed up DNS name compression

See merge request isc-projects/bind9!6517

3 years agoCHANGES note for [GL !6517]
Tony Finch [Thu, 30 Jun 2022 16:19:54 +0000 (17:19 +0100)] 
CHANGES note for [GL !6517]

[performance] A new algorithm for DNS name compression based on a
hash set of message offsets. Name compression is now
more complete as well as being generally faster, and
the implementation is less complicated and requires
much less memory.

3 years agoA couple of compression microbenchmarks
Tony Finch [Sat, 25 Jun 2022 14:29:54 +0000 (15:29 +0100)] 
A couple of compression microbenchmarks

The `render` benchmark loads some binary DNS message dumps and
repeatedly passes them to `dns_message_render`.

The `compress` benchmark loads a list of domain names and packs them
into 4KiB chunks using `dns_name_towire`.

3 years agoTest compression context hash set collisions
Tony Finch [Fri, 16 Sep 2022 17:55:48 +0000 (18:55 +0100)] 
Test compression context hash set collisions

Check that names are correctly added and deleted in the compression
context. Use many names with differing numerical prefixes to make it
relatively easy to identify and debug problems.

3 years agoSimplify and speed up DNS name compression
Tony Finch [Thu, 23 Jun 2022 20:53:46 +0000 (21:53 +0100)] 
Simplify and speed up DNS name compression

All we need for compression is a very small hash set of compression
offsets, because most of the information we need (the previously added
names) can be found in the message using the compression offsets.

This change combines dns_compress_find() and dns_compress_add() into
one function dns_compress_name() that both finds any existing suffix,
and adds any new prefix to the table. The old split led to performance
problems caused by duplicate names in the compression context.

Compression contexts are now either small or large, which the caller
chooses depending on the expected size of the message. There is no
dynamic resizing.

There is a behaviour change: compression now acts on all the labels in
each name, instead of just the last few.

A small benchmark suggests this is about 2x faster.

3 years agoMerge branch 'artem-isc_nmsocket_set_tlsctx-loopmgr-fix' into 'main'
Artem Boldariev [Sun, 16 Oct 2022 21:50:51 +0000 (21:50 +0000)] 
Merge branch 'artem-isc_nmsocket_set_tlsctx-loopmgr-fix' into 'main'

Fix isc_nmsocket_set_tlsctx() broken during loopmgr refactroing

See merge request isc-projects/bind9!6915

3 years agoFix isc_nmsocket_set_tlsctx()
Artem Boldariev [Fri, 14 Oct 2022 18:36:51 +0000 (21:36 +0300)] 
Fix isc_nmsocket_set_tlsctx()

During loop manager refactoring isc_nmsocket_set_tlsctx() was not
properly adapted. The function is expected to broadcast the new TLS
context for every worker, but this behaviour was accidentally broken.

3 years agoMerge branch 'ondrej-pthread_once-runtime-check' into 'main'
Ondřej Surý [Fri, 14 Oct 2022 14:40:31 +0000 (14:40 +0000)] 
Merge branch 'ondrej-pthread_once-runtime-check' into 'main'

Improve reporting for pthread_once errors

See merge request isc-projects/bind9!6910

3 years agoImprove reporting for pthread_once errors
Ondřej Surý [Fri, 14 Oct 2022 14:10:41 +0000 (16:10 +0200)] 
Improve reporting for pthread_once errors

Replace all uses of RUNTIME_CHECK() in lib/isc/include/isc/once.h with
PTHEADS_RUNTIME_CHECK(), in order to improve error reporting for any
once-related run-time failures (by augmenting error messages with
file/line/caller information and the error string corresponding to
errno).

3 years agoMerge branch 'tkrizek/remove-system-test-delzone' into 'main'
Tom Krizek [Fri, 14 Oct 2022 14:37:39 +0000 (14:37 +0000)] 
Merge branch 'tkrizek/remove-system-test-delzone' into 'main'

Remove system test delzone

See merge request isc-projects/bind9!6882

3 years agoRemove system test delzone
Tom Krizek [Mon, 10 Oct 2022 11:28:29 +0000 (13:28 +0200)] 
Remove system test delzone

There are multiple reasons to remove this test as obsolete:

- The test may not possibly work for over 2.5 years, since
  98b3b93791777218c04a67ddaef22619162249f7 removed the rndc.py python
  tool on which this test relies.
- It isn't part of the test suite either in CI or locally unless it is
  explicitly enabled. As a result, there are many issues which prevent
  the test from being executed caused by various refactoring efforts
  accumulated over time.
- Even if the test could be executed, it has no clear failure condition.
  If the python script(s) fail, the test still passes.

3 years agoMerge branch 'ondrej-refactor-isc_httpd' into 'main'
Ondřej Surý [Fri, 14 Oct 2022 10:23:21 +0000 (10:23 +0000)] 
Merge branch 'ondrej-refactor-isc_httpd' into 'main'

Rewrite isc_httpd using picohttpparser and isc_url_parse

See merge request isc-projects/bind9!6879

3 years agoAdd CHANGES note for [GL !6879]
Ondřej Surý [Fri, 7 Oct 2022 13:58:43 +0000 (15:58 +0200)] 
Add CHANGES note for [GL !6879]

3 years agoReplace the statschannel truncated tests with two new tests
Ondřej Surý [Thu, 6 Oct 2022 10:56:25 +0000 (12:56 +0200)] 
Replace the statschannel truncated tests with two new tests

Now that the artificial limit on the recv buffer has been removed, the
current system test always fails because it tests if the truncation has
happened.

Add test that sending more than 10 headers makes the connection to
closed; and add test that sending huge HTTP request makes the connection
to be closed.

3 years agoRewrite isc_httpd using picohttpparser and isc_url_parse
Ondřej Surý [Thu, 6 Oct 2022 10:56:25 +0000 (12:56 +0200)] 
Rewrite isc_httpd using picohttpparser and isc_url_parse

Rewrite the isc_httpd to be more robust.

1. Replace the hand-crafted HTTP request parser with picohttpparser for
   parsing the whole HTTP/1.0 and HTTP/1.1 requests.  Limit the number
   of allowed headers to 10 (arbitrary number).

2. Replace the hand-crafted URL parser with isc_url_parse for parsing
   the URL from the HTTP request.

3. Increase the receive buffer to match the isc_netmgr buffers, so we
   can at least receive two full isc_nm_read()s.  This makes the
   truncation processing much simpler.

4. Process the received buffer from single isc_nm_read() in a single
   loop and schedule the sends to be independent of each other.

The first two changes makes the code simpler and rely on already
existing libraries that we already had (isc_url based on nodejs) or are
used elsewhere (picohttpparser).

The second two changes remove the artificial "truncation" limit on
parsing multiple request.  Now only a request that has too many
headers (currently 10) or is too big (so, the receive buffer fills up
without reaching end of the request) will end the connection.

We can be benevolent here with the limites, because the statschannel
channel is by definition private and access must be allowed only to
administrators of the server.  There are no timers, no rate-limiting, no
upper limit on the number of requests that can be served, etc.

3 years agoAdd picohttpparser.{c.h} from https://github.com/h2o/picohttpparser
Ondřej Surý [Fri, 7 Oct 2022 13:48:26 +0000 (15:48 +0200)] 
Add picohttpparser.{c.h} from https://github.com/h2o/picohttpparser

PicoHTTPParser is a tiny, primitive, fast HTTP request/response parser.

Unlike most parsers, it is stateless and does not allocate memory by
itself. All it does is accept pointer to buffer and the output
structure, and setups the pointers in the latter to point at the
necessary portions of the buffer.

3 years agoMerge branch 'pspacek/git-blame-ignore-revs' into 'main'
Petr Špaček [Thu, 13 Oct 2022 16:02:33 +0000 (16:02 +0000)] 
Merge branch 'pspacek/git-blame-ignore-revs' into 'main'

Add list of meaningless commits to .git-blame-ignore-revs

See merge request isc-projects/bind9!6903

3 years agoAdd list of meaningless commits to .git-blame-ignore-revs
Petr Špaček [Thu, 13 Oct 2022 12:33:52 +0000 (14:33 +0200)] 
Add list of meaningless commits to .git-blame-ignore-revs

Works nicely together with:
    git config --add blame.ignoreRevsFile .git-blame-ignore-revs

The list was generated by hand-picking from git log --oneline augmented
with:
    --author=tbox
    --grep=clang-format
    --grep=copyright
    --grep=reformat
    --grep=whitespace
plus
    git log --format='commit %H %s' --stat | grep -E 'commit|changed' | grep -B1 '[0-9][0-9][0-9] files changed'
plus some sanity checking.

Comments were added with:
    for COMMIT in $(cat .git-blame-ignore-revs)
        do git log -1 --format="# %s" "$COMMIT"
        echo $COMMIT
    done

3 years agoMerge branch 'pspacek/dns-name-attributes-struct' into 'main'
Petr Špaček [Thu, 13 Oct 2022 15:22:57 +0000 (15:22 +0000)] 
Merge branch 'pspacek/dns-name-attributes-struct' into 'main'

Replace #define DNS_NAMEATTR_* with struct of booleans

See merge request isc-projects/bind9!6902

3 years agoReplace #define DNS_NAMEATTR_ with struct of bools
Petr Špaček [Thu, 13 Oct 2022 08:33:41 +0000 (10:33 +0200)] 
Replace #define DNS_NAMEATTR_ with struct of bools

sizeof(dns_name_t) did not change but the boolean attributes are now
separated as one-bit structure members. This allows debuggers to
pretty-print dns_name_t attributes without any special hacks, plus we
got rid of manual bit manipulation code.

3 years agoFix latent bug in RBT node attributes handling
Petr Špaček [Thu, 13 Oct 2022 11:08:22 +0000 (13:08 +0200)] 
Fix latent bug in RBT node attributes handling

Originally RBT node stored three lowest bits from dns_name_t attributes.
This had a curious side-effect noticed by Tony Finch:

If you create an rbt node from a DYNAMIC name then the flag will be
propagated through dns_rbt_namefromnode() ... if you subsequently call
dns_name_free() it will try to isc_mem_put() a piece of an rbt node ...
but dns_name_free() REQUIRE()s that the name is dynamic so in the usual
case where rbt nodes are created from non-dynamic names, this kind of
code will fail an assertion.

This is a bug it dates back to june 1999 when NAMEATTR_DYNAMIC was
invented.

Apparently it does not happen often :-)
I'm planning to get rid of DNS_NAMEATTR_ definitions and bit operations,
so removal of this "three-bit-subset" assignment is a first step.

We can keep only the ABSOLUTE flag in RBT node and nothing else because
names attached to rbt nodes are always readonly: The internal node_name()
function always sets the NAMEATTR_READONLY when making a dns_name that
refers to the node's name, so the READONLY flag will be set in the name
returned by dns_rbt_namefromnode().

Co-authored-by: Tony Finch <fanf@isc.org>
3 years agoMerge branch 'artem-doth-reduce-listener-sockets-number' into 'main'
Ondřej Surý [Thu, 13 Oct 2022 05:37:48 +0000 (05:37 +0000)] 
Merge branch 'artem-doth-reduce-listener-sockets-number' into 'main'

doth system test fixes - decrese the size of HTTP listener quota, increase transfer-in/out limits

Closes #3596

See merge request isc-projects/bind9!6898

3 years agodoth system test: increase transfers-in/out limits
Artem Boldariev [Wed, 24 Aug 2022 17:44:47 +0000 (20:44 +0300)] 
doth system test: increase transfers-in/out limits

Sometimes doth test could intermittently fail shortly after start due
to inability to complete a zone transfer in time. As it turned out, it
could happen due to transfers-in/out limits. Initially the defaults
were fine, but over time, especially when adding Strict/Mutual TLS, we
added more than 10 zones so it became possible to hit the limits.

This commit takes care of that by bumping the limits.

3 years agodoth system test - decrease HTTP listener quota size
Artem Boldariev [Wed, 12 Oct 2022 15:46:54 +0000 (18:46 +0300)] 
doth system test - decrease HTTP listener quota size

This commit reduces the size of HTTP listener quota from 300 (default)
to 100 so that it would make hitting any global limits in case of
running multiple tests in parallel in multiple containers unlikely.

This way the need in opening many file descriptors of different
kinds (e.g. client side connections and pipes) gets significantly
reduced while the required code paths are still verified.

3 years agoMerge branch 'ondrej-restore-connrefused-for-udp_test' into 'main'
Ondřej Surý [Wed, 12 Oct 2022 17:24:24 +0000 (17:24 +0000)] 
Merge branch 'ondrej-restore-connrefused-for-udp_test' into 'main'

Restore ignoring ISC_R_CONNREFUSED in connect_read_cb

See merge request isc-projects/bind9!6899

3 years agoRestore ignoring ISC_R_CONNREFUSED in connect_read_cb
Ondřej Surý [Wed, 12 Oct 2022 17:21:42 +0000 (19:21 +0200)] 
Restore ignoring ISC_R_CONNREFUSED in connect_read_cb

In ac4cc8443dddc8e900188b4beae54c7ca222094c, the ISC_R_CONNREFUSED was
removed in connect_read_cb, but it can actually happen in the udp_test:

    [ RUN      ] udp_recv_send
    connect_read_cb(0x7f2c2801a270, connection refused, (nil))

3 years agoMerge branch '3595-dont-set-so_reuseport-on-outgoing-udp-sockets' into 'main'
Ondřej Surý [Wed, 12 Oct 2022 13:38:41 +0000 (13:38 +0000)] 
Merge branch '3595-dont-set-so_reuseport-on-outgoing-udp-sockets' into 'main'

The UDP connect socket should not set REUSEPORT_LB

See merge request isc-projects/bind9!6888

3 years agoMerge branch '3595-retry-on-timeout-in-udp_recv_one-and_udp_recv_two-unit-test' into...
Ondřej Surý [Wed, 12 Oct 2022 13:36:31 +0000 (13:36 +0000)] 
Merge branch '3595-retry-on-timeout-in-udp_recv_one-and_udp_recv_two-unit-test' into 'main'

Retry on timeout in the UDP recv_one, udp_recv_two and double_read tests

See merge request isc-projects/bind9!6894

3 years agoGracefully handle ISC_R_SHUTTINGDOWN in udp__send_cb
Ondřej Surý [Tue, 11 Oct 2022 10:29:48 +0000 (12:29 +0200)] 
Gracefully handle ISC_R_SHUTTINGDOWN in udp__send_cb

The ISC_R_SHUTTINGDOWN should be handled the same as ISC_R_CANCELED in
the udp__send_cb(), as we might be sending the data while the
loopmgr/netmgr shutdown has been initiated.

3 years agoMake sure the unit test listening and connecting ports are different
Ondřej Surý [Tue, 11 Oct 2022 10:03:17 +0000 (12:03 +0200)] 
Make sure the unit test listening and connecting ports are different

In rare circumstances, the UDP port for the listening socket and the UDP
port for the connecting socket might be the same.  Because we use the
"reuse" port socket option, this isn't caught when binding the socket,
and thus the connected client socket could send a datagram to itself,
completely bypassing the server.  This doesn't happen under normal
operation mode because `named` is listening on a privileged port (53),
and even if not, it doesn't usually talk to itself as the tests do.

Pick an arbitrary port for listening (9153-9156) that is outside the
ephemeral port range for the network manager related unit tests (except
the `doh_test).

3 years agoDon't set load-balancing socket option on the UDP connect sockets
Ondřej Surý [Tue, 11 Oct 2022 07:10:16 +0000 (09:10 +0200)] 
Don't set load-balancing socket option on the UDP connect sockets

The isc_nm_udpconnect() erroneously set the reuse port with
load-balancing on the outgoing connected UDP sockets.  This socket
option makes only sense for the listening sockets.  Don't set the
load-balancing reuse port option on the outgoing UDP sockets.

3 years agoRetry on timeout in the UDP recv_one, recv_two and double_read tests
Ondřej Surý [Wed, 12 Oct 2022 07:43:56 +0000 (09:43 +0200)] 
Retry on timeout in the UDP recv_one, recv_two and double_read tests

Since we are testing UDP on the localhost and the same interface, the
UDP datagrams can't get lost.  Change the connect read callback, so it
starts reading again on the timeout instead of just getting stuck, and
fail when any other result codes than ISC_R_SUCCESS and ISC_R_TIMEDOUT
are received because we don't expect them to happen in these simple
tests.

3 years agoMerge branch 'artem-clear-ssl-error-queue-for-dns-transports' into 'main'
Ondřej Surý [Wed, 12 Oct 2022 13:33:38 +0000 (13:33 +0000)] 
Merge branch 'artem-clear-ssl-error-queue-for-dns-transports' into 'main'

TLS: clear error queue before doing I/O or calling SSL_get_error()

See merge request isc-projects/bind9!6892

3 years agoDoH unit test: remove broken remnants of slowdown logic
Artem Boldariev [Wed, 12 Oct 2022 12:26:06 +0000 (15:26 +0300)] 
DoH unit test: remove broken remnants of slowdown logic

This commit removes broken remnants of unit test slowdown logic, which
caused unit test hangs on platforms susceptible to "too many open
files" error, notably OpenBSD.

3 years agoTLS DNS: fix certificate verification error message reporting
Artem Boldariev [Tue, 11 Oct 2022 18:00:04 +0000 (21:00 +0300)] 
TLS DNS: fix certificate verification error message reporting

This commit fixes TLS DNS verification error message reporting which
we probably broke during one of the recent networking code
refactorings.

This prevent e.g. dig from producing useful error messages related to
TLS certificates verification.

3 years agoTLS: clear error queue before doing IO or calling SSL_get_error()
Artem Boldariev [Tue, 4 Oct 2022 18:03:23 +0000 (21:03 +0300)] 
TLS: clear error queue before doing IO or calling SSL_get_error()

Ensure that TLS error is empty before calling SSL_get_error() or doing
SSL I/O so that the result will not get affected by prior error
statuses.

In particular, the improper error handling led to intermittent unit
test failure and, thus, could be responsible for some of the system
test failures and other intermittent TLS-related issues.

See here for more details:

https://www.openssl.org/docs/man3.0/man3/SSL_get_error.html

In particular, it mentions the following:

> The current thread's error queue must be empty before the TLS/SSL
> I/O operation is attempted, or SSL_get_error() will not work
> reliably.

As we use the result of SSL_get_error() to decide on I/O operations,
we need to ensure that it works reliably by cleaning the error queue.

TLS DNS: empty error queue before attempting I/O

3 years agoMerge branch '3601-ignore-connection_reset-in-listen_send_cb' into 'main'
Ondřej Surý [Wed, 12 Oct 2022 13:19:03 +0000 (13:19 +0000)] 
Merge branch '3601-ignore-connection_reset-in-listen_send_cb' into 'main'

Ignore additional return codes in the netmgr unit tests

Closes #3601

See merge request isc-projects/bind9!6895

3 years agoIgnore additional return codes in the netmgr unit tests
Ondřej Surý [Wed, 12 Oct 2022 12:40:49 +0000 (14:40 +0200)] 
Ignore additional return codes in the netmgr unit tests

There was inconsistency in which error codes would get accepted and
ignored in the network manager unit test callbacks.  Add following
results, so we just detach the handle instead of causing assertion
failure:

* ISC_R_SHUTTINGDOWN - when the network manager is shutting down
* ISC_R_CANCELED - the socket has been shut down
* ISC_R_EOF - the (TCP) communication has ended on the other side
* ISC_R_CONNECTIONRESET - the TCP connection was reset

This should fix some of the spurious unit test failures.

3 years agoMerge branch '3574-cid-357292-improper-use-of-negative-value-in-tcp.c' into 'main'
Arаm Sаrgsyаn [Wed, 12 Oct 2022 09:00:21 +0000 (09:00 +0000)] 
Merge branch '3574-cid-357292-improper-use-of-negative-value-in-tcp.c' into 'main'

Resolve "CID 357292: Improper use of negative value in lib/isc/netmgr/tcp.c"

Closes #3574

See merge request isc-projects/bind9!6851

3 years agoRemove a superfluous check of sock->fd against -1
Aram Sargsyan [Wed, 12 Oct 2022 08:21:35 +0000 (08:21 +0000)] 
Remove a superfluous check of sock->fd against -1

The check is left from when tcp_connect_direct() called isc__nm_socket()
and it was uncertain whether it had succeeded, but now isc__nm_socket()
is called before tcp_connect_direct(), so sock->fd cannot be -1.

    *** CID 357292:    (REVERSE_NEGATIVE)
    /lib/isc/netmgr/tcp.c: 309 in isc_nm_tcpconnect()
    303
    304      atomic_store(&sock->active, true);
    305
    306      result = tcp_connect_direct(sock, req);
    307      if (result != ISC_R_SUCCESS) {
    308      atomic_store(&sock->active, false);
    >>>     CID 357292:    (REVERSE_NEGATIVE)
    >>>     You might be using variable "sock->fd" before verifying that it is >= 0.
    309      if (sock->fd != (uv_os_sock_t)(-1)) {
    310      isc__nm_tcp_close(sock);
    311      }
    312      isc__nm_connectcb(sock, req, result, true);
    313      }
    314

3 years agoMerge branch '3595-fix-the-intermittent-udp_test-failures' into 'main'
Ondřej Surý [Tue, 11 Oct 2022 13:02:14 +0000 (13:02 +0000)] 
Merge branch '3595-fix-the-intermittent-udp_test-failures' into 'main'

Handle double timeout in udp_cancel_read test

See merge request isc-projects/bind9!6889

3 years agoHandle double timeout in udp_cancel_read test
Ondřej Surý [Tue, 11 Oct 2022 07:06:37 +0000 (09:06 +0200)] 
Handle double timeout in udp_cancel_read test

If sending took too long the isc_nm_read() could timeout twice, leading
to extra 'cread' counter in the udp_cancel_read test.  Increase the
cread counter only on ISC_R_EOF (canceled read) and deal with the
multiple ISC_R_TIMEOUTS gracefully.

3 years agoMerge branch '3592-fix-startup-detection-after-restart-in-start.pl' into 'main'
Michał Kępień [Tue, 11 Oct 2022 09:55:51 +0000 (09:55 +0000)] 
Merge branch '3592-fix-startup-detection-after-restart-in-start.pl' into 'main'

Fix startup detection after restart in start.pl

Closes #3592

See merge request isc-projects/bind9!6881