Commit graph

13884 commits

Author SHA1 Message Date
Artem Boldariev
bb8ba2c027 Update max concurrent streams limit in HTTP listeners on reconfig
This commit ensures that HTTP listeners concurrent streams limit gets
updated properly on reconfiguration.

(cherry picked from commit e72962d5f1)
2022-06-28 16:37:31 +03:00
Artem Boldariev
1ccbb24078 Update HTTP listeners quotas on reconfiguration
This commit ensures that on reconfiguration a proper value for HTTP
connections limit is picked up.

The commit also refactors how listeners settings are updated so that
there is less code duplication.

(cherry picked from commit a2379135fa)
2022-06-28 16:37:31 +03:00
Artem Boldariev
63a4c12227 Store HTTP quota size inside a listenlist instead of the quota
This way only quota size is passed to the interface/listener
management code instead of a quota object. Thus, we can implement
updating the quota object size instead of recreating the object.

(cherry picked from commit 3f0b310772)
2022-06-28 16:37:31 +03:00
Matthijs Mekking
35f6cabab4 Add isccfg duration utility functions
Add function isccfg_duration_toseconds and isccfg_parse_duration to get
rid of code duplication.

(cherry picked from commit d8dae61832)
2022-06-28 14:37:26 +02:00
Matthijs Mekking
feaf3950fd Fix a bug in the duration_fromtext function
The function actually did not enforce that the duration string starts
with a P (or p), just that there is a P (or p) in the string.

(cherry picked from commit 8e18fa5874)
2022-06-28 14:37:19 +02:00
Matthijs Mekking
8af88d4111 Also inherit from "default" for "insecure" policy
Remove the duplication from the defaultconf and inherit the values
not set in the "insecure" policy from the "default" policy. Therefore,
we must insist that the first read built-in policy is the default one.

(cherry picked from commit c2a7950417)
2022-06-28 14:37:10 +02:00
Matthijs Mekking
fd34ea8523 Nit changes in keymgr and kasp
Use the ISC_MAX define instead of "x = a > b ? a : b" paradigm.

Remove an unneeded include.

(cherry picked from commit 5d6f0de84b)
2022-06-28 14:36:53 +02:00
Matthijs Mekking
e16cfce91d When loading dnssec-policies, inherit from default
Most of the settings (durations) are already inheriting from the default
because they use the constants from lib/dns/kasp.h. We need them as
constants so we can use them in named-checkconf to verify the policy
parameters.

The NSEC(3) parameters and keys should come from the actual default
policy. Change the call to cfg_kasp_fromconfig() to include the default
kasp. We also no longer need to corner case where config is NULL we load
the built-in policy: the built-in policies are now loaded when config is
set to named_g_config.

Finally, add a debug log (it is useful to see which policies are being
loaded).

(cherry picked from commit 20acb8d3a3)
2022-06-28 14:36:45 +02:00
Matthijs Mekking
03c0c72aeb Store built-in dnssec-policies in defaultconf
Update the defaultconf with the built-in policies. These will now be
printed with "named -C".

Change the defines in kasp.h to be strings, so they can be concatenated
in the defaultconf. This means when creating a kasp structure, we no
longer initialize the defaults (this is fine because only kaspconf.c
uses dns_kasp_create() and it inherits from the default policy).

In kaspconf.c, the default values now need to be parsed from string.

Introduce some variables so we don't need to do get_duration multiple
times on the same configuration option.

Finally, clang-format-14 decided to do some random formatting changes.

(cherry picked from commit 5ff414e986)
2022-06-28 14:36:38 +02:00
Matthijs Mekking
4fb2ecd444 Move duration structure to libisccfg/duration
Having the duration structure and parsing code here, it becomes
more accessible to be used in other places.

(cherry picked from commit a28d919503)
2022-06-28 14:36:31 +02:00
Michał Kępień
457b666c6f Fix destination port extraction for client queries
The current logic for determining the address of the socket to which a
client sent its query is:

 1. Get the address:port tuple from the netmgr handle using
    isc_nmhandle_localaddr().

 2. Convert the address:port tuple from step 1 into an isc_netaddr_t
    using isc_netaddr_fromsockaddr().

 3. Convert the address from step 2 back into a socket address with the
    port set to 0 using isc_sockaddr_fromnetaddr().

