Commit Graph

38128 Commits

Author SHA1 Message Date
Michal Nowak
3fc050f097 Merge branch 'mnowak/set-up-version-and-release-notes-for-bind-9.18.20' into 'bind-9.18'
Set up version and release notes for BIND 9.18.20

See merge request isc-projects/bind9!8293
2023-09-12 07:38:12 +00:00
Michal Nowak
8b5e396f45 Set up release notes for BIND 9.18.20 2023-09-12 09:36:39 +02:00
Michal Nowak
a0d8c44bf7 Update BIND version to 9.18.20-dev 2023-09-12 09:36:39 +02:00
Ondřej Surý
04128e764e Merge branch '4292-uncleared-libcrypto-error-crypto-evp-evp_fetch-c-373-inner_evp_generic_fetch-bind-9.18' into 'bind-9.18'
[9.18] Resolve "Uncleared libcrypto error: crypto/evp/evp_fetch.c:373 inner_evp_generic_fetch"

See merge request isc-projects/bind9!8279
2023-09-06 15:47:08 +00:00
Mark Andrews
7f89f2d6bc Call ERR_clear_error on EVP_MD_fetch or EVP_##alg error
(cherry picked from commit 28adcf1831)
2023-09-06 15:47:05 +00:00
Mark Andrews
ad9fd9e362 Merge branch '4290-raise-log-level-to-isc_log_error-on-formerr-in-xfrin-c-bind-9.18' into 'bind-9.18'
[9.18] Resolve "raise log level to ISC_LOG_NOTICE on FORMERR in xfrin.c"

