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

14012 Commits

Author SHA1 Message Date
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
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ý
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
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
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
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
Ondřej Surý
8248da3b83 Preserve the contents of socket buffer on realloc
On TCPDNS/TLSDNS read callback, the socket buffer could be reallocated
if the received contents would be larger than the buffer.  The existing
code would not preserve the contents of the existing buffer which lead
to the loss of the already received data.

This commit changes the isc_mem_put()+isc_mem_get() with isc_mem_reget()
to preserve the existing contents of the socket buffer.
2021-09-23 22:36:01 +02:00
Ondřej Surý
8edbd0929f Use isc_mem_reget() to handle the internal active handle cache
The netmgr, has an internal cache for freed active handles.  This cache
was allocated using isc_mem_allocate()/isc_mem_free() API because it was
simpler to reallocate the cache when we needed to grow it.  The new
isc_mem_reget() function could be used here reducing the need to use
isc_mem_allocate() API which is tad bit slower than isc_mem_get() API.
2021-09-23 22:17:15 +02:00
Ondřej Surý
15d6249260 Use isc_mem_reget() when growing buffer dynamically
Previously, we cannot use isc_mem_reallocate() for growing the buffer
dynamically, because the memory was allocated using the
isc_mem_get()/isc_mem_put() API.  With the introduction of the
isc_mem_reget() function, we can use grow/shrink the memory directly
without always moving the memory around as the allocator might have
reserved some extra space after the initial allocation.
2021-09-23 22:17:15 +02:00
Ondřej Surý
4cdb3abf27 Return non-NULL pointer on zero-sized allocations and reallocations
Previously, the zero-sized allocations would return NULL pointer and the
caller had to make sure to not dereference such pointer.  The C standard
defines the zero-sized calls to malloc() as implementation specific and
jemalloc mallocx() with zero size would be undefined behaviour.  This
complicated the code as it had to handle such cases in a special manner
in all allocator and deallocator functions.

Now, for realloc(), the situation is even more complicated.  In C
standard up to C11, the behavior would be implementation defined, and
actually some implementation would free to orig ptr and some would not.
Since C17 (via DR400) would deprecate such usage and since C23, the
behaviour would be undefined.

This commits changes helper mem_get(), mem_put() and mem_realloc()
functions to grow the zero-allocation from 0 to sizeof(void *).

This way we get a predicable behaviour that all the allocations will
always return valid pointer.
2021-09-23 22:17:15 +02:00
Ondřej Surý
aeb3d1cab3 Add isc_mem_reget() function to realloc isc_mem_get allocations
The isc_mem_get() and isc_mem_put() functions are leaving the memory
allocation size tracking to the users of the API, while
isc_mem_allocate() and isc_mem_free() would track the sizes internally.
This allowed to have isc_mem_rellocate() to manipulate the memory
allocations by the later set, but not the former set of the functions.

This commit introduces isc_mem_reget(ctx, old_ptr, old_size, new_size)
function that operates on the memory allocations with external size
tracking completing the API.
2021-09-23 11:18:07 -07:00
Ondřej Surý
edee9440d0 Remove the mastefile-format map option
As previously announced, this commit removes the masterfile-format
format 'map' from named, all the tools, the documentation and the
system tests.
2021-09-17 07:09:50 +02:00
Ondřej Surý
6b7a488cbc Mark the masterfile-format type 'map' as deprecated
The map masterfile-format is very fragile and it needs API bump every
time a RBTDB data structures changes.  Also while testing it, we found
out that files larger than 2GB weren't loading and nobody noticed, and
loading many map files were also failing (subject to kernel limits).

Thus we are marking the masterfile-format type 'map' as deprecated and
to be removed in the next stable BIND 9 release.
2021-09-17 05:58:02 +02:00
Mark Andrews
7f5f7b2d7b Specifying sig-signing-type causes named to fail
the range check error was being applied unconditionally
2021-09-16 18:17:22 +10:00
Evan Hunt
a27860ba57 mark "cache-file" as ancient and remove all code implementing it
"cache-file" was already documented as intended for testing
purposes only and not to be used, so we can remove it without
waiting.  this commit marks the option as "ancient", and
removes all the documentation and implementing code, including
dns_cache_setfilename() and dns_cache_dump().

it also removes the documentation for the '-x cachefile`
parameter to named, which had already been removed, but the man
page was not updated at the time.
2021-09-16 00:19:02 -07:00
Evan Hunt
a67d008ba5 deprecate "cache-file"
this commit marks the "cache-file" option as deprecated.
2021-09-16 00:19:02 -07:00
Evan Hunt
14c8d7dfb7 check port in *-source and *-source-v6 options in named.conf
- when transfer-source(-v6), query-source(-v6), notify-source(-v6)
  or parental-source(-v6) are specified with a port number, issue a
  warning.
