Commit Graph

38009 Commits

Author SHA1 Message Date
Ondřej Surý
a1d45685e6 Move and extend the uint8_t low-endian to uint{32,64}t to endian.h
Move the U8TO{32,64}_LE and U{32,64}TO8_LE macros to endian.h and extend
the macros for 16-bit and Big-Endian variants.

Use the macros both in isc_siphash (LE) and isc_buffer (BE) units.
2022-12-20 19:13:48 +01:00
Ondřej Surý
aea251f3bc Change the isc_buffer_reserve() to take just buffer pointer
The isc_buffer_reserve() would be passed a reference to the buffer
pointer, which was unnecessary as the pointer would never be changed
in the current implementation.  Remove the extra dereference.
2022-12-20 19:13:48 +01:00
Ondřej Surý
9fd83ea971 Merge branch '3178-dispatch-race' into 'main'
Fix the thread safety in the dns_dispatch unit

Closes #3178

See merge request isc-projects/bind9!7025
2022-12-19 12:07:12 +00:00
Ondřej Surý
2df311eb21 Add CHANGES and release note for [GL #3178] and [GL #3636] 2022-12-19 11:42:50 +01:00
Ondřej Surý
6f317f27ea Fix the thread safety in the dns_dispatch unit
The dispatches are not thread-bound, and used freely between various
threads (see the dns_resolver and dns_request units for details).

This refactoring make sure that all non-const dns_dispatch_t and
dns_dispentry_t members are accessed under a lock, and both object now
track their internal state (NONE, CONNECTING, CONNECTED, CANCELED)
instead of guessing the state from the state of various struct members.

During the refactoring, the artificial limit DNS_DISPATCH_SOCKSQUOTA on
UDP sockets per dispatch was removed as the limiting needs to happen and
happens on in dns_resolver and limiting the number of UDP sockets
artificially in dispatch could lead to unpredictable behaviour in case
one dispatch has the limit exhausted by others are idle.

The TCP artificial limit of DNS_DISPATCH_MAXREQUESTS makes even less
sense as the TCP connections are only reused in the dns_request API
that's not a heavy user of the outgoing connections.

As a side note, the fact that UDP and TCP dispatch pretends to be same
thing, but in fact the connected UDP is handled from dns_dispentry_t and
dns_dispatch_t acts as a broker, but connected TCP is handled from
dns_dispatch_t and dns_dispatchmgr_t acts as a broker doesn't really
help the clarity of this unit.

This refactoring kept to API almost same - only dns_dispatch_cancel()
and dns_dispatch_done() were merged into dns_dispatch_done() as we need
to cancel active netmgr handles in any case to not leave dangling
connections around.  The functions handling UDP and TCP have been mostly
split to their matching counterparts and the dns_dispatch_<function>
functions are now thing wrappers that call <udp|tcp>_dispatch_<function>
based on the socket type.

More debugging-level logging was added to the unit to accomodate for
this fact.
2022-12-19 11:42:13 +01:00
Ondřej Surý
5b79127780 Merge branch '3712-fix-reference-counting-in-dns_adb-get_attached_entry-v2' into 'main'
Fix reference counting in get_attached_entry (again)

Closes #3712

See merge request isc-projects/bind9!7250
2022-12-16 20:49:49 +00:00
Ondřej Surý
32ff134eeb Fix reference counting in get_attached_entry (again)
When get_attached_entry() encounters entry that would be expired, it
needs to get reference to the entry before calling maybe_expire_entry(),
so the ADB entry doesn't get destroyed inside the its own lock.

This creeped into the code base again during review, so I am adding
an extra comment to prevent this.
2022-12-16 21:48:43 +01:00
Tom Krizek
096b047628 Merge branch 'tkrizek/danger-backports' into 'main'
Check backport workflow in danger CI

See merge request isc-projects/bind9!7243
2022-12-16 13:18:01 +00:00
Tom Krizek
e8a5ebaee5 danger: remove obsolete check for cherry pick msg
With proper backport commit detection, this check has been made
redundant.
2022-12-16 13:37:12 +01:00
Tom Krizek
c617f97784 danger: check backport commits for original commit IDs
A full backport must have all the commit from the original MR and the
original commit IDs must be referenced in the backport commit messages.

If the criteria above is not met, the MR should be marked as a partial
backport. In that case, any discrepencies are only logged as informative
messages rather than failures.
2022-12-16 13:37:12 +01:00
Tom Krizek
89530f1a1c danger: check that original MR has been merged
When checking a backport MR, ensure that the original MR has been merged
already. This is vital for followup checks that verify commit IDs from
original commits are present in backport commit messages.
2022-12-16 13:37:12 +01:00
Tom Krizek
12e0b05738 danger: check backport links to the original MR
When doing archeology, it is much easier to find stuff if it's properly
linked. This check ensures that backport MR are linked to their original
MR via a "Backport of !XXXX" message.

The regular expression is fairly broad and has been tested to accept the
following variants of the message:
Backport of MR !XXXX
Backport of: !XXXX
backport of mr !XXXX
Backport of   !XXXX
Backport of https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/XXXX
2022-12-16 13:37:12 +01:00
Tom Krizek
14b027cf83 danger: ensure target branch is in the MR title
Having the MR title clearly marked in its title can be very useful when
looking through older issues/MRs.

This check also ensures that the version from the version label matches
the proper version branch (i.e. v9.16 must be marked with [v9_16]).
2022-12-16 13:37:11 +01:00
Tom Krizek
1c0c1ba8b9 danger: support partial backport label
Treat the Backport::Partial label as a backport as well.
2022-12-16 13:37:10 +01:00
Tony Finch
94f2da42e0 Merge branch '3740-rpz-reconfig' into 'main'
A couple of RPZ options were not reconfigured as expected

Closes #3740

See merge request isc-projects/bind9!7230
2022-12-16 09:48:35 +00:00
Tony Finch
d8a3d328db A couple of RPZ options were not reconfigured as expected
[bug]	Changes to the RPZ response-policy min-update-interval
	and add-soa options now take effect as expected when
	named is reconfigured. [GL #3740]
2022-12-15 16:21:38 +00:00
Ondřej Surý
1af9aa849e Merge branch '3739-adb-cleans-overzealously-under-memory-pressure' into 'main'
Exclude the ADB hashmaps from ADB overmem accounting

Closes #3739

See merge request isc-projects/bind9!7228
2022-12-15 15:44:01 +00:00
Ondřej Surý
11df7f02fd Add CHANGES and release note for [GL #3739] 2022-12-15 16:15:39 +01:00
Ondřej Surý
0b661b6f95 Don't expire fresh ADB names and entries
The overmem cleaning in ADB could become overzealous and clean fresh ADB
names and entries.  Add a safety check to not clean any ADB names and
entries that are below ADB_CACHE_MINIMUM threshold.
2022-12-15 16:15:19 +01:00
Ondřej Surý
59dee0b078 Exclude the ADB hashmaps from ADB overmem accounting
The ADB overmem accounting would include the memory used by hashtables
thus vastly reducing the space that can be used for ADB names and
entries when the hashtables would grow.  Create own memory context for
the ADB names and entries hash tables.
2022-12-15 16:14:16 +01:00
Ondřej Surý
f74841fab7 Merge branch 'ondrej-fix-data-race-in-dns_adb' into 'main'
Lock the adbname and adbentry prior to unlocking hash locks

See merge request isc-projects/bind9!7216
2022-12-15 14:58:56 +00:00
Ondřej Surý
a27ea1bba0 Lock the adbname and adbentry prior to unlocking hash locks
There was a datarace that could expire a freshly created ADB names and
entries between the return from get_attached_{name,entry} and locking it
again.  Lock the ADB name and ADB entry inside the hash table lock, so
they won't get expired until the full initialization has been complete.
2022-12-15 15:19:22 +01:00
Arаm Sаrgsyаn
b8a915b0ac Merge branch '3742-catz-update-log-incorrect-soa-serial-representation' into 'main'
Fix an incorrect SOA serial representation in catz

Closes #3742

See merge request isc-projects/bind9!7229
2022-12-15 13:51:18 +00:00
Aram Sargsyan
ac7149aa88 Add a CHANGES note for [GL #3742] 2022-12-15 13:27:09 +00:00
Aram Sargsyan
72b1760ea6 Fix logging a uint32_t SOA serial value in dns_catz_update_from_db()
The dns_catz_update_from_db() function prints serial number as a signed
number (with "%d" in the format string), but the `vers` variable's type
is 'uint32_t'. This breaks serials bigger than 2^31.

Use PRIu32 instead of "d" in the format string.
2022-12-15 13:24:58 +00:00
Aram Sargsyan
de232ab446 Add big SOA serial logging check into the catz system test
Check that the SOA serial numbers printed when updating a catalog zone
is represented correctly for numbers bigger than 2^31.
2022-12-15 13:24:58 +00:00
Arаm Sаrgsyаn
3600e0f491 Merge branch 'aram/dns_adb_getcookie-cleanup' into 'main'
Clean up and refactor dns_adb_getcookie()

See merge request isc-projects/bind9!7211
2022-12-15 13:22:54 +00:00
Aram Sargsyan
03442d922b Clean up and refactor dns_adb_getcookie()
The dns_adb_getcookie() doesn't use the 'adb' parameter, remove it.

Refactor the dns_adb_getcookie() function to just return the size of
the cookie when the caller passes 'NULL' as the 'cookie' argument.
2022-12-15 12:34:26 +00:00
Ondřej Surý
5266444e35 Merge branch 'ondrej-use-isc_hashmap-for-zonemgr_keymgmt' into 'main'
Replace zonemgr_keymgmt own hash table with isc_hashmap

See merge request isc-projects/bind9!7191
2022-12-14 18:39:41 +00:00
Ondřej Surý
578de673b1 Replace zonemgr_keymgmt own hash table with isc_hashmap
Instead of maintaining own hashtable implementation for zonemgr_keymgmt,
use isc_hashmap that already can resize (grow and shrink).
2022-12-14 19:37:07 +01:00
Ondřej Surý
ea88da8692 Merge branch 'ondrej-add-more-logging-to-netmgr' into 'main'
Add internal logging functions to the netmgr

See merge request isc-projects/bind9!7233
2022-12-14 18:35:17 +00:00
Ondřej Surý
52307f8116 Add internal logging functions to the netmgr
Add internal logging functions isc__netmgr_log, isc__nmsocket_log(), and
isc__nmhandle_log() that can be used to add logging messages to the
netmgr, and change all direct use of isc_log_write() to use those
logging functions to properly prefix them with netmgr, nmsocket and
nmsocket+nmhandle.
2022-12-14 19:34:48 +01:00
Ondřej Surý
eeb545a2a9 Merge branch '3637-try-next-server-on-resolver-timeout' into 'main'
Try next server on resolver timeout

Closes #3637

See merge request isc-projects/bind9!7212
2022-12-14 17:52:32 +00:00
Ondřej Surý
d1f1db2f5a Add CHANGES and release notes for [GL #3637] 2022-12-14 18:49:54 +01:00
Ondřej Surý
b8c7dc2dc2 Expire names in shutdown_names() under the lock
Since there could be fetches running, we need to run expire_name() under
the lock when shutting down the names.
2022-12-14 18:49:18 +01:00
Ondřej Surý
32c2acf6fc Add comment why statistics/ns3 has misconfigure root.hints
To count pending queries in the statistics, we need the ns3 to be
misconfigured.  Document the fact in the statistics/ns3/root.hints.
2022-12-14 18:49:18 +01:00
Ondřej Surý
b679640950 Revert the statistics system test change after we fixed the resolver
When the resolver was refactored, the statistics system test had to be
adjusted in c6b4d82557.  Unfortunately,
this change had to be done because of an error in the resolver
refactoring where timeout would not retry next server, but keep trying
the same server.  As we have now fixed this bug, revert the change to
the test back to the previous state.
2022-12-14 18:49:18 +01:00
Ondřej Surý
5466a48fc9 Try next server on resolver timeout
Instead of resending to the same server on the (dispatch) timeout in the
resolver, try the next server.
2022-12-14 18:49:18 +01:00
Ondřej Surý
d0d4a7ede7 Merge branch 'ondrej-allow-zero-length-keys-in-isc_hashmap' into 'main'
Allow zero length keys in isc_hashmap

See merge request isc-projects/bind9!7198
2022-12-14 17:01:54 +00:00
Ondřej Surý
7cefcb6184 Allow zero length keys in isc_hashmap
In case, we are trying to hash the empty key into the hashmap, the key
is going to have zero length.  This might happen in the unit test.
Allow this and add a unit test to ensure the empty zero-length key
doesn't hash to slot 0 as SipHash 2-4 (our hash function of choice) has
no problem with zero-length inputs.
2022-12-14 17:59:07 +01:00
Artem Boldariev
8a35d52807 Merge branch '3725-mutual-tls-session-resumption-fix' into 'main'
Fix TLS session resumption via IDs when Mutual TLS is used

Closes #3725

See merge request isc-projects/bind9!7215
2022-12-14 16:36:53 +00:00
Artem Boldariev
67d74e228f Update Release notes [GL #3725]
Mention that TLS session resumption for Mutual TLS has been fixed.
2022-12-14 18:08:51 +02:00
Artem Boldariev
d8e04cdbc7 Update CHANGES [GL #3725]
Mention that TLS session resumption for Mutual TLS has been fixed.
2022-12-14 18:07:03 +02:00
Artem Boldariev
d5d31c6ba1 Extend the 'doth' system test with a Mutual TLS resumption check
This commit adds a simple check to the 'doth' system test which
ensures that session resumption when Mutual TLS is used works as
expected.
2022-12-14 18:06:20 +02:00
Artem Boldariev
837fef78b1 Fix TLS session resumption via IDs when Mutual TLS is used
This commit fixes TLS session resumption via session IDs when
client certificates are used. To do so it makes sure that session ID
contexts are set within server TLS contexts. See OpenSSL documentation
for 'SSL_CTX_set_session_id_context()', the "Warnings" section.
2022-12-14 18:06:20 +02:00
Tony Finch
39e57ab133 Merge branch 'fanf-dnssec-algorithm-loglevel' into 'main'
List supported DNSSEC algorithms at log level NOTICE

See merge request isc-projects/bind9!7217
2022-12-14 11:02:15 +00:00
Tony Finch
72f8d03cad List supported DNSSEC algorithms at log level NOTICE
NOTICE matches the other startup messages. WARNING weirdly
suggests the list is a problem.
2022-12-14 11:01:22 +00:00
Ondřej Surý
27376b9a8e Merge branch '3736-fix-intermittent-memory-leak-in-forward-system-test' into 'main'
Fix intermittent memory leak in dns_resolver unit

Closes #3736

See merge request isc-projects/bind9!7214
2022-12-14 09:48:37 +00:00
Ondřej Surý
7292ee6d92 Fix intermittent memory leak in dns_resolver unit
A rdataset could have been left unassociated on the error path in the
resume_dslookup() in the dns_resolver unit.  Clone the rdataset after
the error check, so it's not cloned before we check whether we can make
further progress chasing DS records.
2022-12-14 10:48:06 +01:00
Mark Andrews
282d4ea645 Merge branch '3737-fix-initialisation-of-local-in-isdotlocal-in-dig' into 'main'
Resolve "fix initialisation of local. in isdotlocal in dig"

Closes #3737

See merge request isc-projects/bind9!7213
2022-12-13 23:27:50 +00:00