See merge request isc-projects/bind9!8280
2023-09-06 11:29:12 +00:00
Mark Andrews
dd9f205c13 Add a CHANGES note for [GL #4290]
(cherry picked from commit b867244305)
2023-09-06 20:15:17 +10:00
Mark Andrews
0325e4a1fb Adjust level of log messages when transferring in a zone
This raises the log level of messages treated as FORMERR to NOTICE
when transfering in a zone.  This also adds a missing log message
for TYPE0 and meta types received during a zone transfer.

(cherry picked from commit 6c3414739d)
2023-09-06 20:14:41 +10:00
Michal Nowak
95950a2160 Merge branch 'mnowak/statschannel-system-test-is-too-verbose-9.18' into 'bind-9.18'
[9.18] Disable command tracing in statschannel system test

See merge request isc-projects/bind9!8278
2023-09-05 17:23:48 +00:00
Michal Nowak
71441b782b Disable command tracing in statschannel system test
Command tracing was added recently via
525afc666a and makes the system test too
verbose.

(cherry picked from commit f0c37d861c)
2023-09-05 19:20:37 +02:00
Michal Nowak
1f55cbf2d1 Merge branch '4255-suspicious-messsage-id-fix' into 'bind-9.18'
TLS DNS: take into account partial writes by SSL_write_ex()

See merge request isc-projects/bind9!8276
2023-09-05 16:45:42 +00:00
Artem Boldariev
35bd74a5f0 Add CHANGES and release note for [GL #4255]
Mention that possibility of partial TLS writes was taken into account
and that fixes DNS messages corruption over long DNS over TLS streams.
2023-09-05 18:05:59 +02:00
Artem Boldariev
84d71c8e2c TLS DNS: take into account partial writes by SSL_write_ex()
This commit changes TLS DNS so that partial writes by the
SSL_write_ex() function are taken into account properly. Now, before
doing encryption, we are flushing the buffers for outgoing encrypted
data.

The problem is fairly complicated and originates from the fact that it
is somewhat hard to understand by reading the documentation if and
when partial writes are supported/enabled or not, and one can get a
false impression that they are not supported or enabled by
default (https://www.openssl.org/docs/man3.1/man3/SSL_write_ex.html). I
have added a lengthy comment about that into the code because it will
be more useful there. The documentation on this topic is vague and
hard to follow.

The main point is that when SSL_write_ex() fails with
SSL_ERROR_WANT_WRITE, the OpenSSL code tells us that we need to flush
the outgoing buffers and then call SSL_write_ex() again with exactly
the same arguments in order to continue as partial write could have
happened on the previous call to SSL_write_ex() (that is not hard to
verify by calling BIO_pending(sock->tls.app_rbio) before and after the
call to SSL_write_ex() and comparing the returned values). This aspect
was not taken into account in the code.

Now, one can wonder how that could have led to the behaviour that we
saw in the #4255 bug report. In particular, how could we lose one
message and duplicate one twice? That is where things get interesting.

One needs to keep two things in mind (that is important):

Firstly, the possibility that two (or more) subsequent SSL_write_ex()
calls will be done with exactly the same arguments is very high (the
code does not guarantee that in any way, but in practice, that happens
a lot).

Secondly, the dnsperf (the software that helped us to trigger the bug)
bombed the test server with messages that contained exactly the same
data. The only difference in the responses is message IDs, which can
be found closer to the start of a message.

So, that is what was going on in the older version of the code:

1. During one of the isc_nm_send() calls, the SSL_write_ex() call
fails with SSL_ERROR_WANT_WRITE. Partial writing has happened, though,
and we wrote a part of the message with the message
ID (e.g. 2014). Nevertheless, we have rescheduled the complete send
operation asynchronously by a call to tlsdns_send_enqueue().

2. While the asynchronous request has not been completed, we try to
send the message (e.g. with ID 2015). The next isc_nm_send() or
re-queued send happens with a call to SSL_write_ex() with EXACTLY the
same arguments as in the case of the previous call. That is, we are
acting as if we want to complete the previously failed SSL_write_ex()
attempt (according to the OpenSSL documentation:
https://www.openssl.org/docs/man3.1/man3/SSL_write_ex.html, the
"Warnings" section). This way, we already have a start of the message
containing the previous ID (2014 in our case) but complete the write
request with the rest of the data given in the current write
attempt. However, as responses differ only in message ID, we end up
sending a valid (properly structured) DNS message but with the ID of
the previous one. This way, we send a message with ID from the
previous isc_nm_send() attempt. The message with the ID from the send
request from this attempt will never be sent, as the code thinks that
it is sending it now (that is how we send the message with ID 2014
instead of 2015, as in our example, thus making the message with ID
2015 never to be sent).

3. At some point later, the asynchronous send request (the rescheduled
on the first step) completes without an error, sending a second
message with the same ID (2014).

It took exhausting SSL write buffers (so that a data encryption
attempt cannot be completed in one operation) via long DoT streams in
order to exhibit the behaviour described above. The exhaustion
happened because we have not been trying to flush the buffers often
enough (especially in the case of multiple subsequent writes).

In my opinion, the origin of the problem can be described as follows:

It happened due to making wrong guesses caused by poorly written
documentation.
2023-09-05 18:03:44 +02:00
Ondřej Surý
7df60d3085 Merge branch '4038-specialised-arena-per-worker-9.18' into 'bind-9.18'
[9.18] Make it possible to create memory contexts backed by jemalloc arenas

See merge request isc-projects/bind9!8271
2023-09-05 14:00:16 +00:00
Artem Boldariev
7e967f54a4 Add CHANGES and release note for [GL #4038]
Mention that send buffer allocations/deallocations are now routed
through dedicated memory arenas.

(cherry picked from commit 60d52a49b0)
2023-09-05 15:02:30 +02:00
Artem Boldariev
1cc17f797e Allocate DNS send buffers using dedicated per-worker memory arenas
This commit ensures that memory allocations related to DNS send
buffers are routed through dedicated per-worker memory arenas in order
to decrease memory usage on high load caused by TCP-based DNS
transports.

We do that by following jemalloc developers suggestions:

https://github.com/jemalloc/jemalloc/issues/2483#issuecomment-1639019699
https://github.com/jemalloc/jemalloc/issues/2483#issuecomment-1698173849
(cherry picked from commit 01cc7edcca)
2023-09-05 15:02:30 +02:00
Artem Boldariev
f5cb14265f Add ability to set per jemalloc arena dirty and muzzy decay values
This commit adds couple of functions to change "dirty_decay_ms" and
"muzzy_decay_ms" settings on arenas associated with memory contexts.

(cherry picked from commit 6e98b58d15)
2023-09-05 15:02:30 +02:00
Artem Boldariev
16a45837ca Make it possible to create memory contexts backed by jemalloc arenas
This commit extends the internal memory management middleware code in
BIND so that memory contexts backed by dedicated jemalloc arenas can
be created. A new function (isc_mem_create_arena()) is added for that.

Moreover, it extends the existing code so that specialised memory
contexts can be created easily, should we need that functionality for
other future purposes. We have achieved that by passing the flags to
the underlying jemalloc-related calls. See the above
isc_mem_create_arena(), which can serve as an example of this.

Having this opens up possibilities for creating memory contexts tuned
for specific needs.

(cherry picked from commit 8550c52588)
2023-09-05 15:02:30 +02:00
Ondřej Surý
6d24650333 Merge branch 'artem-fix-building-on-dragonflybsd-9.18' into 'bind-9.18'
[9.18] Fix building BIND on DragonFly BSD (on both older an newer versions)

See merge request isc-projects/bind9!8272
2023-09-05 11:07:49 +00:00
Artem Boldariev
d53ecb7720 Fix building BIND on DragonFly BSD (on both older an newer versions)
This commit ensures that BIND and supplementary tools still can be
built on newer versions of DragonFly BSD. It used to be the case, but
somewhere between versions 6.2 and 6.4 the OS developers rearranged
headers and moved some function definitions around.

Before that the fact that it worked was more like a coincidence, this
time we, at least, looked at the related man pages included with the
OS.

No in depth testing has been done on this OS as we do not really
support this platform - so it is more like a goodwill act. We can,
however, use this platform for testing purposes, too. Also, we know
that the OS users do use BIND, as it is included in its ports
directory.

Building with './configure' and './configure --without-jemalloc' have
been fixed and are known to work at the time the commit is made.

(cherry picked from commit 942569a1bb)
2023-09-05 10:33:51 +02:00
Ondřej Surý
445283a67b Merge branch '4263-deprecate-dnssec-must-be-secure-feature-9.18' into 'bind-9.18'
Deprecate 'dnssec-must-be-secure' option

See merge request isc-projects/bind9!8268
2023-09-04 16:54:46 +00:00
Ondřej Surý
12935f2e70 Add CHANGES and release note for [GL #4263]
(cherry picked from commit 898f0ee3cf)
2023-09-04 17:27:38 +02:00
Ondřej Surý
c9d6f0e400 Deprecate 'dnssec-must-be-secure' option
The dnssec-must-be-secure feature was added in the early days of BIND 9
and DNSSEC and it makes sense only as a debugging feature.

Remove the feature to simplify the code.

(cherry picked from commit 9e0b348a2b)
2023-09-04 17:27:14 +02:00
Michał Kępień
8f99ee3e13 Merge branch 'michal/reorganize-vulnerability-docs-9.18' into 'bind-9.18'
[9.18] Move security-related information to SECURITY.md

See merge request isc-projects/bind9!8266
2023-09-04 10:00:36 +00:00
Michał Kępień
695624f314 Move security-related information to SECURITY.md
To follow current best practices, create a short SECURITY.md file in the
root of the repository that contains information about the project's
security policy and guidelines for reporting potential security issues.
Replace the relevant bits of text in other files with references to the
new SECURITY.md file, so that the relevant information only needs to be
maintained in one place.

Replace all occurrences of the generic security-officer@isc.org email
with a dedicated address for reporting BIND 9 security issues,
bind-security@isc.org.

(cherry picked from commit ca9fed9143)
2023-09-04 11:56:46 +02:00
Arаm Sаrgsyаn
07599c2798 Merge branch 'aram/zone.c-got_transfer_quota-bugfix-9.18' into 'bind-9.18'
[9.18] Reset the 'result' before using it again in zone.c:got_transfer_quota()

See merge request isc-projects/bind9!8256
2023-09-04 08:36:57 +00:00
Ondřej Surý
46969dca75 Unobfuscate the code-flow logic in got_transfer_quota()
This refactors the code flow in got_transfer_quota() to not use the
CHECK() macro as it really obfuscates the code flow logic here.

(cherry picked from commit 00cb151f8e)
2023-09-04 08:04:52 +00:00
Aram Sargsyan
07b2d19b92 Reset the 'result' before using it again
The 'result' variable should be reset to ISC_R_NOTFOUND again,
because otherwise a log message could be logged about not being
able to get the TLS configuration based on on the 'result' value
from the previous calls to get the TSIG key.

(cherry picked from commit 6cab7fc627)
2023-09-04 08:04:52 +00:00
Matthijs Mekking
978b4cdd6f Merge branch '4266-document-dnssec-policy-lifetime-v9_18' into 'bind-9.18'
[9.18] Clarify BIND 9 time formats

See merge request isc-projects/bind9!8259
2023-09-01 08:19:40 +00:00
Matthijs Mekking
41085510a6 Add CHANGES entry for #4266
(cherry picked from commit fd3d58d512)
2023-09-01 10:18:50 +02:00
Matthijs Mekking
44cd3788ac Explain lifetime format
Add the text "TTL-style unit suffixes or ISO 8601 duration formats",
just like we do at other places that are duration option types.

Also, in the dnssec-policy "keys" example, use a TTL-style unit too.

(cherry picked from commit b5a757c452)
2023-09-01 10:18:31 +02:00
Matthijs Mekking
a3f94bf002 Add a glossary definition for duration
We don't yet explain the syntax of TTL-style suffixes or ISO 8601
duration formats.

(cherry picked from commit cc122d22b4)
2023-09-01 10:18:31 +02:00
Matthijs Mekking
caf5eeb141 Fix keys reference link in ARM
There's a statement that says: "Here is an example (for illustration
purposes only) of some possible entries in a [keys] list:", and that
links to the wrong "keys" statement (it links to the TSIG keys section).

Remove the reference, as we are already in the right section.

(cherry picked from commit 07c70ea2bd)
2023-09-01 10:18:31 +02:00
Mark Andrews
2dbdcd6f4b Merge branch '4159-openssl-error-queue-not-cleaned-bind-9.18' into 'bind-9.18'
[9.18] Resolve "OpenSSL error queue not cleaned"

See merge request isc-projects/bind9!8263
2023-09-01 04:49:40 +00:00
Mark Andrews
3c2704e994 Add release note for [GL #4159]
(cherry picked from commit 6a1a73759a)
2023-09-01 14:22:19 +10:00
Mark Andrews
4735383680 Add CHANGES note for [GL #4159]
(cherry picked from commit 6c3d4d7aa2)
2023-09-01 14:22:17 +10:00
Mark Andrews
e10dfc2e2d Detect uncleared libcrypto errors in rdata processing
If libcrypto errors are not cleared slow memory leaks occur which
are not detected at shutdown.

(cherry picked from commit 14727bb4b9)
2023-09-01 14:21:49 +10:00
Mark Andrews
91a6885a01 Style fix
(cherry picked from commit b6e1650455)
2023-09-01 14:06:28 +10:00
Mark Andrews
29a93d2889 Check that buf is large enough
(cherry picked from commit 299f519b09)
2023-09-01 14:06:27 +10:00
Mark Andrews
f77ffa7953 Take ownership of pointer before freeing
(cherry picked from commit 9e2288208d)
2023-09-01 14:03:49 +10:00
Mark Andrews
4c27f80476 Add missing "Design by Contract" REQUIREs
(cherry picked from commit b442ae8d3e)
2023-09-01 14:00:14 +10:00
Mark Andrews
788a8a7c4d Free evp_md_ctx and pkey at exit
(cherry picked from commit 936b73cb57)
2023-09-01 13:45:57 +10:00
Mark Andrews
74f9d749bf Clear OpenSSL error stack when exiting
(cherry picked from commit eaedba6621)
2023-09-01 13:45:34 +10:00
Mark Andrews
894b0970e6 Clear OpenSSL errors on TSL error paths
(cherry picked from commit 4f790b6c58)
2023-09-01 13:45:34 +10:00
Mark Andrews
0111782f1e Clear OpenSSL errors on context creation failures
(cherry picked from commit 96db614d69)
2023-09-01 13:45:34 +10:00
Mark Andrews
900efd613f Clear OpenSSL errors on SHA failures
(cherry picked from commit 247422c69f)
2023-09-01 13:45:34 +10:00
Mark Andrews
34a0bb146c Clear OpenSSL errors on engine errors
(cherry picked from commit 2ba62aebce)
2023-09-01 13:43:20 +10:00
Mark Andrews
aca6f3e82d Clear OpenSSL errors on EVP failures
(cherry picked from commit 4ea926934a)
2023-09-01 13:40:32 +10:00
Mark Andrews
b5b13771f2 Clear OpenSSL errors on EVP_PKEY_new failures
(cherry picked from commit 6df53cdb87)
2023-09-01 13:37:02 +10:00
Mark Andrews
4d37996b1a Clear OpenSSL errors on EC_KEY_get0_private_key failures
(cherry picked from commit 86b04368b0)
2023-09-01 13:34:14 +10:00