]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
4 years agoRemove exclusive mode from ns_interfacemgr
Ondřej Surý [Mon, 14 Mar 2022 11:38:46 +0000 (12:38 +0100)] 
Remove exclusive mode from ns_interfacemgr

Now that the dns_aclenv_t has now properly rwlocked .localhost and
.localnets member, we can remove the task exclusive mode use from the
ns_interfacemgr.  Some light related cleanup has been also done.

4 years agoAdd isc_rwlock around dns_aclenv .localhost and .localnets member
Ondřej Surý [Mon, 14 Mar 2022 11:38:46 +0000 (12:38 +0100)] 
Add isc_rwlock around dns_aclenv .localhost and .localnets member

In order to modify the .localhost and .localnets members of the
dns_aclenv, all other processing on the netmgr loops needed to be
stopped using the task exclusive mode.  Add the isc_rwlock to the
dns_aclenv, so any modifications to the .localhost and .localnets can be
done under the write lock.

4 years agoMerge branch '3248-dig-stuck-using-a-server-with-a-mapped-ip-address' into 'main'
Arаm Sаrgsyаn [Mon, 4 Apr 2022 09:37:40 +0000 (09:37 +0000)] 
Merge branch '3248-dig-stuck-using-a-server-with-a-mapped-ip-address' into 'main'

Fix dig hanging issue in cases when the lookup's next query can't start

Closes #3248

See merge request isc-projects/bind9!6061

