Commit graph

14980 commits

Author SHA1 Message Date
Mark Andrews
6c3414739d 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.
2023-09-06 02:24:53 +00:00
Mark Andrews
28adcf1831 Call ERR_clear_error on EVP_MD_fetch or EVP_##alg error 2023-09-06 00:28:56 +00:00
Mark Andrews
cf63cb1136 Restore dns_validator_destroy and fetchctx_detach call order
7a78a85b moved the destruction of the validator from near the start
validated to the end.  This reversed the order of dns_validator_destroy
and fetchctx_detach.  Restore the order so that val->name remains
valid for the lifetime of the validator.
2023-09-06 09:23:00 +10:00
Ondřej Surý
d862f4bc64
Ignore jemalloc versions before 4.0.0
We now depend on explicitly creating memory arenas and disabling tcache
on those, and these features are not available with jemalloc < 4.
Instead of working around these issues, make the jemalloc >= 4.0.0 hard
requirement by looking for sdallocx() symbol that's only available from
that version.

The jemalloc < 4 was only used by RHEL 7 which is not supported since
BIND 9.19+.
2023-09-05 18:46:57 +02:00
Artem Boldariev
01cc7edcca
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
2023-09-05 09:39:41 +02:00
Artem Boldariev
6e98b58d15
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.
2023-09-05 09:39:41 +02:00
Artem Boldariev
8550c52588
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.
2023-09-05 09:39:41 +02:00
Ondřej Surý
9e0b348a2b
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.
2023-09-04 13:38:14 +02:00
Evan Hunt
1019c0c0b1
unconditionally create view and resolver nametrees
instead of allowing a NULL nametree in dns_nametree_covered(),
require nametree to exist, and ensure that the nametrees defined
for view and resolver objects are always created.
2023-09-04 10:19:48 +02:00
Evan Hunt
1a238a0f86
use a count nametree for synthfromdnssec
use the count semantics for dns_nametree to support view->sfd.
2023-09-04 10:19:48 +02:00
Evan Hunt
b1e4e2a9ee
add a 'foundname' argument to dns_nametree_covered()
when checking whether a name is covered, the ancestor name that
was found can be set into a name object passed in.
2023-09-04 10:19:48 +02:00
Evan Hunt
0ebaa26da7
add semantics to name trees to support counters
name trees can now also hold trees of counters. each time a name
dns_nametree_add() is called with a given name, the counter for that
name is incremented; the name is not deleted until dns_nametree_delete()
is called the same number of times.

this is meant to be used for synth-from-dnssec, which is incremented for
each key defined at a name, and decremented when a key is removed, the
name must continue to exist until the number of keys has reached zero.
2023-09-04 10:19:48 +02:00
Evan Hunt
bc3fd1a2ef
use bitfield name trees for disable-algorithms and disable-ds-digests
switch disable-algorithms and disable-ds-digests to use
bitfield-type name trees, replacing the RBT-based bftree.
2023-09-04 10:19:48 +02:00
Evan Hunt
9ed1dba976
add semantics to dns_nametree to support bitfields
name trees can now hold either boolean values or bit fields. the
type is selected when the name tree is created.

the behavior of dns_nametree_add() differs slightly beteween the types:
in a boolean tree adding an existing name will return ISC_R_EXISTS,
but in a bitfield tree it simply sets the specified bit in the bitfield
and returns ISC_R_SUCCESS.
2023-09-04 10:19:48 +02:00
Evan Hunt
54fc02410e refactor disable_algorithm and disable_ds_digest to use one data structure
the functions for disabling DNSSEC signing algorithms and DS digest
algorithms in resolver.c had a lot of duplicated code.

this commit adds functions to implement a "bitfield tree", which is
(currently) an RBT in which the node data contains arbitrary-sized
bitfields to indicate whether a value has been added at the given
node or not. (it can be changed to a QP trie later.)

