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

32848 Commits

Author SHA1 Message Date
Witold Kręcicki
f68fe9ff14 Fix a startup/shutdown crash in ns_clientmgr_create 2020-11-10 14:17:05 +01:00
Witold Kręcicki
3c00fb71db isc_nm_tls_create_server_ctx can create ephemeral certs
In-memory ephemeral certs creation for easy DoT/DoH deployment.
2020-11-10 14:17:04 +01:00
Witold Kręcicki
38b78f59a0 Add DoT support to bind
Parse the configuration of tls objects into SSL_CTX* objects.  Listen on
DoT if 'tls' option is setup in listen-on directive.  Use DoT/DoH ports
for DoT/DoH.
2020-11-10 14:16:55 +01:00
Evan Hunt
8ed005f924 add parser support for TLS configuration options
This commit adds stub parser support and tests for:
- "tls" statement, specifying key and cert.
- an optional "tls" keyvalue in listen-on statements for DoT
  configuration.

Documentation for these options has also been added to the ARM, but
needs further work.
2020-11-10 14:16:49 +01:00
Evan Hunt
8886569e9d report peer address in TLS mode, and specify protocol
- peer address was not being reported correctly by "dig +tls"
- the protocol used is now reported in the dig output: UDP, TCP, or TLS.
2020-11-10 14:16:41 +01:00
Witold Kręcicki
03b2c948b6 add "dig +tls"
- add "+[no]tls" option to dig to enable TLS mode
- override the default port number in dig from 53 to 853 when using TLS
2020-11-10 14:16:35 +01:00
Witold Kręcicki
b2ee0e9dc3 netmgr: server-side TLS support
Add server-side TLS support to netmgr - that includes moving some of the
isc_nm_ functions from tcp.c to a wrapper in netmgr.c calling a proper
tcp or tls function, and a new isc_nm_listentls() function.

Add DoT support to tcpdns - isc_nm_listentlsdns().
2020-11-10 14:16:27 +01:00
Mark Andrews
fb8f1e49ab Merge branch '2252-ns_client_sendraw-is-missing-dnstap-support' into 'main'
Resolve "ns_client_sendraw() is missing DNSTAP support."

Closes #2252

See merge request isc-projects/bind9!4368
2020-11-10 06:41:08 +00:00
Mark Andrews
157e3a98f2 Add CHANGES not for [GL #2252] 2020-11-10 06:15:46 +00:00
Mark Andrews
2b7128fede Check that DNSTAP captures forwarded UPDATE responses 2020-11-10 06:15:46 +00:00
Mark Andrews
b09727a765 Implement DNSTAP support in ns_client_sendraw()
ns_client_sendraw() is currently only used to relay UPDATE
responses back to the client.  dns_dt_send() is called with
this assumption.
2020-11-10 06:15:46 +00:00
Mark Andrews
a66b638d41 Merge branch '2259-zone_namerd_tostr-called-w-o-lock-being-held' into 'main'
Resolve "zone_namerd_tostr called w/o lock being held"

Closes #2259

See merge request isc-projects/bind9!4376
2020-11-10 06:14:21 +00:00
Mark Andrews
84f43903da Lock zone before calling zone_namerd_tostr()
WARNING: ThreadSanitizer: data race
    Read of size 8 at 0x000000000001 by thread T1:
    #0 inline_raw lib/dns/zone.c:1375
    #1 zone_namerd_tostr lib/dns/zone.c:15316
    #2 dns_zone_name lib/dns/zone.c:15391
    #3 xfrin_log lib/dns/xfrin.c:1605
    #4 xfrin_destroy lib/dns/xfrin.c:1477
    #5 dns_xfrin_detach lib/dns/xfrin.c:739
    #6 xfrin_connect_done lib/dns/xfrin.c:970
    #7 tcpdnsconnect_cb netmgr/tcpdns.c:786
    #8 tcp_connect_cb netmgr/tcp.c:292
    #9 <null> <null>
    #10 <null> <null>

    Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M1):
    #0 zone_shutdown lib/dns/zone.c:14462
    #1 dispatch lib/isc/task.c:1152
    #2 run lib/isc/task.c:1344
    #3 <null> <null>

    Location is heap block of size 2769 at 0x000000000013 allocated by thread T3:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713
    #2 mem_get lib/isc/mem.c:622
    #3 mem_allocateunlocked lib/isc/mem.c:1268
    #4 isc___mem_allocate lib/isc/mem.c:1288
    #5 isc__mem_allocate lib/isc/mem.c:2453
    #6 isc___mem_get lib/isc/mem.c:1037
    #7 isc__mem_get lib/isc/mem.c:2432
    #8 dns_zone_create lib/dns/zone.c:984
    #9 configure_zone bin/named/server.c:6502
    #10 do_addzone bin/named/server.c:13391
    #11 named_server_changezone bin/named/server.c:13788
    #12 named_control_docommand bin/named/control.c:207
    #13 control_command bin/named/controlconf.c:392
    #14 dispatch lib/isc/task.c:1152
    #15 run lib/isc/task.c:1344
    #16 <null> <null>
