2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00
Commit Graph

39293 Commits

Author SHA1 Message Date
Michał Kępień
a47dc810f7 Add a tool for reproducing ISC SPNEGO bugs
Extend the "tsiggss" system test with reproducers for CVE-2020-8625 and
CVE-2021-25216.
2023-06-19 09:20:03 +02:00
Tony Finch
5f9790feca Merge branch '4126-statschannel-connection-close-keepalive' into 'main'
Improve statschannel HTTP Connection: header logic

See merge request isc-projects/bind9!8014
2023-06-15 16:03:51 +00:00
Tony Finch
e18ca83a3b Improve statschannel HTTP Connection: header protocol conformance
In HTTP/1.0 and HTTP/1.1, RFC 9112 section 9.6 says the last response
in a connection should include a `Connection: close` header, but the
statschannel server omitted it.

In an HTTP/1.0 response, the statschannel server can sometimes send a
`Connection: keep-alive` header when it is about to close the
connection. There are two ways:

If the first request on a connection is keep-alive and the second
request is not, then _both_ responses have `Connection: keep-alive`
but the connection is (correctly) closed after the second response.

If a single request contains

	Connection: close
	Connection: keep-alive

then RFC 9112 section 9.3 says the keep-alive header is ignored, but
the statschannel sends a spurious keep-alive in its response, though
it correctly closes the connection.

To fix these bugs, make it more clear that the `httpd->flags` are part
of the per-request-response state. The Connection: flags are now
described in terms of the effect they have instead of what causes them
to be set.
2023-06-15 17:03:09 +01:00
Michał Kępień
a0efcf0e58 Merge branch '4150-fix-entity-renumbering-in-parse_tsan.py' into 'main'
Fix entity renumbering in util/parse_tsan.py

Closes #4150

See merge request isc-projects/bind9!8037
2023-06-15 14:18:30 +00:00
Michał Kępień
7f0790c82f Fix entity renumbering in util/parse_tsan.py
util/parse_tsan.py builds tables of mutexes, threads, and pointers it
finds in the TSAN report provided to it as a command-line argument and
then replaces all mentions of each of these entities so that they are
numbered sequentially in the processed report.  For example, this line:

    Cycle in lock order graph: M0 (...) => M5 (...) => M9 (...) => M0

is expected to become:

    Cycle in lock order graph: M1 (...) => M2 (...) => M3 (...) => M1

Problems arise when the gaps between mutex/thread identifiers present on
a single line are smaller than the total number of mutexes/threads found
by the script so far.  For example, the following line:

    Cycle in lock order graph: M0 (...) => M1 (...) => M2 (...) => M0

first gets turned into:

    Cycle in lock order graph: M1 (...) => M1 (...) => M2 (...) => M1

and then into:

    Cycle in lock order graph: M2 (...) => M2 (...) => M2 (...) => M2

In other words, lines like this become garbled due to information loss.

The problem stems from the fact that the numbering scheme the script
uses for identifying mutexes and threads is exactly the same as the one
used by TSAN itself.  Update util/parse_tsan.py so that it uses
zero-padded numbers instead, making the "overlapping" demonstrated above
impossible.
2023-06-15 16:17:14 +02:00
Ondřej Surý
f22046d61b Merge branch '4149-make-isc_result-tables-more-compact' into 'main'
Make isc_result tables smaller

Closes #4149