Note that the port number (readily available in the netmgr handle) is
needlessly lost in the process, preventing it from being recorded in
dnstap captures of client traffic produced by named.

Fix by first storing the address:port tuple returned by
isc_nmhandle_localaddr() in client->destsockaddr and then creating an
isc_netaddr_t from that structure.  This allows the port number to be
retained in client->destsockaddr, which is what subsequently gets passed
to dns_dt_send().

(cherry picked from commit 2f945703f2)
2022-06-22 13:46:42 +02:00
Michal Nowak
d3eb307e3c
Update clang to version 14
(cherry picked from commit 1c45a9885a)
2022-06-16 18:09:33 +02:00
Artem Boldariev
b3490213eb CID 352848: split xfrin_start() and remove dead code
This commit separates TLS context creation code from xfrin_start() as
it has become too large and hard to follow into a new
function (similarly how it is done in dighost.c)

The dead code has been removed from the cleanup section of the TLS
creation code:

* there is no way 'tlsctx' can equal 'found';
* there is no way 'sess_cache' can be non-NULL in the cleanup section.

Also, it fixes a bug in the older version of the code, where TLS
client session context fetched from the cache would not get passed to
isc_nm_tlsdnsconnect().

(cherry picked from commit 98f758ed4f)
2022-06-15 17:02:45 +03:00
Artem Boldariev
334eeef5a1 Do not provide a shim for SSL_SESSION_is_resumable()
The recently added TLS client session cache used
SSL_SESSION_is_resumable() to avoid polluting the cache with
non-resumable sessions. However, it turned out that we cannot provide
a shim for this function across the whole range of OpenSSL versions
due to the fact that OpenSSL 1.1.0 does uses opaque pointers for
SSL_SESSION objects.

The commit replaces the shim for SSL_SESSION_is_resumable() with a non
public approximation of it on systems shipped with OpenSSL 1.1.0. It
is not turned into a proper shim because it does not fully emulate the
behaviour of SSL_SESSION_is_resumable(), but in our case it is good
enough, as it still helps to protect the cache from pollution.

For systems shipped with OpenSSL 1.0.X and derivatives (e.g. older
versions of LibreSSL), the provided replacement perfectly mimics the
function it is intended to replace.

(cherry picked from commit 40be3c9263)
2022-06-15 17:02:45 +03:00
Artem Boldariev
0cec9cca37 Fix an abort in DoH (client-side) when writing on closing sock
The commit fixes a corner case in client-side DoH code, when a write
attempt is done on a closing socket (session).

The change ensures that the write call-back will be called with a
proper error code (see failed_send_cb() call in client_httpsend()).

(cherry picked from commit 9abb00bb5f)
2022-06-15 17:02:45 +03:00
Artem Boldariev
cb6591f277 Avoid aborting when uv_timer_start() is used on a closing socket
In such a case it will return UV_EINVAL (-EINVAL), leading to
aborting, as the code expects the function to succeed.

(cherry picked from commit 245f7cec2e)
2022-06-15 17:02:45 +03:00
Artem Boldariev
5154bac7c5 Add SSL_SESSION_is_resumable() implementation shim
This commit adds SSL_SESSION_is_resumable() implementation if it is
missing.

(cherry picked from commit 35338b4105)
2022-06-15 17:02:45 +03:00
Artem Boldariev
e02284354a DoT: implement TLS client session resumption
This commit extends DoT code with TLS client session resumption
support implemented on top of the TLS client session cache.

(cherry picked from commit 86465c1dac)
2022-06-15 17:02:45 +03:00
Artem Boldariev
0a4a76ff7a TLS stream/DoH: implement TLS client session resumption
This commit extends TLS stream code and DoH code with TLS client
session resumption support implemented on top of the TLS client
session cache.