2020-11-10 15:56:13 +11:00
Mark Andrews
bd3cc31f2b Merge branch '2230-legacy-system-test-fails-intermittently' into 'main'
Resolve "legacy system test fails intermittently"

Closes #2207

See merge request isc-projects/bind9!4295
2020-11-09 22:18:29 +00:00
Mark Andrews
06db7a153f Retry edns512 multiple times to trigger fallback to edns at 512
We want named to have slow resolving (multiple retries) when
there is a very small working MTU
2020-11-09 21:45:44 +00:00
Mark Andrews
b5145f46dc Fixup legacy test to account for not falling back to EDNS 512 lookups.
The SOA lookup for edns512 could succeed if the negative response
for ns.edns512/AAAA completed before all the edns512/SOA query
attempts are made.  The ns.edns512/AAAA lookup returns tc=1 and
the SOA record is cached after processing the NODATA response.
Lookup a TXT record at edns512 and look it up instead of the
SOA record.

Removed 'checking that TCP failures do not influence EDNS statistics
in the ADB' as it is no longer appropriate.
2020-11-09 21:45:44 +00:00
Evan Hunt
45f1df5412 Merge branch '2258-xfrin-shutdown-race' into 'main'
address some possible shutdown races in xfrin

Closes #2258

See merge request isc-projects/bind9!4374
2020-11-09 21:45:14 +00:00
Evan Hunt
e011521ef1 address some possible shutdown races in xfrin
there were two failures during observed in testing, both occurring
when 'rndc halt' was run rather than 'rndc stop' - the latter dumps
zone contents to disk and presumably introduced enough delay to
prevent the races:

- a failure when the zone was shut down and called dns_xfrin_detach()
  before the xfrin had finished connecting; the connect timeout
  terminated without detaching its handle
- a failure when the tcpdns socket timer fired after the outerhandle
  had already been cleared.

this commit incidentally addresses a failure observed in mutexatomic
due to a variable having been initialized incorrectly.
2020-11-09 12:33:37 -08:00
Ondřej Surý
ce58a149ce Merge branch '1840-netmgr-tls-layer-link-with-libssl' into 'main'
Add support to link with libssl

See merge request isc-projects/bind9!4373
2020-11-09 15:38:22 +00:00
Ondřej Surý
127ba7e930 Add libssl libraries to Windows build
This commit extends the perl Configure script to also check for libssl
in addition to libcrypto and change the vcxproj source files to link
with both libcrypto and libssl.
2020-11-09 16:00:28 +01:00
Witold Kręcicki
9a2065e2f4 autoconf: link with libssl
This is prerequisite to adding DoT and DoH support to BIND 9.
2020-11-09 15:59:01 +01:00
Ondřej Surý
c62f3af395 Merge branch '2016-xfrin-netmgr' into 'main'
use netmgr for xfrin

Closes #2016