See merge request isc-projects/bind9!8034
2023-06-15 13:46:52 +00:00
Ondřej Surý
0a35c0da9b Add CHANGES note for [GL #4149] 2023-06-15 15:32:24 +02:00
Ondřej Surý
a8e6c3b8f7 Make isc_result tables smaller
The isc_result_t enum was to sparse when each library code would skip to
next << 16 as a base.  Remove the huge holes in the isc_result_t enum to
make the isc_result tables more compact.

This change required a rewrite how we map dns_rcode_t to isc_result_t
and back, so we don't ever return neither isc_result_t value nor
dns_rcode_t out of defined range.
2023-06-15 15:32:04 +02:00
Ondřej Surý
b53d1d7069 Refactor how we map isc_result_t <-> dns_rcode_t
The mapping functions between isc_result_t and dns_rcode_t could return
both isc_result_t values not defined in the header and dns_rcode_t
values not defined in the header because it blindly maps anything
withing full 12-bits defined for RCODEs to isc_result_t and back.

Refactor the dns_result_{from,to}rcode() functions to always return
valid isc_result_t and dns_rcode_t values by explicitly mapping the
values to each other and returning DNS_R_SERVFAIL (dns_rcode_servfail)
when encountering value out of the defined range.
2023-06-15 15:32:04 +02:00
Tom Krizek
189aadbab9 Merge branch 'tkrizek/ci-system-clang-tsan-disallow-failure' into 'main'
Mark CI failure of system:clang:tsan as an error again

See merge request isc-projects/bind9!8035
2023-06-15 11:09:48 +00:00
Tom Krizek
e556097e81 Mark CI failure of system:clang:tsan as an error again
Both the issues causing frequent failures have been resolved. The job
seems to have stabilized and there's no longer a need to mark the
failure as a mere warnings.
2023-06-15 13:09:18 +02:00
Arаm Sаrgsyаn
14d4bf9136 Merge branch '4132-catz-data-race-in-db.c' into 'main'
Fix a data race between the dns_zone and dns_catz modules

Closes #4132

See merge request isc-projects/bind9!8031
2023-06-15 09:50:15 +00:00
Aram Sargsyan
f73007afe7 Add a CHANGES note for [GL #4132] 2023-06-15 08:50:04 +00:00
Aram Sargsyan
6f1f5fc307 Fix a data race between the dns_zone and dns_catz modules
The dns_zone_catz_enable_db() and dns_zone_catz_disable_db()
functions can race with similar operations in the catz module
because there is no synchronization between the threads.

Add catz functions which use the view's catalog zones' lock
when registering/unregistering the database update notify callback,
and use those functions in the dns_zone module, instead of doing it
directly.
2023-06-15 08:49:20 +00:00
Tony Finch
68cfbd2bd1 Merge branch '4134-zonefile-erofs' into 'main'
Translate POSIX errorcode EROFS to ISC_R_NOPERM

Closes #4134

See merge request isc-projects/bind9!8017
2023-06-14 12:44:54 +00:00
Tony Finch
82401f0f0e CHANGES note for [GL #4134]
[cleanup]	Report "permission denied" instead of "unexpected error"
		when trying to update a zone file is on a read-only file
		system. Thanks to Midnight Veil. [GL #4134]
2023-06-14 13:13:39 +01:00
Midnight Veil
dd6acc1cac Translate POSIX errorcode EROFS to ISC_R_NOPERM
Report "permission denied" instead of "unexpected error"
when trying to update a zone file on a read-only file system.
2023-06-14 13:12:45 +01:00
Mark Andrews
06bbe6a2db Merge branch '4021-tsan-error-view-adb-detached-too-early' into 'main'
Resolve "TSAN error: view->adb detached too early."

Closes #4021

See merge request isc-projects/bind9!8016
2023-06-14 10:36:08 +00:00
Mark Andrews
0da3370642 Add CHANGES note for [GL #4021] 2023-06-14 19:22:00 +10:00
Mark Andrews
971f49b3ad Use RCU for view->adb access
view->adb may be referenced while the view is shutting down as the
zone uses a weak reference to the view and examines view->adb but
dns_view_detach call dns_adb_detach to clear view->adb.
2023-06-14 19:21:28 +10:00
Evan Hunt
984decc563 Merge branch 'each-tsig-refactoring' into 'main'
TSIG/TKEY refactoring

See merge request isc-projects/bind9!7828
2023-06-14 08:14:47 +00:00
Evan Hunt
885c132f4a improve code flow
the code in dns_tkey_processquery() was unnecessarily hard to follow.
2023-06-14 08:14:38 +00:00
Evan Hunt
f4084ff543 minor tkey-related fixups
- style fixes and general tidying-up in tkey.c
- remove the unused 'intoken' parameter from dns_tkey_buildgssquery()
- remove an unnecessary call to dns_tkeyctx_create() in ns_server_create()
  (the TKEY context that was created there would soon be destroyed and
  another one created when the configuration was loaded).
2023-06-14 08:14:38 +00:00
Evan Hunt
96e8b0e782 rename 'ret' to 'result'
purely to assuage my desire for consistency across modules,
result variables have been renamed to 'result' as they are
throughout most of BIND. there are no other changes.
2023-06-14 08:14:38 +00:00
Evan Hunt
6105a7d360 convert TSIG keyring storage from RBT to hash table
since it is not necessary to find partial matches when looking
up names in a TSIG keyring, we can use a hash table instead of
an RBT to store them.

the tsigkey object now stores the key name as a dns_fixedname
rather than allocating memory for it.

the `name` parameter to dns_tsigkeyring_add() has been removed;
it was unneeded since the tsigkey object already contains a copy
of the name.

the opportunistic cleanup_ring() function has been removed;
it was only slowing down lookups.
2023-06-14 08:14:38 +00:00
Evan Hunt
e64b44a5cb remove dns__tsig_algallocated()
this function was no longer needed, because the algorithm name is no
longer copied into the tsigkey object by dns_tsigkey_createfromkey();
it's always just a pointer to a statically defined name.
2023-06-14 08:14:38 +00:00
Evan Hunt
f2d5782e89 get_key_struct() can no longer fail
remove checks for NULL return values.
2023-06-14 08:14:38 +00:00
Evan Hunt
ffacf0aec6 use algorithm number instead of name to create TSIG keys
the prior practice of passing a dns_name containing the
expanded name of an algorithm to dns_tsigkey_create() and
dns_tsigkey_createfromkey() is unnecessarily cumbersome;
we can now pass the algorithm number instead.
2023-06-14 08:14:38 +00:00
Evan Hunt
a6e187a8d5 further dns_tsigkey API tweaks
- remove the 'ring' parameter from dns_tsigkey_createfromkey(),
  and use dns_tsigkeyring_add() to add key objects to a keyring instead.
- add a magic number to dns_tsigkeyring_t
- change dns_tsigkeyring_dumpanddetach() to dns_tsigkeyring_dump();
  we now call dns_tsigkeyring_detach() separately.
- remove 'maxgenerated' from dns_tsigkeyring_t since it never changes.
2023-06-14 08:14:38 +00:00
Evan Hunt
404a13b4dd clean up reference counting in dns_tsigkey
the reference counter in dns_tsigkey was being computed differently
depending on whether there was a keyring or not. this is prone to
error.
2023-06-14 08:14:38 +00:00
Evan Hunt
6fa8524bba use ISC_REFCOUNT_IMPL for dns_tsigkey and dns_tsigkeyring
use the ISC_REFCOUNT attach/detach implementation in dns/tsig.c
so that detailed tracing can be used during refactoring.

dns_tsig_keyring_t has been renamed dns_tsigkeyring_t so the type
and the attach/detach function names will match.
2023-06-14 08:14:38 +00:00
Evan Hunt
b1db1c1475 minor tsig.c cleanups
- style cleanups.
- simplify the function parameters to dns_tsigkey_create():
  + remove 'restored' and 'generated', they're only ever set to false.
  + remove 'creator' because it's only ever set to NULL.
  + remove 'inception' and 'expiry' because they're only ever set to
    (0, 0) or (now, now), and either way, this means "never expire".
  + remove 'ring' because we can just use dns_tsigkeyring_add() instead.
- rename dns_keyring_restore() to dns_tsigkeyring_restore() to match the
  rest of the functions operating on dns_tsigkeyring objects.
2023-06-14 08:14:38 +00:00
Matthijs Mekking
dc71aab358 Merge branch '4141-find-zone_keys' into 'main'
Update find_zone_keys for dynamic update

Closes #4141

See merge request isc-projects/bind9!8029
2023-06-14 08:05:55 +00:00
Matthijs Mekking
e59c6a5adc Update findzonekeys function name in log message
The "dns_dnssec_findzonekeys2" log message is a leftover from when that
was the name of the function. Rename to match the current name of the
function.
2023-06-14 09:08:56 +02:00
Matthijs Mekking
5cf91728d1 Add dynamic update prepub and doubleksk test case
Add two test cases for zones that use auto-dnssec, but not
inline-signing, and make sure that the change for find_zone_keys()
do not affect introducing a new key that is intended for signing.

See note https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/7638#note_355944
2023-06-14 09:08:56 +02:00
Matthijs Mekking
5c9a7ffbdb Add CHANGES for find_zone_keys() function update
Probably a useful point in history.
2023-06-14 09:08:56 +02:00
Matthijs Mekking
88e5bc0687 Update find_zone_keys for dynamic update
The find_zone_keys() function was not working properly for
inline-signed zones. It only worked if the DNSKEY records were also
published in the unsigned version of the zone. But this is not the
case when you use dnssec-policy, the DNSKEY records will only occur
in the signed version of the zone. Therefor, when looking for keys
to sign the zone, only the newly added keys in the dynamic update
were found (which could be zero), ignoring existing keys.

Also, if a DNSKEY was added, it would try to sign the zone with just
this new key, and this would only work if the key files for that key
were imported into the key-directory.

This is a design error, because the goal is to sign the zone with the
keys for which we actually have key files for. So instead of looking
for DNSKEY records to then search for the matching key files, call
dns_dnssec_findmatchingkeys() which just looks for the keys we have
on disk for the given zone. It will also set the correct DNSSEC
signing hints.
2023-06-14 09:08:56 +02:00
Matthijs Mekking
cda1ae69ac Add log check in multisigner system test
When we add DNSKEY records via dynamic update, this should no longer
trigger signing the zone with these keys. This currently happens when
'find_zone_keys()' looks up the keys by inspecting the DNSKEY RRset,
then attempting to read the corresponding key files.

Add checks that inspect the logs whether an attempt to read the key
files for the newly added keys was done (and failed because these files
are not available).
2023-06-14 09:08:56 +02:00
Tom Krizek
2633732fb1 Merge branch 'tkrizek/remove-trailing-whitespace' into 'main'
Remove trailing whitespace from all text files

See merge request isc-projects/bind9!8012
2023-06-13 13:31:32 +00:00
Tom Krizek
034a32a4f3 Add utility script to detect trailing whitespace
Run the script in CI as well to ensure we don't accidentally add
trailing whitespace again.
2023-06-13 15:06:38 +02:00
Tom Krizek
03e981ed2c Ignore trailing whitespace removal commit in git blame 2023-06-13 15:06:38 +02:00
Tom Krizek
5893debf46 Remove trailing whitespace from all text files
I've used the following command to remove the trailing whitespace for
all tracked text files:

git grep -Il '' | xargs sed -i 's/[ \t]*$//'
2023-06-13 15:05:40 +02:00
Arаm Sаrgsyаn
589752fc69 Merge branch '4136-catz-db-update-notify-bug' into 'main'
Fix catz db update callback registration logic error

Closes #4136

See merge request isc-projects/bind9!8025
2023-06-13 13:01:05 +00:00
Aram Sargsyan
23f609ba59 Add a CHANGES note for [GL #4136] 2023-06-13 12:58:13 +00:00
Aram Sargsyan
998765fea5 Fix catz db update callback registration logic error
When a catalog zone is updated using AXFR, the zone database is changed,
so it is required to unregister the update notification callback from
the old database, and register it for the new one.

Currently, here is the order of the steps happening in such scenario:

1. The zone.c:zone_startload() function registers the notify callback
   on the new database using dns_zone_catz_enable_db()
2. The callback, when called, notices that the new 'db' is different
   than 'catz->db', and unregisters the old callback for 'catz->db',
   marks that it's unregistered by setting 'catz->db_registered' to
   false, then it schedules an update if it isn't already scheduled.
3. The offloaded update process, after completing its job, notices that
   'catz->db_registered' is false, and (re)registers the update callback
   for the current database it is working on. There is no harm here even
   if it was registered also on step 1, and we can't skip it, because
   this function can also be called "artificially" during a
   reconfiguration, and in that case the registration step is required
   here.

A problem arises when before step 1 an update process was already
in a running state, operating on the old database, and finishing its
work only after step 2. As described in step 3, dns__catz_update_cb()
notices that 'catz->db_registered' is false and registers the callback
on the current database it is working on, which, at that state, is
already obsolete and unused by the zone. When it detaches the database,
the function which is responsible for its cleanup (e.g. free_rbtdb())
asserts because there is a registered update notify callback there.

To fix the problem, instead of delaying the (re)registration to step 3,
make sure that the new callback is registered and 'catz->db_registered'
is accordingly marked on step 2.
2023-06-13 12:58:13 +00:00
Tom Krizek
b94e500d3d Merge branch '4117-serve-stale-check' into 'main'
Avoid false positive in serve-stale system test check

Closes #4117

See merge request isc-projects/bind9!8026
2023-06-13 12:10:25 +00:00
Tom Krizek
dd7bcd2855 Avoid false positive in serve-stale system test check
The purpose of the check is to verify the server has survived the
previous barrage of queries. This is done by sending a query and
checking we get a NOERROR response back.

Previously, that query could've been affected by a servfail cache - the
server would return a SERVFAIL answer, thus failing the check, despite
being up and running. Use version.bind txt ch query to avoid the
interference of servfail cache.
2023-06-13 10:52:01 +02:00
Michal Nowak
c1879b54c3 Merge branch 'mnowak/set-up-version-and-release-notes-for-bind-9.19.15' into 'main'
Set up version and release notes for BIND 9.19.15

See merge request isc-projects/bind9!8021
2023-06-12 15:12:13 +00:00
Michal Nowak
a04301f936 Set up release notes for BIND 9.19.15 2023-06-12 16:12:40 +02:00
Michal Nowak
8f6e77aee9 Update BIND version to 9.19.15-dev 2023-06-12 16:12:27 +02:00