2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00
Commit Graph

38684 Commits

Author SHA1 Message Date
Tony Finch
9b7aa536ba QSBR: safe memory reclamation for lock-free data structures
This "quiescent state based reclamation" module provides support for
the qp-trie module in dns/qp. It is a replacement for liburcu, written
without reference to the urcu source code, and in fact it works in a
significantly different way.

A few specifics of BIND make this variant of QSBR somewhat simpler:

  * We can require that wait-free access to a qp-trie only happens in
    an isc_loop callback. The loop provides a natural quiescent state,
    after the callbacks are done, when no qp-trie access occurs.

  * We can dispense with any API like rcu_synchronize(). In practice,
    it takes far too long to wait for a grace period to elapse for each
    write to a data structure.

  * We use the idea of "phases" (aka epochs or eras) from EBR to
    reduce the amount of bookkeeping needed to track memory that is no
    longer needed, knowing that the qp-trie does most of that work
    already.

I considered hazard pointers for safe memory reclamation. They have
more read-side overhead (updating the hazard pointers) and it wasn't
clear to me how to nicely schedule the cleanup work. Another
alternative, epoch-based reclamation, is designed for fine-grained
lock-free updates, so it needs some rethinking to work well with the
heavily read-biased design of the qp-trie. QSBR has the fastest read
side of the basic SMR algorithms (with no barriers), and fits well
into a libuv loop. More recent hybrid SMR algorithms do not appear to
have enough benefits to justify the extra complexity.
2023-02-23 15:57:53 +00:00
Tony Finch
5e8aa4982b Merge branch 'fanf-refcount-trace-tid' into 'main'
Include thread ID in refcount trace output

See merge request isc-projects/bind9!7584
2023-02-23 14:28:34 +00:00
Tony Finch
63cd73d43e Include thread ID in refcount trace output 2023-02-23 14:28:27 +00:00
Arаm Sаrgsyаn
4e1bddc6e0 Merge branch 'aram/catz-remove-unused-catzs-loop' into 'main'
Remove catzs->loop

See merge request isc-projects/bind9!7569
2023-02-23 09:39:17 +00:00
Aram Sargsyan
18d67fa916 Remove catzs->loop
The 'loop' member of the dns_catz_zones structure is not used.
2023-02-23 08:56:37 +00:00
Evan Hunt
211ec73f41 Merge branch '3778-empty-include' into 'main'
fix a crash from using an empty string for "include"

Closes #3778

See merge request isc-projects/bind9!7572
2023-02-22 17:36:13 +00:00
Evan Hunt
dc27552c30 remove isc_glob
the isc_glob module was originally needed to support posix-style glob
processing on Windows, but is now just an unnecessary wrapper around
glob(3). this commit removes it.
2023-02-22 17:35:29 +00:00
Evan Hunt
4dfc3f056d fix a crash from using an empty string for "include"
the parser could crash when "include" specified an empty string in place
of the filename. this has been fixed by returning ISC_R_FILENOTFOUND
when the string length is 0.
2023-02-22 17:35:29 +00:00
Tony Finch
7aa0ee4f5e Merge branch 'fanf-atomic-lists' into 'main'
Simple lock-free singly-linked stack

See merge request isc-projects/bind9!7470
2023-02-22 17:05:51 +00:00
Ondřej Surý
6eb1340d1b Use atomic stack for async job queue
Previously, the async job queue would use a locked-list (ISC_LIST).
With introduction of atomic stack (that has to be drained at once), we
could use it to remove some contention between the threads and simplify
the async queue.

Fortunately, the reverse order still works for us - instead of append
and tail/prev operation on the list, we are now using prepend and
head/next operation on the atomic stack.
2023-02-22 16:13:37 +00:00
Tony Finch
36e56923ce Simple lock-free stack in <isc/stack.h>
Add a singly-linked stack that supports lock-free prepend and drain (to
empty the list and clean up its elements).  Intended for use with QSBR
to collect objects that need safe memory reclamation, or any other user
that works with adding objects to the stack and then draining them in
one go like various work queues.

In <isc/atomic.h>, add an `atomic_ptr()` macro to make type
declarations a little less abominable, and clean up a duplicate
definition of `atomic_compare_exchange_strong_acq_rel()`
2023-02-22 16:13:37 +00:00
Tom Krizek
29a7507b04 Merge branch '3622-serve-stale-rrsig-test' into 'main'
[CVE-2022-3736] Test RRSIG queries with serve-stale enabled

Closes #3622

See merge request isc-projects/bind9!7578
2023-02-22 12:57:09 +00:00
Mark Andrews
add40273df Test RRSIG queries with serve-stale enabled
Make RRSIG queries where the existing tests trigger a DNS_EVENT_TRYSTALE
event.
2023-02-22 13:22:02 +01:00
Tom Krizek
af33cd479b Merge branch '3619-serve-stale-client-timeout-crash-test' into 'main'
[CVE-2022-3924] Add a reproducer for the serve-stale crash when recursive clients soft quota is reached

Closes #3619