it also replaces the functions dns_resolver_disable_algorithm(),
dns_resolver_algorithm_supported(), dns_resolver_disable_ds_digest()
and dns_resolver_ds_digest_supported() with simple wrappers that call
the new functions.
2023-09-01 10:46:58 -07:00
Evan Hunt
e83ac0ce65 use dns_nametree in place of RBTs
replace the use of RBTs for deny-answer-aliases, the exclude
lists for deny-answer-aliases and deny-answer-addresses, and
dnssec-must-be-secure, with name trees.
2023-09-01 10:46:53 -07:00
Evan Hunt
56114aaa0d add dns_nametree structure for policy match lookups
this is a QP trie of boolean values to indicate whether a name is
included in or excluded from some policy. this can be used for
synth-from-dnssec, deny-answer-aliases, etc.
2023-09-01 10:46:48 -07:00
Evan Hunt
9067b637d8 replace RBTs with hashmaps in dns_transport
as dns_transport_find() is only concerned with finding an exact
match on the specified name it doesn't need to use a tree data
structure internally, we can replace the RBTs with hash tables.
2023-09-01 10:39:39 -07:00
Mark Andrews
299f519b09 Check that buf is large enough 2023-09-01 12:01:20 +10:00
Mark Andrews
9e2288208d Take ownership of pointer before freeing 2023-09-01 12:01:20 +10:00
Mark Andrews
4c4ecbc83c Address potential memory leak in dst__openssl_fromlabel 2023-09-01 12:01:20 +10:00
Mark Andrews
b442ae8d3e Add missing "Design by Contract" REQUIREs 2023-09-01 12:01:20 +10:00
Mark Andrews
4f790b6c58 Clear OpenSSL errors on TSL error paths 2023-09-01 12:01:20 +10:00
Mark Andrews
96db614d69 Clear OpenSSL errors on context creation failures 2023-09-01 12:01:20 +10:00
Mark Andrews
247422c69f Clear OpenSSL errors on SHA failures 2023-09-01 12:01:20 +10:00
Mark Andrews
2ba62aebce Clear OpenSSL errors on engine errors 2023-09-01 12:01:19 +10:00
Mark Andrews
4ea926934a Clear OpenSSL errors on EVP failures 2023-09-01 12:01:19 +10:00
Mark Andrews
6df53cdb87 Clear OpenSSL errors on EVP_PKEY_new failures 2023-09-01 12:01:19 +10:00
Mark Andrews
86b04368b0 Clear OpenSSL errors on EC_KEY_get0_private_key failures 2023-09-01 12:01:19 +10:00
Mark Andrews
abd8c03592 Clear OpenSSL errors on EVP_PKEY_get0_EC_KEY failures 2023-09-01 12:01:19 +10:00
Mark Andrews
d8a9adc821 Clear OpenSSL errors on EVP_PKEY_get_bn_param failures 2023-09-01 12:01:19 +10:00
Mark Andrews
8529be30bb Clear OpenSSL errors on EVP_MD_CTX_create failures 2023-09-01 12:01:19 +10:00
Mark Andrews
eafcd41120 Clear OpenSSL errors on ECDSA_SIG_new failures 2023-09-01 12:01:19 +10:00
Mark Andrews
5e09d959b0 Clear OpenSSL errors on d2i_ASN1_OBJECT failures
When d2i_ASN1_OBJECT() fails an error is pushed onto the thread's
error stack.  This is now cleared by calling ERR_clear_error().
2023-09-01 12:01:19 +10:00
Ondřej Surý
d9048b3db1
Remove ISC_MEM_ZERO and isc_mem_*x() API
Use the new isc_mem_c*() calloc-like API for allocations that are
zeroed.

In turn, this also fixes couple of incorrect usage of the ISC_MEM_ZERO
for structures that need to be zeroed explicitly.

There are few places where isc_mem_cput() is used on structures with a
flexible member (or similar).
2023-08-31 22:08:35 +02:00
Ondřej Surý
8ac679a980
Remove ISC_MEM_ALIGN() memory flag
The ISC_MEM_ALIGN() was not used anywhere (except mem.c itself), so just
remove the unused flag.
2023-08-31 22:08:35 +02:00
Ondřej Surý
55c29b8d83
Do extra manual isc_mem_cget() conversions
Some of the cases weren't caught by the coccinelle and there were some
places where cget+memmove() could get converted to simple creget().
2023-08-31 22:08:35 +02:00
Ondřej Surý
89fcb6f897
Apply the isc_mem_cget semantic patch 2023-08-31 22:08:35 +02:00
Ondřej Surý
6272482113
Checked array allocation arithmetic with isc_mem_get and friends
Add new isc_mem_cget(), isc_mem_creget(), and isc_mem_cput() macros to
complement the isc_mem_callocate() (which works like calloc()).

The overflow checks are implemented as macros in the <isc/mem.h>, so
that the compiler can see that the element size is constant: it should
always be `sizeof(something)`.
2023-08-31 22:08:35 +02:00
Evan Hunt
8bda38e7d4 remove dns_name_totext2() and dns_name_toprincipal()
we can pass option flags to dns_name_totext() to get the same
results, and eliminate the extra function names.
2023-08-31 12:53:32 -07:00
Evan Hunt
62d70966f2 remove dns_name_towire2()
we don't need two versions of dns_name_towire(), we can just add NULL
to the calls that don't need to specify a compression offset.
2023-08-31 10:29:16 -07:00
Evan Hunt
a290ed5bd0 remove dns_name_fromstring2()
we don't need two versions of dns_name_fromstring() any longer; we
can just specify an origin value of dns_rootname for absolute names.
2023-08-31 10:29:16 -07:00
Evan Hunt
6909897adf remove cfg_acl_fromconfig2()
the extra option to limit ACL configuration to only one address family
was no longer in use, and has been removed.
2023-08-31 10:29:16 -07:00
Ondřej Surý
00cb151f8e 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.
2023-08-31 09:40:54 +00:00
Aram Sargsyan
6cab7fc627 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.
2023-08-31 09:40:54 +00:00
Matthijs Mekking
3ae721db6c After cache flush, restore serve-stale settings
When flushing the cache, we create a new cache database. The serve-stale
settings need to be restored after doing this. We already did this
for max-stale-ttl, but forgot to do this for stale-refresh-time.
2023-08-31 11:07:35 +02:00
Mark Andrews
9e03b5f5cc Set the modification time of the zone file after dumping
For secondary, mirror and redirect zones the expiry time is set
from the zone file's modification time on restart.  As zone dumping
take time, set the modification time of the zone file to the expire
time less the expire interval.
2023-08-31 11:34:14 +10:00
Mark Andrews
b04d941354 Trim the effective expire time based on expire option
and use that adjusted time to set the modification times.
2023-08-31 11:32:29 +10:00
Mark Andrews
0b4200c010 Extract the expire option from the response 2023-08-31 11:32:29 +10:00
Mark Andrews
be21d31840 Handle EDNS induced FORMERR responses
If we are talking to a non EDNS aware primary that returns FORMERR
to EDNS requests retry the request without using EDNS.
2023-08-31 11:32:29 +10:00