- when the port specified is the same as the DNS listener port (i.e.,
  53, or whatever was specified as "port" in "options"), issue a fatal
  error.
- check that "port" is in range. (previously this was only checked
  by named, not by named-checkconf.)
- added checkconf tests.
- incidental fix: removed dead code in check.c:bind9_check_namedconf().

(note: if the DNS port is specified on the command line with "named -p",
that is not conveyed to libbind9, so these checks will not take it into
account.)
2021-09-14 19:24:33 +02:00
Ondřej Surý
8ac1d4e0da Remove the code to adjust listening interfaces for *-source-v6
Previously, named would run with a configuration
where *-source-v6 (notify-source-v6, transfer-source-v6 and
query-source-v6) address and port could be simultaneously used for
listening.  This is no longer true for BIND 9.16+ and the code that
would do interface adjustments would unexpectedly disable listening on
TCP for such interfaces.

This commit removes the code that would adjust listening interfaces
for addresses/ports configured in *-source-v6 option.
2021-09-14 14:51:03 +02:00
Aram Sargsyan
ae9330b641 Fix an off-by-one error in catz_opt_cmp() function
This commit fixes an off-by-one error in catz_opt_cmp() function which
was resulting in ignoring the last character of the compared string.
2021-09-09 21:54:10 +00:00
Aram Sargsyan
ae53919154 Add synonym configuration options for catalog zones
This commit adds 'primaries' and 'default-primaries' catalog zones
configuration options synonyms for 'masters' and 'default-masters'
respectively.
2021-09-09 21:54:10 +00:00
Ondřej Surý
8cb2ba5dd3 Remove native PKCS#11 support
The native PKCS#11 support has been removed in favour of better
maintained, more performance and easier to use OpenSSL PKCS#11 engine
from the OpenSC project.
2021-09-09 15:35:39 +02:00
Aram Sargsyan
74f50cd29f Remove dead code
Remove dead code from the USE_DEVPOLL branch in libisc's socket.c
2021-09-08 10:12:03 +00:00
Evan Hunt
3b544d28bf map files over 2GB could not be loaded
- fixed a size comparison using "signed int" that failed if the file
  size was more than 2GB, since that was treated as a negative number.
- incidentally renamed deserialize32() to just deserialize(). we no
  longer have separate 32 and 64 bit rbtdb implementations.
2021-09-01 08:01:27 -07:00
Ondřej Surý
45726fc01f Synchronize the isc_trampoline API with changes needed in v9_16
This commit synchronizes the isc_trampoline API to match the changes
needed to fix Windows service in v9_16.
2021-09-01 10:44:21 +02:00
Artem Boldariev
c0906dd491 Re-enable some TLS-related options for non-DoH builds
This commit fixes a regression introduced at
ea80bcc41c. Some options, which are
common to both DoH and DoT were mistakenly disabled for non-DoH
builds. That is a mistake, because DoH does not imply DoT and vice
versa. Not fixing this would make DoT functionality not accessible
without DoH.
2021-09-01 10:42:05 +03:00
Evan Hunt
679f1c0dad change CFG_ZONE_MASTER and CFG_ZONE_SLAVE
these values have been renamed as CFG_ZONE_PRIMARY and
CFG_ZONE_SECONDARY.
2021-08-30 11:06:12 -07:00
Evan Hunt
916760ae46 rename dns_zone_master and dns_zone_slave
dns_zone_master and dns_zone_slave are renamed as dns_zone_primary
and dns_zone_secondary.
2021-08-30 11:06:12 -07:00
Artem Boldariev
db1ba15ff2 Replace multiple /dns-query constants with a global one
This commit replaces the constants defining /dns-query, the default
DoH endpoint, with a global definition.
2021-08-30 10:32:17 +03:00
Artem Boldariev
530133c10f Unify DoH URI making throughout the codebase
This commit adds new function isc_nm_http_makeuri() which is supposed
to unify DoH URI construction throughout the codebase.

It handles IPv6 addresses, hostnames, and IPv6 addresses given as
hostnames properly, and replaces similar ad-hoc code in the codebase.
2021-08-30 10:21:58 +03:00
Evan Hunt
556ffe3eea clean up dns_client API
- removed unused functions
- changed some public functions to static that are never called
  from outside client.c