4 years agoAdd CHANGES note for [GL #3248]
Aram Sargsyan [Fri, 1 Apr 2022 13:39:06 +0000 (13:39 +0000)] 
Add CHANGES note for [GL #3248]

4 years agoFix dig hanging issue in cases when the lookup's next query can't start
Aram Sargsyan [Fri, 1 Apr 2022 13:12:40 +0000 (13:12 +0000)] 
Fix dig hanging issue in cases when the lookup's next query can't start

In recv_done(), when dig decides to start the lookup's next query in
the line using `start_udp()` or `start_tcp()`, and for some reason,
no queries get started, dig doesn't cancel the lookup.

This can occur, for example, when there are two queries in the lookup,
one with a regular IP address, and another with a IPv4 mapped IPv6
address. When the regular IP address fails to serve the query, its
`recv_done()` callback starts the next query in the line (in this
case the one with a mapped IP address), but because `dig` doesn't
connect to such IP addresses, and there are no other queries in the
list, no new queries are being started, and the lookup keeps hanging.

After calling `start_udp()` or `start_tcp()` in `recv_done()`, check
if there are no pending/working queries then cancel the lookup instead
of only detaching from the current query.

4 years agoMerge branch '3252-stop-timer-before-detach' into 'main'
Ondřej Surý [Fri, 1 Apr 2022 23:48:26 +0000 (23:48 +0000)] 
Merge branch '3252-stop-timer-before-detach' into 'main'

Don't use reference counting in isc_timer unit

Closes #3252

See merge request isc-projects/bind9!6067

4 years agoDon't use reference counting in isc_timer unit
Ondřej Surý [Fri, 1 Apr 2022 22:42:20 +0000 (00:42 +0200)] 
Don't use reference counting in isc_timer unit

The reference counting and isc_timer_attach()/isc_timer_detach()
semantic are actually misleading because it cannot be used under normal
conditions.  The usual conditions under which is timer used uses the
object where timer is used as argument to the "timer" itself.  This
means that when the caller is using `isc_timer_detach()` it needs the
timer to stop and the isc_timer_detach() does that only if this would be
the last reference.  Unfortunately, this also means that if the timer is
attached elsewhere and the timer is fired it will most likely be
use-after-free, because the object used in the timer no longer exists.

Remove the reference counting from the isc_timer unit, remove
isc_timer_attach() function and rename isc_timer_detach() to
isc_timer_destroy() to better reflect how the API needs to be used.

The only caveat is that the already executed event must be destroyed
before the isc_timer_destroy() is called because the timer is no longet
attached to .ev_destroy_arg.

4 years agoMerge branch 'ondrej-remove-task-privileged-mode' into 'main'
Ondřej Surý [Fri, 1 Apr 2022 23:01:48 +0000 (23:01 +0000)] 
Merge branch 'ondrej-remove-task-privileged-mode' into 'main'

Remove task privileged mode

Closes #3253

See merge request isc-projects/bind9!6049

4 years agoAdd CHANGES note for [GL #3253]
Ondřej Surý [Thu, 31 Mar 2022 07:43:27 +0000 (09:43 +0200)] 
Add CHANGES note for [GL #3253]

4 years agoRemove task privileged mode
Ondřej Surý [Thu, 31 Mar 2022 07:08:47 +0000 (09:08 +0200)] 
Remove task privileged mode

Previously, the task privileged mode has been used only when the named
was starting up and loading the zones from the disk as the "first" thing
to do.  The privileged task was setup with quantum == 2, which made the
taskmgr/netmgr spin around the privileged queue processing two events at
the time.

The same effect can be achieved by setting the quantum to UINT_MAX (e.g.
practically unlimited) for the loadzone task, hence the privileged task
mode was removed in favor of just processing all the events on the
loadzone task in a single task_run().

4 years agoMerge branch 'ondrej-cleanup-extra-memory-context-in-dns_zone' into 'main'
Ondřej Surý [Fri, 1 Apr 2022 21:54:55 +0000 (21:54 +0000)] 
Merge branch 'ondrej-cleanup-extra-memory-context-in-dns_zone' into 'main'

Cleanup the tasks and memory contexts in dns_zone

Closes #3226 and #3159

See merge request isc-projects/bind9!6004

4 years agoAdd CHANGES note for [GL #3226]
Ondřej Surý [Wed, 23 Mar 2022 12:53:54 +0000 (13:53 +0100)] 
Add CHANGES note for [GL #3226]

4 years agoRemove isc_pool API
Ondřej Surý [Fri, 18 Mar 2022 11:50:18 +0000 (12:50 +0100)] 
Remove isc_pool API

Since the last user of the isc_pool API is gone, remove the whole
isc_pool API.

4 years agoUse isc_nm_getnworkers to manage zone resources
Ondřej Surý [Fri, 18 Mar 2022 09:14:17 +0000 (10:14 +0100)] 
Use isc_nm_getnworkers to manage zone resources

Instead of passing the number of worker to the dns_zonemgr manually,
get the number of nm threads using the new isc_nm_getnworkers() call.

Additionally, remove the isc_pool API and manage the array of memory
context, zonetasks and loadtasks directly in the zonemgr.

4 years agoSet hard thread affinity for each zone
Ondřej Surý [Thu, 17 Mar 2022 22:37:26 +0000 (23:37 +0100)] 
Set hard thread affinity for each zone

After switching to per-thread resources in the zonemgr, the performance
was decreased because the memory context, zonetask and loadtask was
picked from the pool at random.

Pin the zone to single threadid (.tid) and align the memory context,
zonetask and loadtask to be the same, this sets the hard affinity of the
zone to the netmgr thread.

4 years agoRemove the zone counting in the named
Ondřej Surý [Mon, 10 Jan 2022 21:02:20 +0000 (22:02 +0100)] 
Remove the zone counting in the named

The zone counting in the named was used to properly size the zonemgr
resources (memory contexts, zonetasks and loadtasks).  Since this is no
longer the case, remove the whole zone counting from named.

4 years agoCreate per-thread task and memory context for zonemgr
Ondřej Surý [Fri, 17 Dec 2021 10:34:57 +0000 (11:34 +0100)] 
Create per-thread task and memory context for zonemgr

Previously, the zonemgr created 1 task per 100 zones and 1 memory
context per 1000 zones (with minimum 10 tasks and 2 memory contexts) to
reduce the contention between threads.

Instead of reducing the contention by having many resources, create a
per-nm_thread memory context, loadtask and zonetask and spread the zones
between just per-thread resources.

Note: this commit alone does decrease performance when loading the zone
by couple seconds (in case of 1M zone) and thus there's more work in
this whole MR fixing the performance.

4 years agoMerge branch 'ondrej-repair-isc_task_purgeevent' into 'main'
Ondřej Surý [Fri, 1 Apr 2022 21:50:04 +0000 (21:50 +0000)] 
Merge branch 'ondrej-repair-isc_task_purgeevent' into 'main'

Repair isc_task_purgeevent(), clean isc_task_unsend{,range}()

Closes #3252

See merge request isc-projects/bind9!6053

4 years agoAdd CHANGES note for [GL #3252]
Ondřej Surý [Fri, 1 Apr 2022 08:59:28 +0000 (10:59 +0200)] 
Add CHANGES note for [GL #3252]

4 years agoStop the zone timer before detaching the timer
Ondřej Surý [Fri, 1 Apr 2022 08:51:41 +0000 (10:51 +0200)] 
Stop the zone timer before detaching the timer

Previously, the zone timer was not stopped before detaching the timer.
This could lead to a data race where the timer post_event() could fire
before the timer was detached, but then the event would be executed
after the zone was already destroyed.

This was not noticed before because the timing or the ordering of the
actions were different, but it was causing assertion failures in the
libns tests now.

Properly stop the zone timer before detaching the timer object from the
dns_zone.

4 years agoSet quantum to infinity for the zone loading task
Ondřej Surý [Thu, 31 Mar 2022 20:15:49 +0000 (22:15 +0200)] 
Set quantum to infinity for the zone loading task

When we are loading the zones, set the quantum to UINT_MAX, which makes
task_run process all tasks at once.  After the zone loading is finished
the quantum will be dropped to 1 to not block server when we are loading
new zones after reconfiguration.

4 years agoAdd isc_task_setquantum() and use it for post-init zone loading
Ondřej Surý [Fri, 1 Apr 2022 08:40:37 +0000 (10:40 +0200)] 
Add isc_task_setquantum() and use it for post-init zone loading

Add isc_task_setquantum() function that modifies quantum for the future
isc_task_run() invocations.

NOTE: The current isc_task_run() caches the task->quantum into a local
variable and therefore the current event loop is not affected by any
quantum change.

4 years agoRemove isc_task_purge() and isc_task_purgerange()
Ondřej Surý [Thu, 31 Mar 2022 20:14:14 +0000 (22:14 +0200)] 
Remove isc_task_purge() and isc_task_purgerange()

The isc_task_purge() and isc_task_purgerange() were now unused, so sweep
the task.c file.  Additionally remove unused ISC_EVENTATTR_NOPURGE event
attribute.

4 years agoPurge the .resched_event in dns_cache
Ondřej Surý [Thu, 31 Mar 2022 20:06:22 +0000 (22:06 +0200)] 
Purge the .resched_event in dns_cache

Instead of sweeping the cache cleaner tasks, purge the more specific
cleaner.resched_event event.

4 years agoKeep the list of scheduled events on the timer
Ondřej Surý [Thu, 31 Mar 2022 19:59:57 +0000 (21:59 +0200)] 
Keep the list of scheduled events on the timer

Instead of searching for the events to purge, keep the list of scheduled
events on the timer list and purge the events that we have scheduled.

4 years agoRepair isc_task_purgeevent(), clean isc_task_unsend{,range}()
Ondřej Surý [Thu, 31 Mar 2022 19:55:15 +0000 (21:55 +0200)] 
Repair isc_task_purgeevent(), clean isc_task_unsend{,range}()

The isc_task_purgerange() was walking through all events on the task to
find a matching task.  Instead use the ISC_LINK_LINKED to find whether
the event is active.

Cleanup the related isc_task_unsend() and isc_task_unsendrange()
functions that were not used anywhere.

4 years agoMerge branch '3243-mr-6035-fix' into 'main'
Ondřej Surý [Fri, 1 Apr 2022 21:32:48 +0000 (21:32 +0000)] 
Merge branch '3243-mr-6035-fix' into 'main'

Turn isc_hash_bits32() into static online function

Closes #3243

See merge request isc-projects/bind9!6050

4 years agoHelp gcovr find isc/hash.h when included from lib/dns
Ondřej Surý [Fri, 1 Apr 2022 21:05:43 +0000 (23:05 +0200)] 
Help gcovr find isc/hash.h when included from lib/dns

Similar to other tweaks, copy the lib/isc/include/isc/hash.h to lib/dns
to help gcovr find the file.

4 years agoTurn isc_hash_bits32() into static online function
Ondřej Surý [Thu, 31 Mar 2022 09:12:41 +0000 (11:12 +0200)] 
Turn isc_hash_bits32() into static online function

Adding extra val & 0xffff in the isc_hash_bits32() macros in the hotpath
has significantly reduced the performance.  Turn the macro into static
inline function matching the previous hash_32() function used to compute
hashval matching the hashtable->bits.

4 years agoMerge branch '3250-resolver-test-non-querytrace' into 'main'
Evan Hunt [Fri, 1 Apr 2022 17:16:09 +0000 (17:16 +0000)] 
Merge branch '3250-resolver-test-non-querytrace' into 'main'

fix resolver test when built without --enable-querytrace

Closes #3250

See merge request isc-projects/bind9!6064

4 years agofix resolver test when built without --enable-querytrace
Evan Hunt [Fri, 1 Apr 2022 16:51:37 +0000 (09:51 -0700)] 
fix resolver test when built without --enable-querytrace

a test case in the 'resolver' system test was reliant on
logged output that would only be present when query tracing
was enabled, as in developer builds. that test case is now
disabled when query tracing is not available. Thanks to
Anton Castelli.

4 years agoMerge branch '3236-fix-debian9-no-SSL_CTX_set1_cert_store' into 'main'
Artem Boldariev [Fri, 1 Apr 2022 14:28:09 +0000 (14:28 +0000)] 
Merge branch '3236-fix-debian9-no-SSL_CTX_set1_cert_store' into 'main'

Implement shim for SSL_CTX_set1_cert_store() (affects Debian 9)

Closes #3236

See merge request isc-projects/bind9!6054

4 years agoImplement shim for SSL_CTX_set1_cert_store() (affects Debian 9)
Artem Boldariev [Fri, 1 Apr 2022 08:16:44 +0000 (11:16 +0300)] 
Implement shim for SSL_CTX_set1_cert_store() (affects Debian 9)

This commit implements a shim for SSL_CTX_set1_cert_store() for
OpenSSL/LibreSSL versions where it is not available.

4 years agoMerge branch '3145-dig-+nssearch-does-not-exit-until-interrupted' into 'main'
Arаm Sаrgsyаn [Fri, 1 Apr 2022 11:51:17 +0000 (11:51 +0000)] 
Merge branch '3145-dig-+nssearch-does-not-exit-until-interrupted' into 'main'

Fix "dig +nssearch" indefinitely hanging issue

Closes #3145

See merge request isc-projects/bind9!6007

4 years agoSynchronze udp_ready() and tcp_connected() functions entry behavior
Aram Sargsyan [Tue, 29 Mar 2022 20:58:15 +0000 (20:58 +0000)] 
Synchronze udp_ready() and tcp_connected() functions entry behavior

The `udp_ready()` and `tcp_connected()` functions in dighost.c are
used for similar purposes for UDP and TCP respectively.

Synchronize the `udp_ready()` function entry code to behave like
`tcp_connected()` by adding input validation, debug messages and
early exit code when `cancel_now` is `true`.

4 years agoAdd CHANGES note for [GL #3145]
Aram Sargsyan [Sun, 20 Mar 2022 14:03:26 +0000 (14:03 +0000)] 
Add CHANGES note for [GL #3145]

4 years agoFix "dig +nssearch" indefinitely hanging issue
Aram Sargsyan [Sun, 20 Mar 2022 13:54:39 +0000 (13:54 +0000)] 
Fix "dig +nssearch" indefinitely hanging issue

When finishing the NSSEARCH task and there is no more followup
lookups to start, dig does not destroy the last lookup, which
causes it to hang indefinitely.

Rename the unused `first_pass` member of `dig_query_t` to `started`
and make it `true` in the first callback after `start_udp()` or
`start_tcp()` of the query to indicate that the query has been
started.

Create a new `check_if_queries_done()` function to check whether
all of the queries inside a lookup have been started and finished,
or canceled.

Use the mentioned function in the TRACE code block in `recv_done()`
to check whether the current query is the last one in the lookup and
cancel the lookup in that case to free the resources.

4 years agoMerge branch '3191-issue-45178-in-oss-fuzz-bind9-dns_master_load_fuzzer-integer-overf...
Mark Andrews [Fri, 1 Apr 2022 10:31:45 +0000 (10:31 +0000)] 
Merge branch '3191-issue-45178-in-oss-fuzz-bind9-dns_master_load_fuzzer-integer-overflow-in-generate' into 'main'

Resolve "Issue 45178 in oss-fuzz: bind9:dns_master_load_fuzzer: Integer-overflow in generate"

Closes #3191

See merge request isc-projects/bind9!5928

4 years agoadd a system test for $GENERATE with an integer overflow
Evan Hunt [Fri, 4 Mar 2022 23:19:52 +0000 (15:19 -0800)] 
add a system test for $GENERATE with an integer overflow

the line "$GENERATE 19-28/2147483645 $ CNAME x" should generate
a single CNAME with the owner "19.example.com", but prior to the
overflow bug it generated several CNAMEs, half of them with large
negative values.

we now test for the bugfix by using "named-checkzone -D" and
grepping for a single CNAME in the output.

4 years agoupdate shell syntax
Evan Hunt [Fri, 4 Mar 2022 23:13:25 +0000 (15:13 -0800)] 
update shell syntax

clean up the shell syntax in the checkzone test prior to adding
a new test.

4 years agoAdd test case for issue-45178
Mark Andrews [Thu, 3 Mar 2022 22:51:22 +0000 (09:51 +1100)] 
Add test case for issue-45178

4 years agoPrevent arithmetic overflow of 'i' in master.c:generate
Mark Andrews [Thu, 3 Mar 2022 22:37:39 +0000 (09:37 +1100)] 
Prevent arithmetic overflow of 'i' in master.c:generate

the value of 'i' in generate could overflow when adding 'step' to
it in the 'for' loop.  Use an unsigned int for 'i' which will give
an additional bit and prevent the overflow.  The inputs are both
less than 2^31 and and the result will be less than 2^32-1.

4 years agoMerge branch '3209-notauth-subdomain' into 'main'
Tony Finch [Wed, 30 Mar 2022 12:12:08 +0000 (12:12 +0000)] 
Merge branch '3209-notauth-subdomain' into 'main'

NOTAUTH errors should log the zone from the query not the nearest match

Closes #3209

See merge request isc-projects/bind9!5982

4 years agoLog "not authoritative for update zone" more clearly
Tony Finch [Tue, 15 Mar 2022 17:57:43 +0000 (17:57 +0000)] 
Log "not authoritative for update zone" more clearly

Ensure the update zone name is mentioned in the NOTAUTH error message
in the server log, so that it is easier to track down problematic
update clients. There are two cases: either the update zone is
unrelated to any of the server's zones (previously no zone was
mentioned); or the update zone is a subdomain of one or more of the
server's zones (previously the name of the irrelevant parent zone was
misleadingly logged).

Closes #3209

4 years agoMerge branch '3230-remove-task-exclusive-mode-from-ns_clientmgr' into 'main'
Ondřej Surý [Wed, 30 Mar 2022 11:18:08 +0000 (11:18 +0000)] 
Merge branch '3230-remove-task-exclusive-mode-from-ns_clientmgr' into 'main'

Remove task exclusive mode from ns_clientmgr

Closes #3230

See merge request isc-projects/bind9!6024

4 years agoAdd CHANGES mode for [GL #3230]
Ondřej Surý [Thu, 24 Mar 2022 12:15:17 +0000 (13:15 +0100)] 
Add CHANGES mode for [GL #3230]

4 years agoRemove task exclusive mode from ns_clientmgr
Ondřej Surý [Thu, 24 Mar 2022 12:12:54 +0000 (13:12 +0100)] 
Remove task exclusive mode from ns_clientmgr

The .lock, .exiting and .excl members were not using for anything else
than starting task exclusive mode, setting .exiting to true and ending
exclusive mode.

Remove all the stray members and dead code eliminating the task
exclusive mode use from ns_clientmgr.

4 years agoMerge branch '3213-remove-exclusive-task-mode-from-dns_adb' into 'main'
Ondřej Surý [Wed, 30 Mar 2022 10:41:30 +0000 (10:41 +0000)] 
Merge branch '3213-remove-exclusive-task-mode-from-dns_adb' into 'main'

refactor ADB

Closes #3213

See merge request isc-projects/bind9!6033

4 years agoAdd CHANGES note for [GL #3213]
Evan Hunt [Fri, 25 Mar 2022 20:23:19 +0000 (13:23 -0700)] 
Add CHANGES note for [GL #3213]

4 years agoAdd detailed ADB and entry attach/detach tracing
Evan Hunt [Thu, 24 Mar 2022 22:58:26 +0000 (15:58 -0700)] 
Add detailed ADB and entry attach/detach tracing

To turn on detailed debug tracing of dns_adb and dns_adbentry
reference counting, #define ADB_TRACE at the top of adb.c. This
is off by default.

4 years agoRefactor ADB reference counting, shutdown and locking
Evan Hunt [Mon, 21 Mar 2022 19:48:52 +0000 (12:48 -0700)] 
Refactor ADB reference counting, shutdown and locking

The ADB previously used separate reference counters for internal
and external references, plus additional counters for ABD find
and namehook objects, and used all these counters to coordinate
its shutdown process, which was a multi-stage affair involving
a sequence of control events.

It also used a complex interlocking set of static functions for
referencing, deferencing, linking, unlinking, and cleaning up various
internal objects; these functions returned boolean values to their
callers to indicate what additional processing was needed.

The changes in the previous two commits destabilized this fragile
system in a way that was difficult to recover from, so in this commit
we refactor all of it. The dns_adb and dns_adbentry objects now use
conventional attach and detach functions for reference counting, and
the shutdown process is much more straightforward.  Instead of
handling shutdown asynchronously, we can just destroy the ADB when
references reach zero

In addition, ADB locking has been simplified. Instead of a
single `find_{name,entry}_and_lock()` function which searches for
a name or entry's hash bucket, locks it, and then searches for the
name or entry in the bucket, we now use one function to find the
bucket (leaving it to the caller to do the locking) and another
find the name or entry.  Instead of locking the entire ADB when
modifying hash tables, we now use read-write locks around the
specific hash table. The only remaining need for adb->lock
is when modifying the `whenshutdown` list.

Comments throughout the module have been improved.

4 years agoRefactor how ADB names and entries are stored in the dns_adb
Evan Hunt [Wed, 16 Mar 2022 20:58:55 +0000 (21:58 +0100)] 
Refactor how ADB names and entries are stored in the dns_adb

Replace adb->{names,entries} and related arrays (indexed by hashed
bucket) with a isc_ht hash tables storing the new struct
adb{name,entry}bucket_t that wraps all the variables that were
originally stored in arrays indexed by "bucket" number stored directly
in the struct dns_adb.

Previously, the task exclusive mode has been used to grow the internal
arrays used to store the named and entries objects.  The isc_ht hash
tables are now protected by the isc_rwlock instead and thus the usage of
the task exclusive mode has been removed from the dns_adb.

Co-authored-by: Ondřej Surý <ondrej@isc.org>
4 years agominor pre-refactoring cleanups
Evan Hunt [Thu, 24 Mar 2022 23:06:48 +0000 (16:06 -0700)] 
minor pre-refactoring cleanups

the use of "result" as a variable name for a boolean return value
was confusing; all 'result' variables that are not isc_result_t
have been renamed to 'ret'.

The static function print_dns_name() was a duplicate of
dns_name_print(), so it has been replaced with that.

Changed INSIST to REQUIRE where appropriate, and added NULL
initialization for pointer variables.

4 years agoMerge branch 'ondrej-remove-multiple-application-contexts' into 'main'
Ondřej Surý [Tue, 29 Mar 2022 22:24:20 +0000 (22:24 +0000)] 
Merge branch 'ondrej-remove-multiple-application-contexts' into 'main'

Remove isc_appctx_t use in dns_client

See merge request isc-projects/bind9!6041

4 years agoAdd CHANGES note for [GL !6041]
Ondřej Surý [Mon, 28 Mar 2022 18:58:04 +0000 (20:58 +0200)] 
Add CHANGES note for [GL !6041]

4 years agoRemove isc_appctx_t use in dns_client
Ondřej Surý [Mon, 28 Mar 2022 18:21:07 +0000 (20:21 +0200)] 
Remove isc_appctx_t use in dns_client

The use of isc_appctx_t in dns_client was used to wait for
dns_client_startresolve() to finish the processing (the resolve_done()
task callback).

This has been replaced with standard bool+cond+lock combination removing
the need of isc_appctx_t altogether.

4 years agoMerge branch 'fanf/macos-ifconfig' into 'main'
Tony Finch [Tue, 29 Mar 2022 16:52:30 +0000 (16:52 +0000)] 
Merge branch 'fanf/macos-ifconfig' into 'main'

MacOS needs more IP addresses to run the system tests

See merge request isc-projects/bind9!5993

4 years agoMacOS needs more IP addresses to run the system tests
Tony Finch [Tue, 15 Mar 2022 17:01:34 +0000 (17:01 +0000)] 
MacOS needs more IP addresses to run the system tests

The launchd script only counted up to 8 whereas ifconfig.sh went all
the way up to 10, and even a bit further than that.

4 years agoMerge branch 'each-consolidate-fibonacci-hashing' into 'main'
Evan Hunt [Mon, 28 Mar 2022 22:27:59 +0000 (22:27 +0000)] 
Merge branch 'each-consolidate-fibonacci-hashing' into 'main'

consolidate fibonacci hashing and support case-insensitive hash tables

See merge request isc-projects/bind9!6035

4 years agoMake isc_ht optionally case insensitive
Ondřej Surý [Wed, 16 Mar 2022 20:58:55 +0000 (21:58 +0100)] 
Make isc_ht optionally case insensitive

Previously, the isc_ht API would always take the key as a literal input
to the hashing function.  Change the isc_ht_init() function to take an
'options' argument, in which ISC_HT_CASE_SENSITIVE or _INSENSITIVE can
be specified, to determine whether to use case-sensitive hashing in
isc_hash32() when hashing the key.

4 years agoconsolidate fibonacci hashing in one place
Evan Hunt [Wed, 16 Mar 2022 20:23:02 +0000 (13:23 -0700)] 
consolidate fibonacci hashing in one place

Fibonacci hashing was implemented in four separate places (rbt.c,
rbtdb.c, resolver.c, zone.c). This commit combines them into a single
implementation. The hash_32() function is now replaced with
isc_hash_bits32().

4 years agoMerge branch 'ondrej/cleanup-unreachable-calls' into 'main'
Ondřej Surý [Mon, 28 Mar 2022 21:40:52 +0000 (21:40 +0000)] 
Merge branch 'ondrej/cleanup-unreachable-calls' into 'main'

Consistenly use UNREACHABLE() instead of ISC_UNREACHABLE()

See merge request isc-projects/bind9!6042

4 years agoConsistenly use UNREACHABLE() instead of ISC_UNREACHABLE()
Ondřej Surý [Mon, 28 Mar 2022 10:59:43 +0000 (12:59 +0200)] 
Consistenly use UNREACHABLE() instead of ISC_UNREACHABLE()

In couple places, we have missed INSIST(0) or ISC_UNREACHABLE()
replacement on some branches with UNREACHABLE().  Replace all
ISC_UNREACHABLE() or INSIST(0) calls with UNREACHABLE().

4 years agoMerge branch 'artem-strict-tls' into 'main'
Artem Boldariev [Mon, 28 Mar 2022 13:55:47 +0000 (13:55 +0000)] 
Merge branch 'artem-strict-tls' into 'main'

Add remote TLS certificate verification support, implement Strict and Mutual TLS authentication in BIND and dig

Closes #3163

See merge request isc-projects/bind9!5837

4 years agoMention TLS certs verification in the CHANGES and Release Notes
Artem Boldariev [Mon, 21 Feb 2022 14:02:32 +0000 (16:02 +0200)] 
Mention TLS certs verification in the CHANGES and Release Notes

This commit adds points to the CHANGES and the release notes about
supporting remote TLS certificates verification and support for Strict
and Mutual TLS transport connections verification.

4 years agoUpdate the "Known Issues"
Artem Boldariev [Mon, 21 Feb 2022 08:25:41 +0000 (10:25 +0200)] 
Update the "Known Issues"

Mention that some old cryptographic library versions lack the
functionality to implement ignoring the Subject field (and thus the
Common Name) when establishing DoT connections.

4 years agoExtend the 'doth' system test with Strict/Mutual TLS checks
Artem Boldariev [Tue, 8 Feb 2022 17:02:05 +0000 (19:02 +0200)] 
Extend the 'doth' system test with Strict/Mutual TLS checks

This commit extends the 'doth' system test with a set of Strict/Mutual
TLS related checks.

This commit also makes each doth NS instance use its own TLS
certificate that includes FQDN, IPv4, and IPv6 addresses, issued using
a common Certificate Authority, instead of ad-hoc certs.

Extend servers initialisation timeout to 60 seconds to improve the
tests stability in the CI as certain configurations could fail to
initialise on time under load.

4 years agoAdd missing plain HTTP options to dig's help output
Artem Boldariev [Wed, 2 Feb 2022 12:30:39 +0000 (14:30 +0200)] 
Add missing plain HTTP options to dig's help output

A couple of dig options were missing in the help output, while been
properly documented and supported. This commit fixes this overlook.

4 years agoDocument supported TLS authentication modes
Artem Boldariev [Tue, 1 Feb 2022 14:57:27 +0000 (16:57 +0200)] 
Document supported TLS authentication modes

This commit updates the reference manual with short descriptions of
different TLS authentication modes, as mentioned in the RFC 9103,
Section 9.3 (Opportunistic TLS, Strict TLS, Mutual TLS), and mentions
how these authentication modes can be achieved via BIND's
configuration file.

4 years agoAdd support for Strict/Mutual TLS into BIND
Artem Boldariev [Wed, 26 Jan 2022 13:26:08 +0000 (15:26 +0200)] 
Add support for Strict/Mutual TLS into BIND

This commit adds support for Strict/Mutual TLS into BIND. It does so
by implementing the backing code for 'hostname' and 'ca-file' options
of the 'tls' statement. The commit also updates the documentation
accordingly.

4 years agoRestore disabled unused 'tls' options: 'ca-file' and 'hostname'
Artem Boldariev [Tue, 25 Jan 2022 16:05:04 +0000 (18:05 +0200)] 
Restore disabled unused 'tls' options: 'ca-file' and 'hostname'

This commit restores the 'tls' options disabled in
78b73d0865ef00062f3bca45cdbc3ca5ccb2ed43.

4 years agoAdd support for Strict/Mutual TLS to dig
Artem Boldariev [Wed, 19 Jan 2022 11:10:08 +0000 (13:10 +0200)] 
Add support for Strict/Mutual TLS to dig

This commit adds support for Strict/Mutual TLS to dig.

The new command-line options and their behaviour are modelled after
kdig (+tls-ca, +tls-hostname, +tls-certfile, +tls-keyfile) for
compatibility reasons. That is, using +tls-* is sufficient to enable
DoT in dig, implying +tls-ca

If there is no other DNS transport specified via command-line,
specifying any of +tls-* options makes dig use DoT. In this case, its
behaviour is the same as if +tls-ca is specified: that is, the remote
peer's certificate is verified using the platform-specific
intermediate CA certificates store. This behaviour is introduced for
compatibility with kdig.

4 years agoAdd ISC_R_TLSBADPEERCERT error code to the TLS related code
Artem Boldariev [Thu, 13 Jan 2022 12:35:24 +0000 (14:35 +0200)] 
Add ISC_R_TLSBADPEERCERT error code to the TLS related code

This commit adds support for ISC_R_TLSBADPEERCERT error code, which is
supposed to be used to signal for TLS peer certificates verification
in dig and other code.

The support for this error code is added to our TLS and TLS DNS
implementations.

This commit also adds isc_nm_verify_tls_peer_result_string() function
which is supposed to be used to get a textual description of the
reason for getting a ISC_R_TLSBADPEERCERT error.

4 years agoExtend TLS context cache with CA certificates store
Artem Boldariev [Tue, 18 Jan 2022 16:31:11 +0000 (18:31 +0200)] 
Extend TLS context cache with CA certificates store

This commit adds support for keeping CA certificates stores associated
with TLS contexts. The intention is to keep one reusable store per a
set of related TLS contexts.

4 years agoAdd foundational functions to implement Strict/Mutual TLS
Artem Boldariev [Tue, 11 Jan 2022 18:40:19 +0000 (20:40 +0200)] 
Add foundational functions to implement Strict/Mutual TLS

This commit adds a set of functions that can be used to implement
Strict and Mutual TLS:

* isc_tlsctx_load_client_ca_names();
* isc_tlsctx_load_certificate();
* isc_tls_verify_peer_result_string();
* isc_tlsctx_enable_peer_verification().

4 years agoAdd utility functions to manipulate X509 certificate stores
Artem Boldariev [Thu, 30 Dec 2021 21:24:25 +0000 (23:24 +0200)] 
Add utility functions to manipulate X509 certificate stores

This commit adds a set of high-level utility functions to manipulate
the certificate stores. The stores are needed to implement TLS
certificates verification efficiently.

4 years agoMerge branch '3221-catz-lightweight-cleanup' into 'main'
Arаm Sаrgsyаn [Mon, 28 Mar 2022 11:04:25 +0000 (11:04 +0000)] 
Merge branch '3221-catz-lightweight-cleanup' into 'main'

[1/5] Catalog zones lightweight cleanup

Closes #3221

See merge request isc-projects/bind9!6011

4 years agoAdd CHANGES note for [GL #3221]
Aram Sargsyan [Wed, 23 Mar 2022 10:55:18 +0000 (10:55 +0000)] 
Add CHANGES note for [GL #3221]

4 years agoUse 'bname' in dns_catz_update_from_db() only when it is ready
Aram Sargsyan [Thu, 17 Mar 2022 14:47:15 +0000 (14:47 +0000)] 
Use 'bname' in dns_catz_update_from_db() only when it is ready

There is a possible code path of using the uninitialized `bname`
character array while logging an error message.

Initialize the `bname` buffer earlier in the function.

Also, change the initialization routine to use a helper function.

4 years agoPut some missing dns_rdata_freestruct() calls in catz.c
Aram Sargsyan [Thu, 17 Mar 2022 14:09:21 +0000 (14:09 +0000)] 
Put some missing dns_rdata_freestruct() calls in catz.c

A successful call to `dns_rdata_tostruct()` expects an accompanying
call to `dns_rdata_freestruct()` to free up any memory that could have
been allocated during the first call.

In catz.c there are several places where `dns_rdata_freestruct()` call
is skipped.

Add the missing cleanup routines.

4 years agoCleanup the code to remove unnecessary indentation
Aram Sargsyan [Tue, 8 Feb 2022 12:01:51 +0000 (12:01 +0000)] 
Cleanup the code to remove unnecessary indentation

Because of the "goto" in the "if" body the "else" part is unnecessary
and adds another level of indentation.

Cleanup the code to not have the "else" part.

4 years agoLog a warning when catz is told to modify a zone not added by catz
Aram Sargsyan [Tue, 8 Feb 2022 11:47:48 +0000 (11:47 +0000)] 
Log a warning when catz is told to modify a zone not added by catz

Catz logs a warning message when it is told to modify a zone which was
not added by the current catalog zone.

When logging a warning, distinguish the two cases when the zone
was not added by a catalog zone at all, and when the zone was
added by a different catalog zone.

4 years agoFix invalid function name in the error log
Aram Sargsyan [Tue, 8 Feb 2022 11:24:18 +0000 (11:24 +0000)] 
Fix invalid function name in the error log

The current function's name in one of the error logs in
catz_addmodzone_taskaction() function is invalid.

Fix the name.

4 years agoMerge branch 'u/fanf2/dnssec-settime-ctime' into 'main'
Ondřej Surý [Fri, 25 Mar 2022 15:13:28 +0000 (15:13 +0000)] 
Merge branch 'u/fanf2/dnssec-settime-ctime' into 'main'

Teach dnssec-settime to read times that it writes

See merge request isc-projects/bind9!2947

4 years agoAdd CHANGES note for [GL !2947]
Tony Finch [Mon, 29 Apr 2019 12:56:05 +0000 (13:56 +0100)] 
Add CHANGES note for [GL !2947]

4 years agoTeach dnssec-settime to read times that it writes
Tony Finch [Mon, 29 Apr 2019 12:56:05 +0000 (13:56 +0100)] 
Teach dnssec-settime to read times that it writes

The dnssec-settime -p and -up options print times in asctime() and
UNIX time_t formats, respectively. The asctime() format can also be
found inside K*.key public key files. Key files also contain times in
the YYYYMMDDHHMMSS format that can be used in timing parameter
options.

The dnssec-settime -p and -up time formats are now acceptable in
timing parameter options to dnssec-settime and dnssec-keygen, so it is
no longer necessary to parse key files to retrieve times that are
acceptable in timing parameter options.

4 years agoMerge branch '3210-dns64-errors' into 'main'
Ondřej Surý [Fri, 25 Mar 2022 10:38:59 +0000 (10:38 +0000)] 
Merge branch '3210-dns64-errors' into 'main'

More explicit dns64 prefix errors

Closes #3210

See merge request isc-projects/bind9!5985

4 years agoAdd CHANGES note for [GL #3210]
Tony Finch [Wed, 16 Mar 2022 17:33:10 +0000 (17:33 +0000)] 
Add CHANGES note for [GL #3210]

4 years agoMore explicit dns64 prefix errors
Tony Finch [Wed, 16 Mar 2022 17:33:10 +0000 (17:33 +0000)] 
More explicit dns64 prefix errors

Quote the dns64 prefix in error messages that complain about
problems with it, to avoid confusion with the following ACLs.

Closes #3210

4 years agoMerge branch 'ondrej-remove-nmhandle-extra' into 'main'
Ondřej Surý [Fri, 25 Mar 2022 09:43:31 +0000 (09:43 +0000)] 
Merge branch 'ondrej-remove-nmhandle-extra' into 'main'

Remove extrahandle size from netmgr

Closes #3227

See merge request isc-projects/bind9!6018

4 years agoMerge branch 'ondrej-cleanup-ns_client-structure' into 'main'
Ondřej Surý [Fri, 25 Mar 2022 09:38:41 +0000 (09:38 +0000)] 
Merge branch 'ondrej-cleanup-ns_client-structure' into 'main'

Remove extra copies and stray members from ns_client_t

See merge request isc-projects/bind9!6017

4 years agoAdd CHANGES note for [GL #3227]
Ondřej Surý [Wed, 23 Mar 2022 13:59:32 +0000 (14:59 +0100)] 
Add CHANGES note for [GL #3227]

4 years agoRemove ns_client_t .shuttingdown member
Ondřej Surý [Wed, 23 Mar 2022 15:16:53 +0000 (16:16 +0100)] 
Remove ns_client_t .shuttingdown member

The way the ns_client_t .shuttingdown member was practically dead code.
The .shuttingdown would be set to true only in ns__client_put() function
meaning that we have detached from all ns_client_t .*handles and the
ns_client_t object being freed:

    client->magic = 0;
    client->shuttingdown = true;
    [...]
    isc_mem_put(manager->ctx, client, sizeof(*client))

Meanwhile the ns_client_t object is accessed like this:

    isc_nmhandle_detach(&client->fetchhandle);

    client->query.attributes &= ~NS_QUERYATTR_RECURSING;
    client->state = NS_CLIENTSTATE_WORKING;

    qctx_init(client, &devent, 0, &qctx);

    client_shuttingdown = ns_client_shuttingdown(client);
    if (fetch_canceled || fetch_answered || client_shuttingdown) {
        [...]
    }

Even if the isc_nmhandle_detach(...) was the last handle detach, it
would mean that immediatelly, after calling the isc_nmhandle_detach(),
we would be causing use-after-free, because the ns_client_t is
immediatelly destroyed after setting .shuttingdown to true.

The similar code in the query_hookresume() already noticed this:

    /*
     * This event is running under a client task, so it's safe to detach
     * the fetch handle.  And it should be done before resuming query
     * processing below, since that may trigger another recursion or
     * asynchronous hook event.
     */

4 years agoRemove extrahandle size from netmgr
Ondřej Surý [Wed, 23 Mar 2022 12:57:15 +0000 (13:57 +0100)] 
Remove extrahandle size from netmgr

Previously, it was possible to assign a bit of memory space in the
nmhandle to store the client data.  This was complicated and prevents
further refactoring of isc_nmhandle_t caching (future work).

Instead of caching the data in the nmhandle, allocate the hot-path
ns_client_t objects from per-thread clientmgr memory context and just
assign it to the isc_nmhandle_t via isc_nmhandle_set().

4 years agoRemove extra copies and stray members from ns_client_t
Ondřej Surý [Wed, 23 Mar 2022 12:57:15 +0000 (13:57 +0100)] 
Remove extra copies and stray members from ns_client_t

The ns_client_t is always attached to ns_clientmgr_t which has
associated memory context, server context, task and threadid.  Use those
directly from the ns_clientmgr_t instead of attaching it to an extra
copy in ns_client_t to make the ns_client_t more sleek and lean.

Additionally, remove some stray ns_client_t struct members that were not
used anywhere.

4 years agoMerge branch 'ondrej/statements-following-return-break-continue-or-goto-will-never...
Ondřej Surý [Fri, 25 Mar 2022 09:07:28 +0000 (09:07 +0000)] 
Merge branch 'ondrej/statements-following-return-break-continue-or-goto-will-never-be-executed' into 'main'

Remove UNREACHABLE() statements after exit()

See merge request isc-projects/bind9!6027

4 years agoRemove UNREACHABLE() statements after exit()
Ondřej Surý [Fri, 25 Mar 2022 08:25:11 +0000 (09:25 +0100)] 
Remove UNREACHABLE() statements after exit()

Couple of UNREACHABLE() statements following exit() were found and
removed.

4 years agoMerge branch 'ondrej/use-newer-compiler-features' into 'main'
Ondřej Surý [Fri, 25 Mar 2022 07:41:05 +0000 (07:41 +0000)] 
Merge branch 'ondrej/use-newer-compiler-features' into 'main'

Use modern C and modern compiler features

See merge request isc-projects/bind9!5480

4 years agoRemove workaround for ancient clang versions (<< 3.2 and << 4.0.1)
Ondřej Surý [Sat, 5 Mar 2022 12:46:52 +0000 (13:46 +0100)] 
Remove workaround for ancient clang versions (<< 3.2 and << 4.0.1)

Some ancient versions of clang reported uninitialized memory use false
positive (see https://bugs.llvm.org/show_bug.cgi?id=14461).  Since clang
4.0.1 has been long obsoleted, just remove the workarounds.

4 years agoRemove use of the inline keyword used as suggestion to compiler
Ondřej Surý [Mon, 11 Oct 2021 11:43:12 +0000 (13:43 +0200)] 
Remove use of the inline keyword used as suggestion to compiler

Historically, the inline keyword was a strong suggestion to the compiler
that it should inline the function marked inline.  As compilers became
better at optimising, this functionality has receded, and using inline
as a suggestion to inline a function is obsolete.  The compiler will
happily ignore it and inline something else entirely if it finds that's
a better optimisation.

Therefore, remove all the occurences of the inline keyword with static
functions inside single compilation unit and leave the decision whether
to inline a function or not entirely on the compiler

NOTE: We keep the usage the inline keyword when the purpose is to change
the linkage behaviour.