See merge request isc-projects/bind9!7575
2023-02-22 11:54:42 +00:00
Aram Sargsyan
4b52b0b4a9 Add tests for CVE-2022-3924
Reproduce the assertion by configuring a 'named' resolver with
'recursive-clients 10;' configuration option and running 20
queries is parallel.

Also tweak the 'ans2/ans.pl' to simulate a 50ms network latency
when qname starts with "latency". This makes sure that queries
running in parallel don't get served immediately, thus allowing
the configured recursive clients quota limitation to be activated.
2023-02-22 10:39:06 +01:00
Evan Hunt
1fb5d42416 Merge branch '3873-cleanup-task-timer-refs' into 'main'
remove references to obsolete isc_task/timer functions

Closes #3873

See merge request isc-projects/bind9!7568
2023-02-22 08:13:47 +00:00
Evan Hunt
b058f99cb8 remove references to obsolete isc_task/timer functions
removed references in code comments, doc/dev documentation, etc, to
isc_task, isc_timer_reset(), and isc_timertype_inactive. also removed a
coccinelle patch related to isc_timer_reset() that was no longer needed.
2023-02-22 08:13:30 +00:00
Evan Hunt
ee186855bf Merge branch 'each-no-sdb' into 'main'
remove SDB API and refactor builtin databases

Closes #3882