See merge request isc-projects/bind9!4246
2020-11-09 14:45:17 +00:00
Evan Hunt
42d94614e4 CHANGES and release notes 2020-11-09 14:50:48 +01:00
Ondřej Surý
934d6c6f92 Refactor the xfrin reference counting
Previously, the xfrin object relied on four different reference counters
(`refs`, `connects`, `sends`, `recvs`) and destroyed the xfrin object
only if all of them were zero.  This commit reduces the reference
counting only to the `references` (renamed from `refs`) counter.  We
keep the existing `connects`, `sends` and `recvs` as safe guards, but
they are not formally needed.
2020-11-09 14:50:48 +01:00
Evan Hunt
1170a52f48 remove isc_task from xfrin
since the network manager is now handling timeouts, xfrin doesn't
need an isc_task object.

it may be necessary to revert this later if we find that it's
important for zone_xfrdone() to be executed in the zone task context.
currently things seem to be working well without that, though.
2020-11-09 13:45:43 +01:00
Evan Hunt
a8d28881d1 remove isc_timer from xfrin
the network manager can now handle timeouts, so it isn't
necessary for xfrin to use isc_timer for the purpose any
longer.
2020-11-09 13:45:43 +01:00
Evan Hunt
49d53a4aa9 use netmgr for xfrin
Use isc_nm_tcpdnsconnect() in xfrin.c for zone transfers.
2020-11-09 13:45:43 +01:00
Michal Nowak
917e365159 Merge branch 'mnowak/test-with-DDEBUG' into 'main'
Enable debug build on Tumbleweed in CI

See merge request isc-projects/bind9!4367
2020-11-09 12:36:24 +00:00
Michal Nowak
59a09b5db8 Enable debug build on Tumbleweed in CI 2020-11-09 13:34:51 +01:00
Evan Hunt
f6d967db54 Merge branch '2140-dig-netmgr' into 'main'
Resolve "convert dig and friends to use the netmgr"

Closes #2140

See merge request isc-projects/bind9!4115
2020-11-08 22:06:04 +00:00
Evan Hunt
3ff0ee568d CHANGES and release note 2020-11-08 13:36:12 -08:00
Ondřej Surý
8af7f81d6c netmgr: Don't crash if socket() returns an error in udpconnect
socket() call can return an error - e.g. EMFILE, so we need to handle
this nicely and not crash.

Additionally wrap the socket() call inside a platform independent helper
function as the Socket data type on Windows is unsigned integer:

> This means, for example, that checking for errors when the socket and
> accept functions return should not be done by comparing the return
> value with –1, or seeing if the value is negative (both common and
> legal approaches in UNIX). Instead, an application should use the
> manifest constant INVALID_SOCKET as defined in the Winsock2.h header
> file.
2020-11-08 13:36:12 -08:00
Ondřej Surý
b558eca633 dig: Refactor recv_done, so there's less exit paths
The recv_done() callback had many exit paths with different conditions,
and every path had it's own set of destructors.  The refactored code now
has unified exit path with descriptive goto labels matching the intent:

 - cancel_lookup
 - next_lookup
 - detach_query
 - keep_query

The only exception to the rule is check_for_more_data() path, where the
part of the query gets reused, so the query->readhandle and query gets
detached on it's own, and by going to the keep_query, we are just
skipping calling the destructors again.
2020-11-08 13:36:12 -08:00
Ondřej Surý
050258bda4 netmgr: Always load the result from async socket
Because we use result earlier for setting the loadbalancing on the
socket, we could be left with a ISC_R_NOTIMPLEMENTED value stored in the
variable and when the UDP connection would succeed, we would
errorneously return this value instead of ISC_R_SUCCESS.
2020-11-07 21:12:08 +01:00
Evan Hunt
88f5f3915b dig: prevent query from being detached if udpconnect fails on first attempt
FreeBSD sometimes returns spurious errors in UDP connect() attempts,
so we try a few times before giving up. However, each failed attempt
triggers a call to udp_ready() in dighost.c, and that was causing
the query object to be detached prematurely.
2020-11-07 21:11:58 +01:00
Ondřej Surý
6d63ffe46d dig: add reference counter to the dig_lookup_t object
Sometimes, the dig_lookup_t could be destroyed before the final
send_done() callback was be called, leading to dereferencing an
already freed dig_lookup_t object.  By making the dig_lookup_t
reference counted, we are ensuring that it won't be freed until
the last reference (from dig_query_t .lookup) is released.
2020-11-07 21:11:42 +01:00
Ondřej Surý
ecd70eb4b5 dig: add new debugging output
track creation, attachment and detachment of dig_query objects.
2020-11-07 20:49:53 +01:00
Ondřej Surý
a2bc627c30 dig: add reference counting to dig_query_t
add a reference counter to the dig_query object to ensure
it isn't freed until the last caller releases it.
2020-11-07 20:49:53 +01:00
Evan Hunt
5307bf64ce reduce timing dependencies in system tests
one of the tests in the resolver system test depends on dig
getting no response to its first two query attempts, and SERVFAIL
on the third after resolution times out.

