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

34696 Commits

Author SHA1 Message Date
Evan Hunt
2c7232d82f Temporarily move dns_tcpmsg functionality into dispatch
Continuing the effort to move all uses of the isc_socket API into
dispatch.c, this commit removes the dns_tcpmsg module entirely, as
dispatch was its only caller, and moves the parts of its functionality
that were being used into the dispatch module.

This code will be removed when we switch to using netmgr TCPDNS.
2021-10-02 11:39:56 -07:00
Evan Hunt
4f30b679e7 Creating TCP dispatch now creates/binds the socket
Previously, creation of TCP dispatches differed from UDP in that a TCP
dispatch was created to attach to an existing socket, whereas a UDP
dispatch would be created in a vacuum and sockets would be opened on
demand when a transaction was initiated.

We are moving as much socket code as possible into the dispatch module,
so that it can be replaced with a netmgr version as easily as
possible. (This will also have the side effect of making TCP and UDP
dispatches more similar.)

As a step in that direction, this commit changes
dns_dispatch_createtcp() so that it creates the TCP socket.
2021-10-02 11:39:34 -07:00
Evan Hunt
f439eb5d99 Dispatch API simplification
- Many dispatch attributes can be set implicitly instead of being passed
  in. we can infer whether to set DNS_DISPATCHATTR_TCP or _UDP from
  whether we're calling dns_dispatch_createtcp() or _createudp().  we
  can also infer DNS_DISPATCHATTR_IPV4 or _IPV6 from the addresses or
  the socket that were passed in.

- We no longer use dup'd sockets in UDP dispatches, so the 'dup_socket'
  parameter has been removed from dns_dispatch_createudp(), along with
  the code implementing it. also removed isc_socket_dup() since it no
  longer has any callers.

- The 'buffersize' parameter was ignored and has now been removed;
  buffersize is now fixed at 4096.

- Maxbuffers and maxrequests don't need to be passed in on every call to
  dns_dispatch_createtcp() and _createudp().

  In all current uses, the value for mgr->maxbuffers will either be
  raised once from its default of 20000 to 32768, or else left
  alone. (passing in a value lower than 20000 does not lower it.) there
  isn't enough difference between these values for there to be any need
  to configure this.

  The value for disp->maxrequests controls both the quota of concurrent
  requests for a dispatch and also the size of the dispatch socket
  memory pool. it's not clear that this quota is necessary at all. the
  memory pool size currently starts at 32768, but is sometimes lowered
  to 4096, which is definitely unnecessary.

  This commit sets both values permanently to 32768.

- Previously TCP dispatches allocated their own separate QID table,
  which didn't incorporate a port table. this commit removes
  per-dispatch QID tables and shares the same table between all
  dispatches. since dispatches are created for each TCP socket, this may
  speed up the dispatch allocation process. there may be a slight
  increase in lock contention since all dispatches are sharing a single
  QID table, but since TCP sockets are used less often than UDP
  sockets (which were already sharing a QID table), it should not be a
  substantial change.

- The dispatch port table was being used to determine whether a port was
  already in use; if so, then a UDP socket would be bound with
  REUSEADDR. this commit removes the port table, and always binds UDP
  sockets that way.
2021-10-02 10:21:49 +02:00
Evan Hunt
9fd375217d Remove DNS_DISPATCHATTR_MAKEQUERY
This attribute was set but was no longer being used.
2021-10-02 10:21:46 +02:00
Evan Hunt
5dcf55da03 Remove support for shared UDP dispatch sockets
Currently the netmgr doesn't support unconnected, shared UDP sockets, so
there's no reason to retain that functionality in the dispatcher prior
to porting to the netmgr.

In this commit, the DNS_DISPATCHATTR_EXCLUSIVE attribute has been
removed as it is now non-optional; UDP dispatches are alwasy exclusive.
Code implementing non-exclusive UDP dispatches has been removed.
dns_dispatch_getentrysocket() now always returns the dispsocket for UDP
dispatches and the dispatch socket for TCP dispatches.