See merge request isc-projects/bind9!7558
2023-02-22 06:32:37 +00:00
Evan Hunt
dee4939299 CHANGES for [GL #3882] 2023-02-21 10:13:34 -08:00
Evan Hunt
aea4f10817 make builtin a standalone dns_db implementation
instead of using the SDB API as a wrapper to register and
unregister and provide a call framework for the builtin databases,
this commit flattens things so that the builtin databases implement
dns_db directly.
2023-02-21 10:13:10 -08:00
Evan Hunt
603cdb6332 move the dns_sdb API
move all dns_sdb code into bin/named/builtin.c, which is the
only place from which it's called.

(note this is temporary: later we'll refactor builtin so that it's a
standalone dns_db implementation on its own instead of using SDB
as a wrapper.)
2023-02-21 10:13:10 -08:00
Evan Hunt
77e7eac54c enable detailed db tracing
move database attach/detach functions to db.c, instead of
requiring them to be implemented for every database type.
instead, they must implement a 'destroy' function that is
called when references go to zero.

this enables us to use ISC_REFCOUNT_IMPL for databases,
with detailed tracing enabled by setting DNS_DB_TRACE to 1.
2023-02-21 10:13:10 -08:00
Evan Hunt
8da43bb7f5 simplify dns_sdb API
SDB is currently (and foreseeably) only used by the named
builtin databases, so it only needs as much of its API as
those databases use.

- removed three flags defined for the SDB API that were always
  set the same by builtin databases.

- there were two different types of lookup functions defined for
  SDB, using slightly different function signatures. since backward
  compatibility is no longer a concern, we can eliminate the 'lookup'
  entry point and rename 'lookup2' to 'lookup'.

- removed the 'allnodes' entry point and all database iterator
  implementation code

- removed dns_sdb_putnamedrr() and dns_sdb_putnamedrdata() since
  they were never used.
2023-02-21 10:13:10 -08:00
Evan Hunt
ffa4757c79 use member name initialization for methods
initialize dns_dbmethods, dns_sdbmethods and dns_rdatasetmethods
using explicit struct member names, so we don't have to keep track
of NULLs for unimplemented functions any longer.
2023-02-21 10:13:10 -08:00
Evan Hunt
8036412aaa make fewer dns_db functions mandatory-to-implement
some dns_db functions would have crashed if the DB implementation failed
to implement them, requiring the implementations to add functions that
did nothing but return ISC_R_NOTIMPLEMENTED or some obvious default
value. we can just have the dns_db wrapper functions themselves return
those values, and clean up the implementations accordingly.
2023-02-21 10:13:10 -08:00
Evan Hunt
c90fafa45d remove rdatalist_p.h
make the private isc__rdatalist_* functions public dns_rdatalist
functions so that all the rdatalist primitives can be used by
callers to libdns. (this will be needed later for moving SDB and
SDLZ out of libdns.)
2023-02-21 10:13:10 -08:00
Matthijs Mekking
c283850cc3 Merge branch 'matthijs-fix-kasp-attach-detach-usage' into 'main'
Fix kasp attach detach usage

See merge request isc-projects/bind9!7563
2023-02-21 15:45:12 +00:00
Mark Andrews
b41882cc75 Fix dns_kasp_attach / dns_kasp_detach usage
The kasp pointers in dns_zone_t should consistently be changed by
dns_kasp_attach and dns_kasp_detach so the usage is balanced.
2023-02-21 15:47:44 +01:00
Tony Finch
caafb15e1e Merge branch 'fanf-prune-libbind9' into 'main'
Move the last bits of libbind9 into libisc

See merge request isc-projects/bind9!7462
2023-02-21 13:12:44 +00:00
Tony Finch
8bb5f37fd4 Add CHANGES and release note
[cleanup]	Move bind9_getaddresses() to isc_getaddresses()
		and remove the now empty libbind9.
2023-02-21 13:12:26 +00:00
Tony Finch
4da9c582b8 Remove libbind9
It is now empty.
2023-02-21 13:12:26 +00:00
Tony Finch
3fef7c626a Move bind9_getaddresses() to isc_getaddresses()
No need to have a whole library for one function.
2023-02-21 13:12:26 +00:00
Mark Andrews
b2923ce356 Merge branch '3884-cid-436299-null-pointer-dereference-in-lib-dns-resolver-c' into 'main'
Resolve "CID 436299: Null pointer dereference in lib/dns/resolver.c"

Closes #3884

See merge request isc-projects/bind9!7562
2023-02-21 12:58:25 +00:00
Mark Andrews
9c17f4353b Cleanup left over 'fctx != NULL' test following refactoring
This was causing 'CID 436299: Null pointer dereferences (REVERSE_INULL)'
in Coverity.  Also removed an 'INSIST(fctx != NULL);' that should
no longer be needed.
2023-02-21 12:22:27 +00:00
Arаm Sаrgsyаn
69b39899d5 Merge branch '3880-fix-rpz-assertion-failure-during-failed-reconfiguration' into 'main'
Detach rpzs and catzs from the previous view

Closes #3880

See merge request isc-projects/bind9!7552
2023-02-21 09:01:27 +00:00
Aram Sargsyan
b086374b1d Add a CHANGES note for [GL #3880] 2023-02-21 08:23:59 +00:00
Aram Sargsyan
121a095a22 Detach rpzs and catzs from the previous view
When switching to a new view during a reconfiguration (or reverting
to the old view), detach the 'rpzs' and 'catzs' from the previuos view.

The 'catzs' case was earlier solved slightly differently, by detaching
from the new view when reverting to the old view, but we can not solve
this the same way for 'rpzs', because now in BIND 9.19 and BIND 9.18
a dns_rpz_shutdown_rpzs() call was added in view's destroy() function
before detaching the 'rpzs', so we can not leave the 'rpzs' attached to
the previous view and let it be shut down when we intend to continue
using it with the new view.

Instead, "re-fix" the issue for the 'catzs' pointer the same way as
for 'rpzs' for consistency, and also because a similar shutdown call
is likely to be implemented for 'catzs' in the near future.
2023-02-21 08:23:13 +00:00
Aram Sargsyan
95f4bac002 Add an "rpz" system test check for a failed reconfiguration
The faulty "DLZ" configuration triggers a reconfiguration failure
in such a place where view reverting code is covered.
2023-02-21 08:23:13 +00:00
Evan Hunt
1efbca6856 Merge branch 'each-cleanup-gethostname' into 'main'
remove named_os_gethostname()

See merge request isc-projects/bind9!7555
2023-02-18 20:23:56 +00:00
Evan Hunt
197334464e remove named_os_gethostname()
this function was just a front-end for gethostname(). it was
needed when we supported windows, which has a different function
for looking up the hostname; it's not needed any longer.
2023-02-18 20:23:41 +00:00
Mark Andrews
345dc4d505 Merge branch '3879-hmac_createctx-fails-to-free-context-on-isc_hmac_init-failure' into 'main'
Resolve "hmac_createctx fails to free context on isc_hmac_init failure"

Closes #3879

See merge request isc-projects/bind9!7549
2023-02-17 22:29:28 +00:00
Mark Andrews
d22257a370 In hmac_createctx free ctx on isc_hmac_init failure 2023-02-17 21:58:56 +00:00
Michal Nowak
b131c60bf5 Merge branch 'mnowak/qa-tools-update' into 'main'
Python formatting updates

See merge request isc-projects/bind9!7551
2023-02-17 15:00:07 +00:00
Michal Nowak
8064ac6bec Fix unnecessary "else" after "raise" with pylint 2.16.2
bin/tests/system/get_algorithms.py:225:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
2023-02-17 15:31:52 +01:00
Michal Nowak
3cd2cc6254 Adapt to Python scripts to black 23.1.0 2023-02-17 15:31:52 +01:00
Tony Finch
000f885614 Merge branch 'fanf-libbind9-libisccfg' into 'main'
Move bind9/check to isccfg/check

See merge request isc-projects/bind9!7461
2023-02-17 12:50:39 +00:00
Tony Finch
dcb54af220 Move bind9/check to isccfg/check
Since it is part of the configuration machinery
2023-02-17 12:13:37 +00:00
Ondřej Surý
6ba2579c67 Merge branch 'ondrej-further-dns_validator-refactoring' into 'main'
additional refactoring of dns_validator

See merge request isc-projects/bind9!7546
2023-02-17 06:22:03 +00:00
Evan Hunt
e49350721f CHANGES for [GL #3797] 2023-02-17 07:18:25 +01:00
Evan Hunt
1ee30be7ce remove validator lock
as every validator function is loop-synchronized, it should no longer be
necessary to use a validator lock.

calling dns_validator_send(), dns_validator_cancel() or
dns_validator_destroy() from a thread other than the one on which the
validator is running will now cause an assertion failure; this should be
fine since the validator and resolver are tightly coupled, and the fetch
contexts and validators run in the same loops.
2023-02-17 07:18:25 +01:00