]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
4 years agoUse isc_tlsctx_attach() in TLS DNS code
Artem Boldariev [Wed, 16 Mar 2022 15:02:46 +0000 (17:02 +0200)] 
Use isc_tlsctx_attach() in TLS DNS code

This commit adds proper reference counting for TLS contexts into
generic TLS DNS (DoT) code.

4 years agoUse isc_tlsctx_attach() in TLS stream code
Artem Boldariev [Tue, 22 Feb 2022 19:22:04 +0000 (21:22 +0200)] 
Use isc_tlsctx_attach() in TLS stream code

This commit adds proper reference counting for TLS contexts into
generic TLS stream code.

4 years agoAdd isc_tlsctx_attach()
Artem Boldariev [Tue, 22 Feb 2022 15:07:57 +0000 (17:07 +0200)] 
Add isc_tlsctx_attach()

The implementation is done on top of the reference counting
functionality found in OpenSSL/LibreSSL, which allows for avoiding
wrapping the object.

Adding this function allows using reference counting for TLS contexts
in BIND 9's codebase.

4 years agoMerge branch '3249-rename-configuration-option-to-reuseport' into 'main'
Ondřej Surý [Wed, 6 Apr 2022 15:23:16 +0000 (15:23 +0000)] 
Merge branch '3249-rename-configuration-option-to-reuseport' into 'main'

Rename the configuration option to load balance sockets to reuseport

Closes #3249

See merge request isc-projects/bind9!6093

4 years agoRename the configuration option to load balance sockets to reuseport
Ondřej Surý [Wed, 6 Apr 2022 15:00:24 +0000 (17:00 +0200)] 
Rename the configuration option to load balance sockets to reuseport

After some back and forth, it was decidede to match the configuration
option with unbound ("so-reuseport"), PowerDNS ("reuseport") and/or
nginx ("reuseport").

4 years agoMerge branch '3259-cid-351372-concurrent-data-access-violations-atomicity' into ...
Mark Andrews [Wed, 6 Apr 2022 07:53:59 +0000 (07:53 +0000)] 
Merge branch '3259-cid-351372-concurrent-data-access-violations-atomicity' into 'main'

Resolve "CID 351372:  Concurrent data access violations  (ATOMICITY)"

Closes #3259

See merge request isc-projects/bind9!6090

4 years agoUnlink the timer event before trying to purge it
Mark Andrews [Wed, 6 Apr 2022 05:52:24 +0000 (15:52 +1000)] 
Unlink the timer event before trying to purge it

as far as I can determine the order of operations is not important.

    *** CID 351372:  Concurrent data access violations  (ATOMICITY)
    /lib/isc/timer.c: 227 in timer_purge()
    221      LOCK(&timer->lock);
    222      if (!purged) {
    223      /*
    224       * The event has already been executed, but not
    225       * yet destroyed.
    226       */
    >>>     CID 351372:  Concurrent data access violations  (ATOMICITY)
    >>>     Using an unreliable value of "event" inside the second locked section. If the data that "event" depends on was changed by another thread, this use might be incorrect.
    227      timerevent_unlink(timer, event);
    228      }
    229      }
    230     }
    231
    232     void

4 years agoMerge branch '3258-cid-351370-cid-351371-after-adb-refactoring' into 'main'
Mark Andrews [Wed, 6 Apr 2022 07:33:19 +0000 (07:33 +0000)] 
Merge branch '3258-cid-351370-cid-351371-after-adb-refactoring' into 'main'

Resolve "CID 351370 & CID 351371 after ADB refactoring"

Closes #3258

See merge request isc-projects/bind9!6089