There is no longer any need to search for existing dispatches from
dns_dispatch_getudp(), so the 'mask' option has been removed, and the
function renamed to the more descriptive dns_dispatch_createudp().
2021-10-02 10:21:43 +02:00
Evan Hunt
300392ae2f General code refactoring
- style cleanup
- removed NULL checks in places where they are not currently needed
- use isc_refcount for dispatch reference counting
- revised code flow for readability
- remove some #ifdefs that are no longer relevant
- remove unused struct members
- removed unnecessary function parameters
- use C99 struct initialization
2021-10-02 10:21:38 +02:00
Evan Hunt
5863acc907 Make sharing of pending TCP dispatches nonoptional
The DNS_REQUESTOPT_SHARE flag was added when client-side pipelining of
TCP queries was implemented. there was no need to make it optional;
forcing it to be in effect for all requests simplfiies the code.
2021-10-02 10:21:35 +02:00
Evan Hunt
ca11f68d61 Simplify dns_dispatchmgr_create with fixed buffersize
- UDP buffersize is now established when creating dispatch manager
  and is always set to 4096.

- Set up the default port range in dispatchmgr before setting the magic
  number.

- Magic is not set until dispatchmgr is fully created.
2021-10-02 10:21:32 +02:00
Evan Hunt
57fce0e895 Remove some DNS_DISPATCHATTR flags
- DNS_DISPATCHATTR_CANREUSE was never set. the code that implements it
  has been removed.

- DNS_DISPATCHOPT_FIXEDID and DNS_DISPATCHATTR_FIXEDID were both
  defined, but only the DISPATCHOPT was ever set; it appears the
  DISPATCHATTR was added accidentally.

- DNS_DISPATCHATTR_NOLISTEN was set but never used.
2021-10-02 10:21:25 +02:00
Evan Hunt
c69f2018a3 Remove unused code in dispatch.c
Some routines in dispatch.c are obsolete and unused; clean them up
before porting to netmgr.
2021-10-02 10:21:22 +02:00
Vicky Risk
a480522f6e Merge branch '2913-release-checklist-for-bind-is-missing-a-step-for-the-official-docker-image' into 'main'
Resolve "Release checklist for BIND + a step for the official docker image"

Closes #2913

See merge request isc-projects/bind9!5436
2021-10-01 15:41:23 +00:00
Vicky Risk
829d02fa3f Update Release.md to break out steps required to build and update packages 2021-10-01 15:21:59 +00:00
Artem Boldariev
39584a5226 Merge branch 'artem/tls-protocols-conf' into 'main'
Resolve #2795, #2796: implement TLS configuration options to make it possible to specify supported TLS versions and implement perfect forward secrecy for DoH and DoT

Closes #2796 and #2795