(cherry picked from commit 90bc13a5d5)
2022-06-15 17:02:45 +03:00
Artem Boldariev
6ec48f1e78 Extend TLS context cache with TLS client session cache
This commit extends TLS context cache with TLS client session cache so
that an associated session cache can be stored alongside the TLS
context within the context cache.

(cherry picked from commit 987892d113)
2022-06-15 17:02:45 +03:00
Artem Boldariev
7c8d76c458 Add TLS client session cache implementation
This commit adds an implementation of a client TLS session cache. TLS
client session cache is an object which allows efficient storing and
retrieval of previously saved TLS sessions so that they can be
resumed. This object is supposed to be a foundation for implementing
TLS session resumption - a standard technique to reduce the cost of
re-establishing a connection to the remote server endpoint.

OpenSSL does server-side TLS session caching transparently by
default. However, on the client-side, a TLS session to resume must be
manually specified when establishing the TLS connection. The TLS
client session cache is precisely the foundation for that.

(cherry picked from commit 4ef40988f3)
2022-06-15 17:02:45 +03:00
Artem Boldariev
9b320b1682 TLS DNS: do not call accept callback twice
Before the changes from this commit were introduced, the accept
callback function will get called twice when accepting connection
during two of these stages:

* when accepting the TCP connection;
* when handshake has completed.

That is clearly an error, as it should have been called only once. As
far as I understand it the mistake is a result of TLS DNS transport
being essentially a fork of TCP transport, where calling the accept
callback immediately after accepting TCP connection makes sense.

This commit fixes this mistake. It did not have any very serious
consequences because in BIND the accept callback only checks an ACL
and updates stats.

(cherry picked from commit e616d7f240)
2022-06-15 15:32:49 +03:00
Aram Sargsyan
12aefe6ced Fix a race condition between shutdown and route_connected()
When shutting down, the interface manager can be destroyed
before the `route_connected()` callback is called, which is
unexpected for the latter and can cause a crash.

Move the interface manager attachment code from the callback
to the place before the callback is registered using
`isc_nm_routeconnect()` function, which will make sure that
the interface manager will live at least until the callback
is called.

Make sure to detach the interface manager if the
`isc_nm_routeconnect()` function is not implemented, or when
the callback is called with a result value which differs from
`ISC_R_SUCCESS`.

(cherry picked from commit f6e729635f)
2022-06-14 14:57:23 +00:00
Aram Sargsyan
e92b261235 Do not use the interface manager until it is ready
The `ns_interfacemgr_create()` function, when calling
`isc_nm_routeconnect()`, uses the newly created `ns_interfacemgr_t`
instance before initializing its reference count and the magic value.

Defer the `isc_nm_routeconnect()` call until the initializations
are complete.

(cherry picked from commit 1d93fe973b)
2022-06-14 14:55:57 +00:00
Ondřej Surý
579270509f Gracefully handle uv_read_start() failures
Under specific rare timing circumstances the uv_read_start() could
fail with UV_EINVAL when the connection is reset between the connect (or
accept) and the uv_read_start() call on the nmworker loop.  Handle such
situation gracefully by propagating the errors from uv_read_start() into
upper layers, so the socket can be internally closed().

(cherry picked from commit b432d5d3bc)
2022-06-14 11:54:11 +02:00
JINMEI Tatuya
5068ee73d6 make the fix more complete
(cherry picked from commit a58647df6a)
2022-06-14 12:06:54 +10:00
JINMEI Tatuya
430a52883d corrected the opcode param to opcode_totext
(cherry picked from commit 2b81a69659)
2022-06-14 12:06:54 +10:00
Aram Sargsyan
8e8b44649f Cleanup dns_fwdtable_delete()
The conversion of `DNS_R_PARTIALMATCH` into `DNS_R_NOTFOUND` is done
in the `dns_rbt_deletename()` function so there is no need to do that
in `dns_fwdtable_delete()`.

Add a possible return value of `ISC_R_NOSPACE` into the header file's
function description comment.

