2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

9118 Commits

Author SHA1 Message Date
Mark Andrews
b442ae8d3e Add missing "Design by Contract" REQUIREs 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
2ba62aebce Clear OpenSSL errors on engine errors 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ý
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
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
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
Mark Andrews
690fd050a0 Allow EDNS to be used when making requests in xfrin
This allow for the EDNS options EXPIRE and NSID to be sent when
when making requests.  The existing controls controlling whether
EDNS is used and whether EXPIRE or NSID are sent are honoured.

Adjust the expected byte counts in the xfer system test to reflect
the EDNS overhead.  Adjust the dig call to match named's behavior
(don't set +expire as we are talking to a secondary).
2023-08-31 11:32:29 +10:00
Mark Andrews
87912e4bb8 Provide a mechanism to return the expire option value
to the zone code so that it can be used to adjust the expire time.
2023-08-31 11:32:29 +10:00
Timo Teräs
628dd278d3 Rework opensslecdsa_link to handle legacy key objects w/ openssl3
Due to bug in openssl3, the pkcs11-engine is made the default
provider if enabled. This causes key generation and load to
return legacy objects.

Openssl3 has limited glue and does not support the full set
of new style parameter to be inqueried from legacy key objects

Rewrite required functions to use first the new API (if available),
but fallback to the old API (if available). For the methods that
have proper OpenSSL compatiblity glue, ship only one version.
2023-08-25 14:59:16 +03:00
Ondřej Surý
2e3eae6b91
Refactor cleanup code in the qp-trie for the forwarders table
Instead of duplicating the destroy_forwarders() code in the cleanup
sections, just call dns_forwarders_detach() every time - in case of
failure, the forwarders aren't going to be attached, and forwarders
object will be destroyed right away.
2023-08-23 15:49:17 +02:00
Ondřej Surý
9b858769dc
Add zone name to the LIBDNS_XFRIN probes
We already print the formatted zone name via the xfrin_log() function,
generate the text once and store it in xfr->info static buffer.  Then we
can reuse the string to pass it to the LIBDNS_XFRIN probes.
2023-08-21 18:39:53 +02:00
Ondřej Surý
d332f07f38
Add a probe when the response rate limiting drops or slips query
Add a trace point that would report when a query gets dropped or slipped
by rate limits. It reports the client IP, the zone, and the RRL result
code.

Co-authored-by: Paul Frieden <pfrieden@yahooinc.com>
2023-08-21 18:39:53 +02:00
Ondřej Surý
96ccba5d51
Add tracing probes to the dns_xfrin unit
Add tracing probes to incoming transfers, so we can accurately measure
the individual events when sending, receiving and parsing the incoming
transfers.
2023-08-21 18:39:53 +02:00
Ondřej Surý
784d055809
Add support for User Statically Defined Tracing (USDT) probes
This adds support for User Statically Defined Tracing (USDT).  On
Linux, this uses the header from SystemTap and dtrace utility, but the
support is universal as long as dtrace is available.

Also add the required infrastructure to add probes to libisc, libdns and
libns libraries, where most of the probes will be.
2023-08-21 18:39:53 +02:00
Ondřej Surý
d76ab69772 Attach to the dns_dispatchmgr in the dns_view object
The dns_dispatchmgr object was only set in the dns_view object making it
prone to use-after-free in the dns_xfrin unit when shutting down named.

Remove dns_view_setdispatchmgr() and optionally pass the dispatchmgr
directly to dns_view_create() when it is attached and not just assigned,
so the dns_dispatchmgr doesn't cease to exist too early.

The dns_view_getdnsdispatchmgr() is now protected by the RCU lock, the
dispatchmgr reference is incremented, so the caller needs to detach from
it, and the function can return NULL in case the dns_view has been
already shut down.
2023-08-15 10:25:37 -07:00
Evan Hunt
b466439437
use a qp-trie for the keytable
Instead of an RBT for the trust anchor tables, use a QP-trie.
2023-08-15 14:25:24 +02:00
Evan Hunt
dea79e7053
use a qp-trie for the forwarders table
Instead of an RBT for the forwarders table, use a QP trie.

We now use reference counting for dns_forwarders_t. When a forwarders
object is retrieved by dns_fwdtable_find(), it must now be explicitly
detached by the caller afterward.

QP tries require stored objects to include their names, so the
the forwarders object now has that. This obviates the need to
pass back a separate 'foundname' value from dns_fwdtable_find().
2023-08-15 14:25:24 +02:00
Evan Hunt
5768dd96ea
clean up some unused functions
dns_fwdtable_delete() was only used by dns_client_clearservers(),
which in turn was never used. both functions have now been deleted.
2023-08-15 14:24:46 +02:00
Evan Hunt
aff01bda54
use a qp-trie for the NTA table
replace the red-black tree used by the negative trust anchor table
with a QP trie.

because of this change, dns_ntatable_init() can no longer fail, and
neither can dns_view_initntatable(). these functions have both been
changed to type void.
2023-08-15 14:24:46 +02:00
Evan Hunt
06216f4f90
rename dns_qp_findname_parent() to _findname_ancestor()
this function finds the closest matching ancestor, but the function
name could be read to imply that it returns the direct parent node;
this commit suggests a slightly less misleading name.
2023-08-15 14:24:46 +02:00
Tony Finch
b38c71961d
Improve qp-trie leaf return values
Make the `pval_r` and `ival_r` out arguments optional.

Add `pval_r` and `ival_r` out arguments to `dns_qp_deletekey()`
and `dns_qp_deletename()`, to return the deleted leaf.
2023-08-15 14:24:39 +02:00
Tony Finch
c622b349e4
Apply the SET_IF_NOT_NULL() semantic patch
spatch --sp-file cocci/set_if_not_null.spatch --use-gitgrep --dir "." --include-headers --in-place
2023-08-15 12:21:41 +02:00
Tony Finch
0d6dcd217d
A SET_IF_NOT_NULL() macro for optional return values
The SET_IF_NOT_NULL() macro avoids a fair amount of tedious boilerplate,
checking pointer parameters to see if they're non-NULL and updating
them if they are.  The macro was already in the dns_zone unit, and this
commit moves it to the <isc/util.h> header.

I have included a Coccinelle semantic patch to use SET_IF_NOT_NULL()
where appropriate. The patch needs an #include in `openssl_shim.c`
in order to work.
2023-08-15 12:04:29 +02:00
Matthijs Mekking
fa108db279 Revert a337dbef
Revert commit that always uses OpenSSL 3.0 API when available,
the new APIs should work always, but OpenSSL has non-obvious
omissions in the automatic mappings it provides.
2023-08-09 23:48:17 +00:00
Mark Andrews
00a09e0d35 Only set key->engine if engine != NULL 2023-08-09 23:48:17 +00:00
Mark Andrews
d527ae11c9 Fix clang formatting 2023-08-09 23:48:17 +00:00
Timo Teräs
de486d0ec5 Fix keyfromlabel to not use engine parameter for provider keys
- Rework key checks to not require 'engine' tag, private key
  is valid with 'label' tag alone

- Fix _fromlabel() functions to work with engine == NULL

- Update dst__openssl_fromlabel_engine() to do provider lookup
  only when engine is not set
2023-08-08 17:16:14 +03:00
Timo Teräs
a337dbef22 Always use OpenSSL 3.0 API when available
The new APIs work always as OpenSSL provides glue to access also
old style engines using the new APIs.
2023-08-08 14:08:00 +00:00
Timo Teräs
8de089e514 Fix support for engine/provider ECDSA keys
Exporting private key of on-token keys is not possible. Fix code
to not fail in this case.
2023-08-08 14:08:00 +00:00
Timo Teräs
de45aab184 Fix OpenSSL 3.0 API EC curve names
The OpenSSL man page examples used the NIST curve names which
are supported. But when querying the name, the native OpenSSL
name is returned. Use these names to pass curve type checks for
engine/provider objects.
2023-08-08 14:08:00 +00:00
Evan Hunt
b3c2b64662 use read lock in rdataset_getownercase()
we were incorrectly write-locking the node when retrieving
the owner case of an rdataset.
2023-08-03 13:26:27 -07:00
Matthijs Mekking
32686beabc Change default TTLsig to one week
Commit dc6dafdad1bce4c59bec0dbc355650c384cfc4d9 allows larger TTL values
in zones that go insecure, and ignores the maximum zone TTL.

This means that if you use TTL values larger than 1 day in your zone,
your zone runs the risk of going bogus before it moves safely to
insecure.

Most resolvers by default cap the maximum TTL that they cache RRsets,
at one day (Unbound, Knot, PowerDNS) so that is fine. However, BIND 9's
default is one week.

Change the default TTLsig to one week, so that also for BIND 9
resolvers in the default cases responses for zones that are going
insecure will not be evaluated as bogus.

This change does mean that when unsigning your zone, it will take six
days longer to safely go insecure, regardless of what TTL values you
use in the zone.
2023-08-02 11:16:50 +02:00
Matthijs Mekking
dc6dafdad1 Ignore max-zone-ttl on dnssec-policy insecure
Allow larger TTL values in zones that go insecure. This is necessary
because otherwise the zone will not be loaded due to the max-zone-ttl
of P1D that is part of the current insecure policy.

In the keymgr.c code, default back to P1D if the max-zone-ttl is set
to zero.
2023-08-01 08:56:52 +02:00