See merge request isc-projects/bind9!5444
2021-10-01 13:28:14 +00:00
Artem Boldariev
4369d94f68 Provide an example of forward secrecy enabled TLS configuration
This commit adds and example of a perfect forward secrecy enabled TLS
configuration intended to be used as a starting point.
2021-10-01 15:56:02 +03:00
Artem Boldariev
834bb4e52b Modify release notes [GL #2796]
Mention the new "tls" clause options in the release notes.
2021-10-01 15:56:02 +03:00
Artem Boldariev
503a9a56b2 Modify release notes [GL #2795]
Mention that it is now possible to specify supported TLS protocol
versions.
2021-10-01 15:56:02 +03:00
Artem Boldariev
bbf758a6fd Modify CHANGES [GL #2796]
Mention the new "tls" options in the CHANGES file.
2021-10-01 15:55:57 +03:00
Artem Boldariev
17d2b3c8db Modify CHANGES [GL #2795]
Mention in the CHANGES file that supported TLS versions can be
specified in the configuration file.
2021-10-01 15:51:40 +03:00
Artem Boldariev
9c34fa2896 Mention that "tls" options defaults are outside of our control
We have to mention that every option within a "tls" clause has
defaults out of our control as some platforms have means for defining
encryption policies globally for any application on the system.

In order to comply with these policies, we have not to modify TLS
contexts settings, unless we have to do so according to the options
specified within "tls" clauses.
2021-10-01 15:50:43 +03:00
Artem Boldariev
c759f25c7b Add "session-tickets" options to the "tls" clause
This commit adds the ability to enable or disable stateless TLS
session resumption tickets (see RFC5077). Having this ability is
twofold.

Firstly, these tickets are encrypted by the server, and the algorithm
might be weaker than the algorithm negotiated during the TLS session
establishment (it is in general the case for TLSv1.2, but the generic
principle applies to TLSv1.3 as well, despite it having better ciphers
for session tickets). Thus, they might compromise Perfect Forward
Secrecy.

Secondly, disabling it might be necessary if the same TLS key/cert
pair is supposed to be used by multiple servers to achieve, e.g., load
balancing because the session ticket by default gets generated in
runtime, while to achieve successful session resumption ability, in
this case, would have required using a shared key.

The proper alternative to having the ability to disable stateless TLS
session resumption tickets is to implement a proper session tickets
key rollover mechanism so that key rotation might be performed
often (e.g. once an hour) to not compromise forward secrecy while
retaining the associated performance benefits. That is much more work,
though. On the other hand, having the ability to disable session
tickets allows having a deployable configuration right now in the
cases when either forward secrecy is wanted or sharing the TLS
key/cert pair between multiple servers is needed (or both).
2021-10-01 15:50:43 +03:00
Artem Boldariev
16c6e2be06 Add "prefer-server-ciphers" options to the "tls" clause
This commit adds support for enforcing the preference of server
ciphers over the client ones. This way, the server attains control
over the ciphers priority and, thus, can choose more strong cyphers
when a client prioritises less strong ciphers over the more strong
ones, which is beneficial when trying to achieve Perfect Forward
Secrecy.
2021-10-01 15:50:43 +03:00
Artem Boldariev
3b88d783a2 Add "ciphers" options to the "tls" clause
This commit adds support for setting TLS cipher list string in the
format specified in the OpenSSL
documentation (https://www.openssl.org/docs/man1.1.1/man1/ciphers.html).

The syntax of the cipher list is verified so that specifying the wrong
string will prevent the configuration from being loaded.
2021-10-01 15:50:43 +03:00
Artem Boldariev
f2ae4c8480 DH-parameters loading support
This commit adds support for loading DH-parameters (Diffie-Hellman
parameters) via the new "dhparam-file" option within "tls" clause. In
particular, Diffie-Hellman parameters are needed to enable the range
of forward-secrecy enabled cyphers for TLSv1.2, which are getting
silently disabled otherwise.
2021-10-01 15:50:43 +03:00
Artem Boldariev
992f815770 Add "protocols" options to the "tls" clause
This commit adds the ability to specify allowed TLS protocols versions
within the "tls" clause. If an unsupported TLS protocol version is
specified in a file, the configuration file will not pass
verification.

Also, this commit adds strict checks for "tls" clauses verification,
in particular:

- it ensures that loading configuration files containing duplicated
"tls" clauses is not allowed;

- it ensures that loading configuration files containing "tls" clauses
missing "cert-file" or "key-file" is not allowed;

- it ensures that loading configuration files containing "tls" clauses
named as "ephemeral" or "none" is not allowed.
2021-10-01 15:50:43 +03:00
Artem Boldariev
9e039986cd TLS: set some common options both for client and server contexts
This commit makes the TLS context manipulation code set some of the
common protocol versions regardless of the OpenSSL version in use.
2021-10-01 15:50:42 +03:00
Arаm Sаrgsyаn
aae268b6c8 Merge branch '2308-catz-reload-when-missing-a-zone' into 'main'
Handle a missing zone when reloading a catalog zone

Closes #2308

See merge request isc-projects/bind9!5442
2021-09-30 19:52:00 +00:00
Aram Sargsyan
3edaa0bde6 Add CHANGES and release notes for [GL #2308] 2021-09-30 19:19:43 +00:00
Aram Sargsyan
94a5712801 Handle a missing zone when reloading a catalog zone
Previously a missing/deleted zone which was referenced by a catalog
zone was causing a crash when doing a reload.

This commit will make `named` to ignore the fact that the zone is
missing, and make sure to restore it later on.
2021-09-30 19:14:12 +00:00
Ondřej Surý
2b5d3f125c Merge branch '2921-replace-xmalloc_true-with-own-assertions' into 'main'
Use assertions to check for failed allocations

See merge request isc-projects/bind9!5449
2021-09-30 13:52:01 +00:00
Ondřej Surý
c3250a9b81 Use assertions to check for failed allocations
It was discovered that named could crash due to a segmentation fault
when jemalloc was in use and memory allocation failed.  This was not
intended to happen as jemalloc's "xmalloc" option was set to "true" in
the "malloc_conf" configuration variable.  However, that variable was
only set after jemalloc was already done with parsing it, which
effectively caused setting that variable to have no effect.

While investigating this issue, it was also discovered that enabling the
"xmalloc" option makes jemalloc use a slow processing path, decreasing
its performance by about 25%. [1]

Additionally, further testing (carried out after fixing the way
"malloc_conf" was set) revealed that the non-default configuration
options do not have any measurable effect on either authoritative or
recursive DNS server performance.

Replace code setting various jemalloc options to non-default values with
assertion checks of mallocx()/rallocx() return values.

[1] https://github.com/jemalloc/jemalloc/pull/523
2021-09-30 13:54:55 +02:00
Artem Boldariev
7b18cdc315 Merge branch '2924-fix-heap-user-after-free-when-checking-for-http-duplicates' into 'main'
Fix heap use after free when checking for "http" duplicates

Closes #2924

See merge request isc-projects/bind9!5452
2021-09-30 09:16:43 +00:00
Artem Boldariev
6499ae021c Modify CHANGES [GL #2924]
Mention that heap-use-after-free when checking for "http" duplicates
is fixed.
2021-09-30 11:56:10 +03:00
Artem Boldariev
ef65d32594 Fix heap use after free when checking for "http" duplicates
This commit fixes heap use after free when checking BIND's
configuration files for errors with http clauses.  The old code
was unnecessarially copying the http element name and freeing
it to early.  The name is now used directly.
2021-09-30 11:56:10 +03:00
Artem Boldariev
52f411b288 Merge branch '2923-validate-doh-path-in-dig' into 'main'
Validate HTTP path passed to dig

Closes #2923

See merge request isc-projects/bind9!5451
2021-09-30 08:36:58 +00:00
Artem Boldariev
b20a8c5065 Modify CHANGES [GL #2923]
Mention that the HTTP path is now validated.
2021-09-29 19:42:18 +03:00
Artem Boldariev
0d5e0b9922 Validate HTTP path passed to dig
The commit makes sure that the HTTP path passed to dig is a valid one.
2021-09-29 19:42:03 +03:00
Ondřej Surý
4ce5f94333 Merge branch '2908-rwlock-with-reader-and-writer-both-waiting' into 'main'
Resolve "rwlock with reader and writer both waiting"

Closes #2908

See merge request isc-projects/bind9!5421
2021-09-29 15:56:35 +00:00
Mark Andrews
c04bce278f Add CHANGES note for [GL #2908] 2021-09-29 17:36:19 +02:00
Mark Andrews
4e1faa35d5 Pause the dbiterator before calling dns_db_find
zone.c:integrity_checks() acquires a read lock while iterating the
zone database, and calls zone_check_mx() which acquires another
read lock. If another thread tries to acquire a write lock in the
meantime, it can deadlock. Calling dns_dbiterator_pause() to release
the first read lock prevents this.
2021-09-29 17:35:57 +02:00
Mark Andrews
214c985876 Merge branch '2911-9-16-21-regression-legacy-check-names-configuration-does-not-work-anymore' into 'main'
Resolve "9.16.21 Regression: Legacy check-names configuration does not work anymore"

Closes #2911

See merge request isc-projects/bind9!5425
2021-09-29 09:42:54 +00:00
Mark Andrews
14249ce9fe Add CHANGES note for [GL #2911] 2021-09-29 09:18:59 +00:00
Mark Andrews
0b0d400d7c Check that 'check-names {secondary|slave} ignore;' works 2021-09-29 09:18:59 +00:00
Mark Andrews
9107c8caeb Check that 'check-names master ignore;' works 2021-09-29 09:18:59 +00:00
Mark Andrews
a3c6516a75 Fix "check-names master" and "check-names slave"
check for type "master" / "slave" at the same time as checking
for "primary" / "secondary" as we step through the maps.

Checking "primary" then "master" or "master" then "primary" does
not work as the synomym is not checked for to stop the search.
Similarly with "secondary" and "slave".
2021-09-29 09:18:59 +00:00
Mark Andrews
cb16ba3a41 Merge branch '2909-pointers-used-before-validation' into 'main'
Resolve "Pointers used before validation"

Closes #2909

See merge request isc-projects/bind9!5443
2021-09-29 01:41:25 +00:00
Mark Andrews
06a69e03ac Address use before NULL check warning of obj
move deference of obj to after NULL check
2021-09-28 11:57:47 +10:00
Mark Andrews
8fc9bb8e8e Address use before NULL check warning of ievent->sock
Reorder REQUIRE checks to ensure ievent->sock is checked earlier
2021-09-28 11:57:47 +10:00
Mark Andrews
7079829b84 Address use before NULL check warning of uvreq
move dereference of uvreq until the after NULL check.
2021-09-28 11:57:47 +10:00
Mark Andrews
eeec53eb5d Merge branch '2910-unknown-system-test-doesn-t-leave-forensics' into 'main'
Resolve "unknown system test doesn't leave forensics"

Closes #2910

See merge request isc-projects/bind9!5422
2021-09-24 03:34:18 +00:00
Mark Andrews
96b7421f8c Preserve dig results in case of test failure 2021-09-24 03:07:31 +00:00