(cherry picked from commit 887aa7a290)
2022-06-09 10:52:04 +00:00
Aram Sargsyan
475e790e03 Check that catz member zone is not a configured forward zone
When processing a catalog zone member zone make sure that there is no
configured pre-existing forward zone with that name.

Refactor the `dns_fwdtable_find()` function to not alter the
`DNS_R_PARTIALMATCH` result (coming from `dns_rbt_findname()`) into
`DNS_R_SUCCESS`, so that now the caller can differentiate partial
and exact matches. Patch the calling sites to expect and process
the new return value.

(cherry picked from commit 2aff264fb1)
2022-06-09 10:50:32 +00:00
Aram Sargsyan
1355fc6a04 Don't process DNSSEC-related and ZONEMD records in catz
When processing a catalog zone update, skip processing records with
DNSSEC-related and ZONEMD types, because we are not interested in them
in the context of a catalog zone, and processing them will fail and
produce an unnecessary warning message.

(cherry picked from commit 73d6643137)
2022-06-02 10:20:11 +00:00
Mark Andrews
7d14346e5f Add missing INDENT call for UPDATE messages
Reported by Peter <pmc@citylink.dinoex.sub.org> on bind-users.

(cherry picked from commit 03132c93ca)
2022-06-02 08:28:15 +10:00
Matthijs Mekking
42711dae88 Only log "new successor in ..." if prepub != 0
If 'prepub' is 0, this has the special meaning that no rollover is
scheduled. If so, don't log "new successor in x seconds".

(cherry picked from commit 955a69109e)
2022-05-31 17:17:05 +02:00
Matthijs Mekking
3cfbe31176 Error if key lifetime is too short
The key lifetime should not be shorter than the time it costs to
introduce the successor key, otherwise keys will be created faster than
they are removed, resulting in a large key set.

The time it takes to replace a key is determined by the publication
interval (Ipub) of the successor key and the retire interval of the
predecessor key (Iret).

For the ZSK, Ipub is the sum of the DNSKEY TTL and zone propagation
delay (and publish safety). Iret is the sum of Dsgn, the maximum zone
TTL and zone propagation delay (and retire safety). The sign delay is
the signature validity period minus the refresh interval: The time to
ensure that all existing RRsets have been re-signed with the new key.
The ZSK lifetime should be larger than both values.

For the KSK, Ipub is the sum of the DNSKEY TTL and zone propagation
delay (and publish safety). Iret is the sum of the DS TTL and parent
zone propagation delay (and retire safety). The KSK lifetime should be
larger than both values.

(cherry picked from commit 8134d46cdb)
2022-05-31 17:16:53 +02:00
Matthijs Mekking
46636b8563 Error if signatures-refresh is too high
The signatures-refresh should not near the signatures-validity value,
to prevent operational instability. Same is true when checking against
signatures-validity-dnskey.

(cherry picked from commit 82fd89107f)
2022-05-31 17:16:40 +02:00
Matthijs Mekking
b32a39dd27 Warn if key lifetime is short
Log a warning if the key lifetime is less than 30 days.

(cherry picked from commit e7322e8f78)
2022-05-31 17:16:35 +02:00
Matthijs Mekking
58690ec11c Warn if multiple keys have same role
If a dnssec-policy has multiple keys configured with the
same algorithm and role.

(cherry picked from commit f54dad005e)
2022-05-31 17:16:29 +02:00
Ondřej Surý
f128a9bcf2 Move all the unit tests to /tests/<libname>/
The unit tests are now using a common base, which means that
lib/dns/tests/ code now has to include lib/isc/include/isc/test.h and
link with lib/isc/test.c and lib/ns/tests has to include both libisc and
libdns parts.

Instead of cross-linking code between the directories, move the
/lib/<foo>/test.c to /tests/<foo>.c and /lib/<foo>/include/<foo>test.h
to /tests/include/tests/<foo>.h and create a single libtest.la
convenience library in /tests/.