4 years agoMove lock to before label to prevent duplicate lock
Mark Andrews [Wed, 6 Apr 2022 02:56:17 +0000 (12:56 +1000)] 
Move lock to before label to prevent duplicate lock

    *** CID 351370:  Program hangs  (LOCK)
    /lib/dns/adb.c: 2699 in dns_adb_cancelfind()
    2693
    2694      LOCK(&nbucket->lock);
    2695      ISC_LIST_UNLINK(adbname->finds, find, plink);
    2696      UNLOCK(&nbucket->lock);
    2697
    2698     cleanup:
    >>>     CID 351370:  Program hangs  (LOCK)
    >>>     "pthread_mutex_lock" locks "find->lock" while it is locked.
    2699      LOCK(&find->lock);
    2700      if (!FIND_EVENTSENT(find)) {
    2701      ev = &find->event;
    2702      task = ev->ev_sender;
    2703      ev->ev_sender = find;
    2704      ev->ev_type = DNS_EVENT_ADBCANCELED;

4 years agoRemove unnecessary NULL test leading to REVERSE_INULL false positive
Mark Andrews [Wed, 6 Apr 2022 02:54:08 +0000 (12:54 +1000)] 
Remove unnecessary NULL test leading to REVERSE_INULL false positive

    *** CID 351371:  Null pointer dereferences  (REVERSE_INULL)
    /lib/dns/adb.c: 2615 in dns_adb_createfind()
    2609      /*
    2610       * Copy out error flags from the name structure into the find.
    2611       */
    2612      find->result_v4 = find_err_map[adbname->fetch_err];
    2613      find->result_v6 = find_err_map[adbname->fetch6_err];
    2614
    >>>     CID 351371:  Null pointer dereferences  (REVERSE_INULL)
    >>>     Null-checking "find" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    2615      if (find != NULL) {
    2616      if (want_event) {
    2617      INSIST((find->flags & DNS_ADBFIND_ADDRESSMASK) != 0);
    2618      isc_task_attach(task, &(isc_task_t *){ NULL });
    2619      find->event.ev_sender = task;
    2620      find->event.ev_action = action;

4 years agoMerge branch 'artem-fix-return-value-x509_store_up_ref' into 'main'
Artem Boldariev [Tue, 5 Apr 2022 12:51:00 +0000 (12:51 +0000)] 
Merge branch 'artem-fix-return-value-x509_store_up_ref' into 'main'

Change X509_STORE_up_ref() shim return value

See merge request isc-projects/bind9!6084

4 years agoChange X509_STORE_up_ref() shim return value
Artem Boldariev [Tue, 5 Apr 2022 10:33:40 +0000 (13:33 +0300)] 
Change X509_STORE_up_ref() shim return value

X509_STORE_up_ref() must return 1 on success, while the previous
implementation would return the references count. This commit fixes
that.

4 years agoMerge branch '3244-dig-use-after-free' into 'main'
Arаm Sаrgsyаn [Tue, 5 Apr 2022 11:52:00 +0000 (11:52 +0000)] 
Merge branch '3244-dig-use-after-free' into 'main'

Resolve "use-after-free in dighost.c/dig.c"

Closes #3244

See merge request isc-projects/bind9!6052

4 years agoAdd CHANGES note for [GL #3244]
Aram Sargsyan [Thu, 31 Mar 2022 23:17:56 +0000 (23:17 +0000)] 
Add CHANGES note for [GL #3244]

4 years agoFix using unset pointer when printing a debug message in dighost.c
Aram Sargsyan [Thu, 31 Mar 2022 22:00:21 +0000 (22:00 +0000)] 
Fix using unset pointer when printing a debug message in dighost.c

The used `query->handle` is always `NULL` at this point.

Change the code to use `handle` instead.

4 years agoAdd a missing clear_current_lookup() call in recv_done()
Aram Sargsyan [Tue, 29 Mar 2022 13:01:24 +0000 (13:01 +0000)] 
Add a missing clear_current_lookup() call in recv_done()

The error code path handling the `ISC_R_CANCELED` code lacks a
`clear_current_lookup()` call, without which dig hangs indefinitely
when handling the error.

Add the missing call to account for all references of the lookup so
it can be destroyed.

4 years agoWhen using +qr in dig print the data of the current query
Aram Sargsyan [Thu, 31 Mar 2022 14:33:49 +0000 (14:33 +0000)] 
When using +qr in dig print the data of the current query

In `send_udp()` and `launch_next_query()` functions, when calling
`dighost_printmessage()` to print detailed information about the
sent query, dig always prints the data of the first query in the
lookup's queries list.

The first query in the list can be already finished, having its handles
freed, and accessing this information results in assertion failure.

Print the current query's information instead.

4 years agoMerge branch '3158-only-set-foundname-on-success-test' into 'main'
Michal Nowak [Tue, 5 Apr 2022 09:02:09 +0000 (09:02 +0000)] 
Merge branch '3158-only-set-foundname-on-success-test' into 'main'

[CVE-2022-0635] Add regression test

Closes #3158

See merge request isc-projects/bind9!6060

4 years agoAdd regression test for CVE-2022-0635
Mark Andrews [Thu, 17 Feb 2022 04:03:52 +0000 (15:03 +1100)] 
Add regression test for CVE-2022-0635

4 years agoMerge branch '3220-digdelv-test-uses-address-outside-of-our-control' into 'main'
Mark Andrews [Tue, 5 Apr 2022 04:22:11 +0000 (04:22 +0000)] 
Merge branch '3220-digdelv-test-uses-address-outside-of-our-control' into 'main'

Handle "network unreachable" error messages in digdelv system test

See merge request isc-projects/bind9!6010

4 years agoUse multiple fixed expressions for portable grep usage
Mark Andrews [Wed, 23 Mar 2022 00:53:00 +0000 (11:53 +1100)] 
Use multiple fixed expressions for portable grep usage

Additionally add "network unreachable" as an expected error message.

4 years agoMerge branch 'ondrej-dont-use-shutdown-function-name' into 'main'
Ondřej Surý [Mon, 4 Apr 2022 23:54:13 +0000 (23:54 +0000)] 
Merge branch 'ondrej-dont-use-shutdown-function-name' into 'main'

Rename shutdown() to test_shutdown() in timer_test.c

See merge request isc-projects/bind9!6078

4 years agoRename shutdown() to test_shutdown() in timer_test.c
Ondřej Surý [Mon, 4 Apr 2022 23:49:04 +0000 (01:49 +0200)] 
Rename shutdown() to test_shutdown() in timer_test.c

The shutdown() is part of standard library (POSIX-1), don't use such
name in the timer_test.c, but rather rename it to test_shutdown().

4 years agoMerge branch '3249-add-configuration-option-to-disable-SO_REUSEPORT_LB-fix' into...
Ondřej Surý [Mon, 4 Apr 2022 23:37:32 +0000 (23:37 +0000)] 
Merge branch '3249-add-configuration-option-to-disable-SO_REUSEPORT_LB-fix' into 'main'

Enable the load-balance-sockets configuration

Closes #3249

See merge request isc-projects/bind9!6076

4 years agoEnable the load-balance-sockets configuration
Ondřej Surý [Mon, 4 Apr 2022 23:20:13 +0000 (01:20 +0200)] 
Enable the load-balance-sockets configuration

Previously, HAVE_SO_REUSEPORT_LB has been defined only in the private
netmgr-int.h header file, making the configuration of load balanced
sockets inoperable.

Move the missing HAVE_SO_REUSEPORT_LB define the isc/netmgr.h and add
missing isc_nm_getloadbalancesockets() implementation.

4 years agoMerge branch '3249-add-configuration-option-to-disable-SO_REUSEPORT_LB' into 'main'
Ondřej Surý [Mon, 4 Apr 2022 21:37:54 +0000 (21:37 +0000)] 
Merge branch '3249-add-configuration-option-to-disable-SO_REUSEPORT_LB' into 'main'

Add option to configure load balance sockets

Closes #3249

See merge request isc-projects/bind9!6059

4 years agoAdd CHANGES and release note for [GL #3249]
Ondřej Surý [Fri, 1 Apr 2022 12:51:42 +0000 (14:51 +0200)] 
Add CHANGES and release note for [GL #3249]

4 years agoAdd option to configure load balance sockets
Ondřej Surý [Fri, 1 Apr 2022 12:43:14 +0000 (14:43 +0200)] 
Add option to configure load balance sockets

Previously, the option to enable kernel load balancing of the sockets
was always enabled when supported by the operating system (SO_REUSEPORT
on Linux and SO_REUSEPORT_LB on FreeBSD).

It was reported that in scenarios where the networking threads are also
responsible for processing long-running tasks (like RPZ processing, CATZ
processing or large zone transfers), this could lead to intermitten
brownouts for some clients, because the thread assigned by the operating
system might be busy.  In such scenarious, the overall performance would
be better served by threads competing over the sockets because the idle
threads can pick up the incoming traffic.

Add new configuration option (`load-balance-sockets`) to allow enabling
or disabling the load balancing of the sockets.

4 years agoMerge branch '3182-placeholder' into 'main'
Ondřej Surý [Mon, 4 Apr 2022 19:47:27 +0000 (19:47 +0000)] 
Merge branch '3182-placeholder' into 'main'

Add placeholder for [GL #3182]

Closes #3182

See merge request isc-projects/bind9!6071

4 years agoAdd placeholder for [GL #3182]
Ondřej Surý [Mon, 4 Apr 2022 19:45:09 +0000 (21:45 +0200)] 
Add placeholder for [GL #3182]

4 years agoMerge branch '3190-offload-rpz-updates' into 'main'
Ondřej Surý [Mon, 4 Apr 2022 19:44:15 +0000 (19:44 +0000)] 
Merge branch '3190-offload-rpz-updates' into 'main'

Run the RPZ update as offloaded work

Closes #3190

See merge request isc-projects/bind9!5938

4 years agoAdd CHANGES and release note for [GL #3190]
Ondřej Surý [Tue, 8 Mar 2022 17:36:08 +0000 (18:36 +0100)] 
Add CHANGES and release note for [GL #3190]

4 years agoRun the RPZ update as offloaded work
Ondřej Surý [Mon, 7 Mar 2022 12:55:03 +0000 (13:55 +0100)] 
Run the RPZ update as offloaded work

Previously, the RPZ updates ran quantized on the main nm_worker loops.
As the quantum was set to 1024, this might lead to service
interruptions when large RPZ update was processed.

Change the RPZ update process to run as the offloaded work.  The update
and cleanup loops were refactored to do as little locking of the
maintenance lock as possible for the shortest periods of time and the db
iterator is being paused for every iteration, so we don't hold the rbtdb
tree lock for prolonged periods of time.

4 years agoRefactor the dns_rpz_add/delete to use local rpz copy
Ondřej Surý [Tue, 8 Mar 2022 16:13:26 +0000 (17:13 +0100)] 
Refactor the dns_rpz_add/delete to use local rpz copy

Previously dns_rpz_add() were passed dns_rpz_zones_t and index to .zones
array.  Because we actually attach to dns_rpz_zone_t, we should be using
the local pointer instead of passing the index and "finding" the
dns_rpz_zone_t again.

Additionally, dns_rpz_add() and dns_rpz_delete() were used only inside
rpz.c, so make them static.

4 years agoGeneral cleanup of dns_rpz implementation
Ondřej Surý [Mon, 7 Mar 2022 12:55:03 +0000 (13:55 +0100)] 
General cleanup of dns_rpz implementation

Do a general cleanup of lib/dns/rpz.c style:

 * Removed deprecated and unused functions
 * Unified dns_rpz_zone_t naming to rpz
 * Unified dns_rpz_zones_t naming to rpzs
 * Add and use rpz_attach() and rpz_attach_rpzs() functions
 * Shuffled variables to be more local (cppcheck cleanup)

4 years agoMerge branch '3229-remove-exclusive-mode-from-ns_interfacemgr' into 'main'
Ondřej Surý [Mon, 4 Apr 2022 19:16:50 +0000 (19:16 +0000)] 
Merge branch '3229-remove-exclusive-mode-from-ns_interfacemgr' into 'main'

Remove exclusive mode from ns_interfacemgr

Closes #3229

See merge request isc-projects/bind9!6023

4 years agoAdd CHANGES note for [GL #3229]
Ondřej Surý [Wed, 23 Mar 2022 23:06:20 +0000 (00:06 +0100)] 
Add CHANGES note for [GL #3229]

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().