- removed unused types and function prototypes
- renamed dns_client_destroy() to dns_client_detach()
2021-08-30 08:47:39 +02:00
Ondřej Surý
cdf9a1fd20 Remove support for external applications to register libisc
The previous versions of BIND 9 exported its internal libraries so that
they can be used by third-party applications more easily.  Certain
library functions were altered from specific BIND-only behavior to more
generic behavior when used by other applications.

This commit removes the function isc_lib_register() that was used by
external applications to enable the functionality.
2021-08-30 08:47:39 +02:00
Evan Hunt
fc6f751fbe replace per-protocol keepalive functions with a common one
this commit removes isc__nm_tcpdns_keepalive() and
isc__nm_tlsdns_keepalive(); keepalive for these protocols and
for TCP will now be set directly from isc_nmhandle_keepalive().

protocols that have an underlying TCP socket (i.e., TLS stream
and HTTP), now have protocol-specific routines, called by
isc_nmhandle_keeaplive(), to set the keepalive value on the
underlying socket.
2021-08-27 10:02:10 -07:00
Evan Hunt
7867b8b57d enable keepalive when the keepalive EDNS option is seen
previously, receiving a keepalive option had no effect on how
long named would keep the connection open; there was a place to
configure the keepalive timeout but it was never used. this commit
corrects that.

this also fixes an error in isc__nm_{tcp,tls}dns_keepalive()
in which the sense of a REQUIRE test was reversed; previously this
error had not been noticed because the functions were not being
used.
2021-08-27 09:56:51 -07:00
Evan Hunt
19e24e22f5 cleanup netmgr-int.h
- fix some duplicated and out-of-order prototypes declared in
  netmgr-int.h
- rename isc_nm_tcpdns_keepalive to isc__nm_tcpdns_keepalive as
  it's for internal use
2021-08-27 09:56:51 -07:00
Artem Boldariev
8a655320c8 Fix a crash (in dig) when closing HTTP socket with unused session
This commit fixes a crash (caused by an assert) when closing an HTTP/2
socket with unused HTTP/2 session.
2021-08-27 12:14:48 +03:00
Diego Fronza
bd0cc048d1 Replace literal 255 with a more descriptive macro name
More details on thread:
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/291#note_12186
2021-08-25 15:10:27 -07:00
Diego Fronza
90e724af45 Avoid an empty block under if condition
This commit doesn't change the logic flow from previous code, it only
makes the code more readable and consistent.

More details on thread:
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/291#note_12185
2021-08-25 15:10:27 -07:00
Diego Fronza
37f42d19a1 Remove redundant function 'newchain'
The removed function 'newchain(a, b)' was almost the same as calling
!chain_equal(a, b), varying only in the amount of data compared
in the non-fixed-length data portion of given chain nodes.

A third argument 'data_size' has been introduced into 'chain_equal'
function in order to allow it to know how many bytes to compare in the
variable-length data portion of the chain nodes.

A helper function 'chain_length(e)' has been introduced to allow
easy calculation of the total length of the non-fixed-length data part
of chain nodes.

Check the thread below for more details:
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/291#note_12184
2021-08-25 15:10:27 -07:00
Diego Fronza
6a12e37382 Use sizeof instead of arbitrary number to iterate fixed size array
More details on thread:
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/291#note_12180
2021-08-25 15:10:27 -07:00
Diego Fronza
87e970474f Initialize buffers with { 0 } instead of memset
More details on threads:
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/291#note_12178
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/291#note_12181
2021-08-25 14:23:26 -07:00
Diego Fronza
98d1e40143 Minor refactoring on function match_nsec3
The logic for matching a set of nsec3 objects against an nsec3param
object was moved to a specific function.

For more details check thread:
https://gitlab.isc.org/isc-projects/bind9/-/merge_requests/291#note_12176
2021-08-25 14:23:26 -07:00
Diego Fronza
966c06a9e6 Minor refactoring/cleanup
This commit moves the warning message to the logical block where it
belongs better.

For more details check thread comment:
https://gitlab.isc.org/isc-projects/bind9/merge_requests/291#note_12167
2021-08-25 14:23:26 -07:00
Artem Boldariev
32cd4367a3 Make no assumptions regarding HTTP headers processing order
This commit changes the DoH code in such a way that it makes no
assumptions regarding which headers are expected to be processed
first. In particular, the code expected the :method: pseudo-header to
be processed early, which might not be true.
2021-08-25 10:32:56 +03:00
Mark Andrews
eb8c1ed3c5 Check that primary tls names are syntactically valid 2021-08-25 15:21:14 +10:00