At the same time, move the /lib/<foo>/tests/ to /tests/<foo>/ (but keep
it symlinked to the old location) and adjust paths accordingly.  In few
places, we are now using absolute paths instead of relative paths,
because the directory level has changed.  By moving the directories
under the /tests/ directory, the test-related code is kept in a single
place and we can avoid referencing files between libns->libdns->libisc
which is unhealthy because they live in a separate Makefile-space.

In the future, the /bin/tests/ should be merged to /tests/ and symlink
kept, and the /fuzz/ directory moved to /tests/fuzz/.

(cherry picked from commit 2c3b2dabe9)
2022-05-31 12:06:00 +02:00
Ondřej Surý
f0df0d679a Give the unit tests a big overhaul
The unit tests contain a lot of duplicated code and here's an attempt
to reduce code duplication.

This commit does several things:

1. Remove #ifdef HAVE_CMOCKA - we already solve this with automake
   conditionals.

2. Create a set of ISC_TEST_* and ISC_*_TEST_ macros to wrap the test
   implementations, test lists, and the main test routine, so we don't
   have to repeat this all over again.  The macros were modeled after
   libuv test suite but adapted to cmocka as the test driver.

   A simple example of a unit test would be:

    ISC_RUN_TEST_IMPL(test1) { assert_true(true); }

    ISC_TEST_LIST_START
    ISC_TEST_ENTRY(test1)
    ISC_TEST_LIST_END

    ISC_TEST_MAIN (Discussion: Should this be ISC_TEST_RUN ?)

   For more complicated examples including group setup and teardown
   functions, and per-test setup and teardown functions.

3. The macros prefix the test functions and cmocka entries, so the name
   of the test can now match the tested function name, and we don't have
   to append `_test` because `run_test_` is automatically prepended to
   the main test function, and `setup_test_` and `teardown_test_` is
   prepended to setup and teardown function.

4. Update all the unit tests to use the new syntax and fix a few bits
   here and there.