using a 5-second retry timer in dig means the SERVFAIL response
could occur while dig is discarding the second query and preparing
to send the third. in this case the server's response could be
missed.  shortening the retry interval to 4 seconds ensures that
dig has already sent the third query when the SERVFAIL response
arrives.

also, the serve-stale system test could fail due to a race in which
it timed out after waiting ten seconds for a file to be written, and
the dig timeout was just a bit longer. this is addressed by extending
the dig timeout to 11 seconds for this test.
2020-11-07 20:49:53 +01:00
Evan Hunt
ea2b04c361 dig: use new netmgr timeout mechanism
use isc_nmhandle_settimeout() to set read/recv timeouts, and get rid
of connect_timeout() and related functions in dighost.c.
2020-11-07 20:49:53 +01:00
Evan Hunt
4be63c5b00 add isc_nmhandle_settimeout() function
this function sets the read timeout for the socket associated
with a netmgr handle and, if the timer is running, resets it.
for TCPDNS sockets it also sets the read timeout and resets the
timer on the outer TCP socket.
2020-11-07 20:49:53 +01:00
Evan Hunt
e12dc1faa2 dig: setup IDN whenever printing a message
because dig now uses the netmgr, printing of response messages
happens in a different thread than setup. the IDN output filtering
procedure, which set using dns_name_settotextfilter(), is stored as
thread-local data, and so if it's set during setup, it won't be
accessible when printing. we now set it immediately before printing,
in the same thread, and clear it immedately afterward.
2020-11-07 20:49:53 +01:00
Evan Hunt
cde27d2d2b dig: remove "+unexpected" option
The network manager does not support returning UDP datagrams to
clients from unexpected sources; it is therefore not possible for
dig to accept them.  The "+[no]unexpected" option has therefore
been removed from the dig command and its documentation.
2020-11-07 20:49:53 +01:00
Evan Hunt
94b7988efb convert dig/host/nslookup to use the netmgr
use netmgr functions instead of isc_socket for dig, host, and
nslookup. note that `dig +unexpected` is not working.
2020-11-07 20:49:53 +01:00
Ondřej Surý
2191d2bf44 fix nmhandle attach/detach errors in tcpdnsconnect_cb()
we need to attach to the statichandle when connecting TCPDNS sockets,
same as with UDP.
2020-11-07 20:49:53 +01:00
Artem Boldariev
d48e040035 Merge branch 'artem/fix-build-with-DEBUG-defined' into 'main'
Fix build with DEBUG defined (-DDEBUG)

See merge request isc-projects/bind9!4351
2020-11-06 10:40:33 +00:00
Artem Boldariev
a236151608 Fix build with DEBUG defined (-DDEBUG)
The problem was introduced by commit 98b55eb4.
2020-11-06 12:20:41 +02:00
Mark Andrews
9a5aa8cf3a Merge branch '2239-fctx-id-is-uninitialized-and-effectively-unused' into 'main'
Resolve "fctx:id is uninitialized and effectively unused"

Closes #2239

See merge request isc-projects/bind9!4346
2020-11-06 02:26:11 +00:00
Mark Andrews
ed783a8139 remove fctx:id field 2020-11-06 01:54:44 +00:00
Michal Nowak
d7308c86a6 Merge branch '1728-drop-big-key' into 'main'
Drop bigkey

Closes #1728

See merge request isc-projects/bind9!4350
2020-11-05 16:25:32 +00:00