5. In the future, we can separate the test declarations and test
   implementations which are going to greatly help with uncluttering the
   bigger unit tests like doh_test and netmgr_test, because the test
   implementations are not declared static (see `ISC_RUN_TEST_DECLARE`
   and `ISC_RUN_TEST_IMPL` for more details.

NOTE: This heavily relies on preprocessor macros, but the result greatly
outweighs all the negatives of using the macros.  There's less
duplicated code, the tests are more uniform and the implementation can
be more flexible.

(cherry picked from commit 63fe9312ff)
2022-05-31 11:34:54 +02:00
Petr Menšík
d074386ef1 Fix failures in isc netmgr_test on big endian machines
Typing from libuv structure to isc_region_t is not possible, because
their sizes differ on 64 bit architectures. Little endian machines seems
to be lucky and still result in test passed. But big endian machine such
as s390x fails the test reliably.

Fix by directly creating the buffer as isc_region_t and skipping the
type conversion. More readable and still more correct.

(cherry picked from commit 057438cb45)
2022-05-24 20:22:57 +02:00
Matthijs Mekking
0ae48af8b2 Require valid key for dst_key functions
Make sure that the key structure is valid when calling the following
functions:
- dst_key_setexternal
- dst_key_isexternal
- dst_key_setmodified
- dst_key_ismodified

(cherry picked from commit 888ec4e0d4)
2022-05-23 12:00:53 +02:00
Matthijs Mekking
ca7e3e25c4 Fix CID 352776: Concurrent data access violations
*** CID 352776:  Concurrent data access violations  (MISSING_LOCK)
/lib/dns/dst_api.c: 474 in dst_key_setmodified()
468     dst_key_isexternal(dst_key_t *key) {
469		return (key->external);
470     }
471
472     void
473     dst_key_setmodified(dst_key_t *key, bool value) {
>>>     CID 352776:  Concurrent data access violations  (MISSING_LOCK)
>>>     Accessing "key->modified" without holding lock
>>>	"dst_key.mdlock". Elsewhere, "dst_key.modified" is accessed with
>>>	"dst_key.mdlock" held 8 out of 11 times (8 of these accesses
>>>	strongly imply that it is necessary).
474		key->modified = value;
475     }
476
477     bool
478     dst_key_ismodified(dst_key_t *key) {
479		return (key->modified);

(cherry picked from commit 1fa24d0afb)
2022-05-23 12:00:45 +02:00
Ondřej Surý
eabee4d7d9 Move setting the sock->write_timeout to the async_*send
Setting the sock->write_timeout from the TCP, TCPDNS, and TLSDNS send
functions could lead to (harmless) data race when setting the value for
the first time when the isc_nm_send() function would be called from
thread not-matching the socket we are sending to.  Move the setting the
sock->write_timeout to the matching async function which is always
called from the matching thread.

(cherry picked from commit 61117840c1)
2022-05-19 22:37:52 +02:00
Ondřej Surý
b4521486ed Use C2x [[fallthrough]] when supported by LLVM/clang
Clang added support for the gcc-style fallthrough
attribute (i.e. __attribute__((fallthrough))) in version 10.  However,
__has_attribute(fallthrough) will return 1 in C mode in older versions,
even though they only support the C++11 fallthrough attribute. At best,
the unsupported attribute is simply ignored; at worst, it causes errors.

The C2x fallthrough attribute has the advantages of being supported in
the broadest range of clang versions (added in version 9) and being easy
to check for support. Use C2x [[fallthrough]] attribute if possible, and
fall back to not using an attribute for clang versions that don't have
it.

Courtesy of Joshua Root

(cherry picked from commit 14c8d43863)
2022-05-19 22:01:59 +02:00
Michal Nowak
4dde80f655 BIND 9.18.3
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEIz+ZTe/bbr1Q+/5RJKPoRjruXlYFAmJ5PF8ACgkQJKPoRjru
 XlZqfg/+NRV6vVEJFKbL+GEUebt9Wfx+6Oqss78FutKqUjblHX18Ga8rEBHirnSr
 DsUB7LczqGUl/GJfgHkRyteBBrbEjpszkAtxXBCniJhz+mOuYRTrutB1xP43Wj/i
 2XeG3cWhjkBymVblL0xKBdBtl1ySblA+xWdp4G3vF3gRzOf/APVmdhKciA5km02s
 Kk4P2TeCjlNfSzPdwSByydnq/Ik/N1dGZDe+FKuIleULg5WZI6PMfzSy35rPDaYW
 e8NIaybjFiboTPv65L0kW/nEainNIiam4jeEOnQs0M/iKKHqILwZx/+j74E8f4qh
 P/Xdjy9voHkJpAeKSl/ZkOaBVGY9yNm5dXrNMB1926tKJ1FciH6qdfBI/s0AhZ0g
 QEVpBigM2L1rl6MobuHQ3WPkax8NcUpndDdCteZkdh5HcmRrGrw/JH1GvzSNq+75
 L3P2wciNoC9aZaXOo3FOSPRiOENUNGZjcLxntCLsJZ/B0n4Zv+vOFeNZGQTt4PC5
 Aly1LbsrOn/kbXKOiZcoEny4YQGPG55lEU+Yb6SLe5vahx24bGe2K3aP12WRy7x+
 2hcAbanoI97t+95Q1el8i3ekg9nYsE/tIbKAlHmnb/xChd4n4BSCHJBAZMgMA5Tk
 n0JbhxwTTWW3dewQzTr6jvCqi/2i5tQJCuGlhnerkgWZezk47Ko=
 =hIP4
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEIz+ZTe/bbr1Q+/5RJKPoRjruXlYFAmKGFw4ACgkQJKPoRjru
 XlZK2Q//fy+tcGiqwxMBwhVhrkMGL4L2CKrlMgs4/DZJKnTb01IHr3DwB+Ag4iVk
 LkK9e8plr/Hf/VZ5LaV2mkk5fCdImZdP24AgpIg9VSaf+tlm6PhdPadWL6ucXayI
 TndnxLV6TdXkySu4zzWcXxgwFxUy3mku4QlAQD3UNCsikqyiUGDOP3Z/BNi9OU10
 YidisnDiPWMNBCvOU9ThPAKcGIHCwvk5rkcno771d/izvLbBWrtQh/8iKqMP6gyT
 dsB8Oq4mlPJ5gh4yv0LLmyUiNFg4CSEVxfWd6PRmZlvXtwOQqA1tKR7srPXwrHxd
 bx+5bbZtQKqEi8l/UYdHhyqaPdPWnUaydzU1LzhUSHJK2f9pEDOfBlOj82Z0hMm2
 T6EaoyykIqyhngSFK9Ef+sCAZ3qrss96bRPSN8gOpn6I6sioH+Bp+E3cBDVTkyRA
 rVKTA0HLegRH2/QnPJjHAu7I6YPE36LZu7kZdEiw8ysqWcIEva8E/PFv2YBJxAv1
 SjEdhzfxVf9ncWndrgC1OjsoDucxYolg1sUCZ776e/E7MzAkOo1cqTXqhi6pcHT0
 OGMmJVitPXJ5bxiZpK1QZ46DqxwHLolk9gImnNvE01vJRxltWKqtdV1dH6Ca6MWo
 s6qMxFcIwmI4Zgq3V933CoD8HCmYW8W7UQ1tEXmDfPwEueqzoTs=
 =/ei9
 -----END PGP SIGNATURE-----

Merge tag 'v9_18_3' into v9_18

BIND 9.18.3
2022-05-19 12:07:45 +02:00
Matthijs Mekking
9b6a20b42e Check if key metadata is modified before writing
Add a new parameter to the dst_key structure, mark a key modified if
dst_key_(un)set[bool,num,state,time] is called. Only write out key
files during a keymgr run if the metadata has changed.

(cherry picked from commit 1da91b3ab4)
2022-05-16 10:37:23 +02:00
Evan Hunt
60e25826c6 Cleanup: always count ns_statscounter_recursclients
The ns_statscounter_recursclients counter was previously only
incremented or decremented if client->recursionquota was non-NULL.
This was harmless, because that value should always be non-NULL if
recursion is enabled, but it made the code slightly confusing.

(cherry picked from commit 0201eab655)
2022-05-14 00:59:09 -07:00
Evan Hunt
bca7f19541 Fix the fetches-per-server quota calculation
Since commit bad5a523c2, when the fetches-per-server quota
was increased or decreased, instead of the value being set to
the newly calculated quota, it was set to the *minimum* of
the new quota or 1 - which effectively meant it was always set to 1.
it should instead have been the maximum, to prevent the value from
ever dropping to zero.

(cherry picked from commit 694bc50273)
2022-05-14 00:43:17 -07:00
Evan Hunt
e117244850 prevent a possible buffer overflow in configuration check
corrected code that could have allowed a buffer overfow while
parsing named.conf.

(cherry picked from commit 921043b541)
2022-05-13 20:29:36 -07:00
Ondřej Surý
71b0e9e5b7 Lock the trampoline when attaching
When attaching to the trampoline, the isc__trampoline_max was access
unlocked.  This would not manifest under normal circumstances because we
initialize 65 trampolines by default and that's enough for most
commodity hardware, but there are ARM machines with 128+ cores where
this would be reported by ThreadSanitizer.

Add locking around the code in isc__trampoline_attach().  This also
requires the lock to leak on exit (along with memory that we already)
because a new thread might be attaching to the trampoline while we are
running the library destructor at the same time.

(cherry picked from commit 933162ae14)
2022-05-13 13:21:49 +02:00
Artem Boldariev
bd41100295
Fix a crash by avoiding destroying TLS stream socket too early
This commit fixes a crash in generic TLS stream code, which could be
reproduced during some runs of the 'sslyze' tool.

The intention of this commit is twofold.

Firstly, it ensures that the TLS socket object cannot be destroyed too
early. Now it is being deleted alongside the underlying TCP socket
object.

Secondly, it ensures that the TLS socket object cannot be destroyed as
a result of calling 'tls_do_bio()' (the primary function which
performs encryption/decryption during the IO) as the code did not
expect that. This code path is fixed now.

(cherry picked from commit a696be6a2d)
2022-05-04 19:56:57 +02:00