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

35845 Commits

Author SHA1 Message Date
Aram Sargsyan
117dac11d1 Use autoconf check for BN_GENCB_new()
BIND unconditionally uses shims for BN_GENCB_new(), BN_GENCB_free(),
and BN_GENCB_get_arg() for all LibreSSL versions and, correctly, for
OpenSSL <1.1.0 versions.

This breaks LibreSSL compilation starting with LibreSSL 3.5.0.

Use autoconf check instead to check whether the family of the functions
are available.
2022-03-02 10:48:09 +00:00
Aram Sargsyan
ef0d7177b6 Remove EVP_CIPHER_CTX_new() and EVP_CIPHER_CTX_free() shims
LibreSSL 3.5.0 fails to compile with these shims. We could have just
removed the LibreSSL check from the pre-processor condition, but it
seems that these shims are no longer needed because all the supported
versions of OpenSSL and LibreSSL have those functions.

According to EVP_ENCRYPTINIT(3) manual page in LibreSSL,
EVP_CIPHER_CTX_new() and EVP_CIPHER_CTX_free() first appeared in
OpenSSL 0.9.8b, and have been available since OpenBSD 4.5.
2022-03-02 10:48:09 +00:00
Evan Hunt
600b6abc05 Merge branch '3174-fix-zone-documentation' into 'main'
fix zone documentation in named.conf man page

Closes #3174

See merge request isc-projects/bind9!5907
2022-03-02 09:57:04 +00:00
Evan Hunt
4ca74eee49 document zone grammar more correctly
the "zone" clause can be documented using, for instance,
`cfg_test --zonegrammar primary", which prints only
options that are valid in primary zones. this was not
the method being used when generating the named.conf
man page; instead, "zone" was documented with all possible
options, and no zone types at all.

this commit removes "zone" from the generic documentation
and adds include statements in named.conf.rst so that
correct zone grammars will be included in the man page.
2022-03-02 01:53:24 -08:00
Mark Andrews
5bcac990dd Merge branch '3175-add-missing-grow-data-call-in-isc-lex-gettoken' into 'main'
Grow the lex token buffer in one more place

Closes #3175

See merge request isc-projects/bind9!5916
2022-03-02 00:35:16 +00:00
Mark Andrews
ce8703a79e Add CHANGES note for [GL #3175] 2022-03-01 16:05:39 -08:00
Mark Andrews
d36938321e Add seed that demonstrated INSIST triggered in isc_lex_gettoken
this is similar to the input found by ClusterFuzz Issue 45027 with
the 0xff characters replaced for readability.
2022-03-01 16:05:39 -08:00
Mark Andrews
4c356d2770 Grow the lex token buffer in one more place
when parsing key pairs, if the '=' character fell at max_token
a protective INSIST preventing buffer overrun could be triggered.
Attempt to grow the buffer immediately before the INSIST.

Also removed an unnecessary INSIST on the opening double quote
of key buffer pair.
2022-03-01 16:05:39 -08:00
Mark Andrews
ed3dd45da8 Merge branch '3176-issue-45110-by-clusterfuzz-external-bind9-dns_master_load_fuzzer-undefined-shift-in-soa_get' into 'main'
Resolve "Issue 45110 by ClusterFuzz-External: bind9:dns_master_load_fuzzer: Undefined-shift in soa_get"

Closes #3176

See merge request isc-projects/bind9!5909
2022-03-02 00:02:09 +00:00
Mark Andrews
b8b99603f1 Use unsigned arithmetic when shifting by 24
By default C promotes short unsigned values to signed int which
leads to undefined behaviour when the value is shifted by too much.
Force unsigned arithmetic to be perform by explicitly casting to a
unsigned type.
2022-03-01 23:36:00 +00:00
Ondřej Surý
f6453c1bc7 Merge branch '3177-add-missing-isc_nm_tcpsocket-to-isc__nmsocket_reset' into 'main'
Handle TCP sockets in isc__nmsocket_reset()

Closes #3177

See merge request isc-projects/bind9!5910
2022-02-28 10:14:01 +00:00
Ondřej Surý
b220fb32bd Handle TCP sockets in isc__nmsocket_reset()
The isc__nmsocket_reset() was missing a case for raw TCP sockets (used
by RNDC and DoH) which would case a assertion failure when write timeout
would be triggered.

TCP sockets are now also properly handled in isc__nmsocket_reset().
2022-02-28 02:06:03 -08:00
Evan Hunt
e2636b1de0 Merge branch 'each-mem-maybedup' into 'main'
mem_maybedup() can no longer fail

See merge request isc-projects/bind9!5835
2022-02-26 10:39:37 +00:00
Mark Andrews
26f817f574 Return ISC_R_NOTIMPLEMENTED rather than ISC_R_UNEXPECTEDEND
If the keydata rdata is shorter that 16 octets it is not out private
keydata type and we have not implemented a tostruct method for it.
2022-02-25 21:06:16 -08:00
Mark Andrews
48039fa25e Do not return ISC_R_UNEXPECTEDEND
All rdata passed to dns_rdata_tostruct is supposed to be well formed,
assert if it isn't.
2022-02-25 20:57:08 -08:00
Evan Hunt
bbaade23eb mem_maybedup() can no longer fail
mem_maybedup() calls isc_mem_allocate() if an mctx is supplied,
but that can no longer fail, so now the only way mem_maybedup()
could return NULL is if it was given a NULL source address by the
caller. this commit adds a REQUIRE to prevent that scenario, and
cleans up all the calling code that previously checked for NULL
return values.

this function is mostly used in rdata tostruct() implementations, so
the documentation for dns_rdata_tostruct() has been updated to
remove 'ISC_R_NOMEMORY' as a possible return value.
2022-02-25 20:57:08 -08:00
Evan Hunt
5e4580d479 Merge branch '2802-fix-missed-occurrences-of-renaming-masters-to-primaries' into 'main'
Resolve "Fix missed occurrences of renaming masters to primaries"

Closes #2802

See merge request isc-projects/bind9!5860
2022-02-26 00:51:05 +00:00
Evan Hunt
0bde07261b remove old zone type documentation
we now document zone type as either "primary" or "secondary",
omitting the old terms (though they are still accepted).
2022-02-25 16:33:37 -08:00
Evan Hunt
0e57fc160e add a CFG_CLAUSEFLAG_NODOC flag for use with outdated terms
"masters" and "default-masters" are now flagged so they will
not be included in the named.conf man page, despite being
accepted as valid options by the parser for backward
compatibiility.
2022-02-25 16:33:30 -08:00
Mark Andrews
9422a5da44 Merge branch '3170-tiny-typo-in-doc-build-script' into 'main'
Fix typo in exclude pattern in doc build configuration

Closes #3170

See merge request isc-projects/bind9!5899
2022-02-24 13:45:37 +00:00
Mark Andrews
0069a689a6 correctly exclude logging-categories.rst 2022-02-24 13:26:38 +00:00
Petr Špaček
53e1b41660 Merge branch 'pspacek/fuzz-rdata-from-text' into 'main'
Add dns_rdata_fromtext() fuzzer

See merge request isc-projects/bind9!4718
2022-02-24 10:30:59 +00:00
Petr Špaček
dc9ba2d3ef Add dns_rdata_fromtext() fuzzer
... along with dns_rdataclass_fromtext and dns_rdatatype_fromtext

Most of the test binary is modified named-rrchecker. Main differences:
- reads single RR and exists
- does not refuse meta classes and rr types
We actually do have some fromtext code for meta-things so erroring out
in named-rrchecker would prevent us from testing this code.

Corpus has examples of all currently supported RR types. I did not do
any minimization.

In future use command

    diff -U0 \
	<(sed -n -e 's/^.*fromtext_\(.*\)(.*$/\1/p' lib/dns/code.h | \
		sort) \
	<(ls fuzz/dns_rdata_fromtext.in/)

to check for missing RR types.
2022-02-24 11:12:06 +01:00
Petr Špaček
759ad04eb8 Fix configure options in FUZZING.md 2022-02-24 11:12:02 +01:00
Petr Špaček
7cef148b5a Merge branch 'pspacek/fuzz_zonefile' into 'main'
Add dns_master_loadbuffer() fuzzer

See merge request isc-projects/bind9!4719
2022-02-24 09:12:16 +00:00
Petr Špaček
5076355822 Add dns_master_loadbuffer() fuzzer
Corpus focuses on "extra" things in master files like $GENERATE etc.
Text encoding for RRs is thoroughly tested in dns_rdata_fromtext
fuzzer.
2022-02-24 10:02:56 +01:00
Ondřej Surý
40caf57cf5 Merge branch '3166-disable-inactivehandles-caching-with-address-sanitizer-fix' into 'main'
Disable inactive uvreqs caching when compiled with sanitizers

Closes #3166

See merge request isc-projects/bind9!5898
2022-02-23 23:45:18 +00:00
Ondřej Surý
ecf042991c Fix typo __SANITIZE_ADDRESS -> __SANITIZE_ADDRESS__
When checking for Address Sanitizer to disable the inactivehandles
caching, there was a typo in the macro.
2022-02-24 00:15:16 +01:00
Ondřej Surý
be339b3c83 Disable inactive uvreqs caching when compiled with sanitizers
When isc__nm_uvreq_t gets deactivated, it could be just put onto array
stack to be reused later to save some initialization time.
Unfortunately, this might hide some use-after-free errors.

Disable the inactive uvreqs caching when compiled with Address or
Thread Sanitizer.
2022-02-24 00:15:16 +01:00
Ondřej Surý
3b2d680c5b Merge branch '3166-disable-inactivehandles-caching-with-address-sanitizer' into 'main'
Disable inactive handles caching when compiled with sanitizers

Closes #3166

See merge request isc-projects/bind9!5879
2022-02-23 22:22:53 +00:00
Ondřej Surý
92cce1da65 Disable inactive handles caching when compiled with sanitizers
When isc_nmhandle_t gets deactivated, it could be just put onto array
stack to be reused later to safe some initialization time.
Unfortunately, this might hide some use-after-free errors.

Disable the inactive handles caching when compiled with Address or
Thread Sanitizer.
2022-02-23 23:21:29 +01:00
Ondřej Surý
be5be5aa39 Merge branch '3167-remove-isc__nmsocket_t-ah_handles' into 'main'
Remove active handles tracking from isc__nmsocket_t

Closes #3147 and #3167

See merge request isc-projects/bind9!5878
2022-02-23 22:13:31 +00:00
Ondřej Surý
e2555a306f Remove active handles tracking from isc__nmsocket_t
The isc__nmsocket_t has locked array of isc_nmhandle_t that's not used
for anything.  The isc__nmhandle_get() adds the isc_nmhandle_t to the
locked array (and resized if necessary) and removed when
isc_nmhandle_put() finally destroys the handle.  That's all it does, so
it serves no useful purpose.

Remove the .ah_handles, .ah_size, and .ah_frees members of the
isc__nmsocket_t and .ah_pos member of the isc_nmhandle_t struct.
2022-02-23 22:54:47 +01:00
Ondřej Surý
3268627916 Delay isc__nm_uvreq_t deallocation to connection callback
When the TCP, TCPDNS or TLSDNS connection times out, the isc__nm_uvreq_t
would be pushed into sock->inactivereqs before the uv_tcp_connect()
callback finishes.  Because the isc__nmsocket_t keeps the list of
inactive isc__nm_uvreq_t, this would cause use-after-free only when the
sock->inactivereqs is full (which could never happen because the failure
happens in connection timeout callback) or when the sock->inactivereqs
mechanism is completely removed (f.e. when running under Address or
Thread Sanitizer).

Delay isc__nm_uvreq_t deallocation to the connection callback and only
signal the connection callback should be called by shutting down the
libuv socket from the connection timeout callback.
2022-02-23 22:54:47 +01:00
Ondřej Surý
713444e51a Merge branch 'ondrej-cleanup-nm_destroy-dequeue' into 'main'
Properly free up enqueued netievents in nm_destroy()

See merge request isc-projects/bind9!5888
2022-02-23 21:52:49 +00:00
Ondřej Surý
88418c3372 Properly free up enqueued netievents in nm_destroy()
When the isc_netmgr is being destroyed, the normal and priority queues
should be dequeued and netievents properly freed.  This wasn't the case.
2022-02-23 22:51:12 +01:00
Michał Kępień
e42d5d8875 Merge branch '3147-fix-more-ns_statscounter_recursclients-underflows' into 'main'
Fix more ns_statscounter_recursclients underflows

Closes #3147

See merge request isc-projects/bind9!5870
2022-02-23 13:42:43 +00:00
Michał Kępień
600f9010d2 Add CHANGES entry for GL #3147 2022-02-23 14:39:11 +01:00
Michał Kępień
1c462a63ec Add release note for GL #3147 2022-02-23 14:39:11 +01:00
Michał Kępień
f7482b68b9 Fix more ns_statscounter_recursclients underflows
Commit aab691d512 did not fix all possible
scenarios in which the ns_statscounter_recursclients counter underflows.
The solution implemented therein can be ineffective e.g. when CNAME
chaining happens with prefetching enabled.

Here is an example recursive resolution scenario in which the
ns_statscounter_recursclients counter can underflow with the current
logic in effect:

 1. Query processing starts, the answer is not found in the cache, so
    recursion is started.  The NS_CLIENTATTR_RECURSING attribute is set.
    ns_statscounter_recursclients is incremented (Δ = +1).

 2. Recursion completes, returning a CNAME.  client->recursionquota is
    non-NULL, so the NS_CLIENTATTR_RECURSING attribute remains set.
    ns_statscounter_recursclients is decremented (Δ = 0).

 3. Query processing restarts.

 4. The current QNAME (the target of the CNAME from step 2) is found in
    the cache, with a TTL low enough to trigger a prefetch.

 5. query_prefetch() attaches to client->recursionquota.
    ns_statscounter_recursclients is not incremented because
    query_prefetch() does not do that (Δ = 0).

 6. Query processing restarts.

 7. The current QNAME (the target of the CNAME from step 4) is not found
    in the cache, so recursion is started.  client->recursionquota is
    already attached to (since step 5) and the NS_CLIENTATTR_RECURSING
    attribute is set (since step 1), so ns_statscounter_recursclients is
    not incremented (Δ = 0).

 8. The prefetch from step 5 completes.  client->recursionquota is
    detached from in prefetch_done().  ns_statscounter_recursclients is
    not decremented because prefetch_done() does not do that (Δ = 0).

 9. Recursion for the current QNAME completes.  client->recursionquota
    is already detached from, i.e. set to NULL (since step 8), and the
    NS_CLIENTATTR_RECURSING attribute is set (since step 1), so
    ns_statscounter_recursclients is decremented (Δ = -1).

Another possible scenario is that after step 7, recursion for the target
of the CNAME from step 4 completes before the prefetch for the CNAME
itself.  fetch_callback() then notices that client->recursionquota is
non-NULL and decrements ns_statscounter_recursclients, even though
client->recursionquota was attached to by query_prefetch() and therefore
not accompanied by an incrementation of ns_statscounter_recursclients.
The net result is also an underflow.

Instead of trying to properly handle all possible orderings of events
set into motion by normal recursion and prefetch-triggered recursion,
adjust ns_statscounter_recursclients whenever the recursive clients
quota is successfully attached to or detached from.  Remove the
NS_CLIENTATTR_RECURSING attribute altogether as its only purpose is made
obsolete by this change.
2022-02-23 14:39:11 +01:00
Petr Špaček
df0bc2b3b6 Merge branch 'pspacek/windows-bat-removal' into 'main'
Remove leftover .bat file

See merge request isc-projects/bind9!5875
2022-02-22 15:05:01 +00:00
Petr Špaček
653db956f0 Remove last .bat file from the source tree
This fixes an omission in !5739, "Remove leftover test code for Windows".
2022-02-22 15:53:25 +01:00
Matthijs Mekking
2070dcf99d Merge branch '3164-fix-parental-agents-documentation' into 'main'
Fix typo in DNSSEC guide parental-agents example

Closes #3164

See merge request isc-projects/bind9!5872
2022-02-22 13:20:46 +00:00
Matthijs Mekking
fd5e39cc76 Fix typo in DNSSEC guide parental-agents example
The example will not load because of the typo, the comma should be a
semicolon.
2022-02-22 11:48:28 +01:00
Michał Kępień
39730a503d Merge branch 'michal/handle-fctx-in-FCTXTRACE-macro-stubs' into 'main'
Add "UNUSED(fctx);" to FCTXTRACE*() macro stubs

See merge request isc-projects/bind9!5867
2022-02-21 09:53:26 +00:00
Michał Kępień
b645e28167 Add "UNUSED(fctx);" to FCTXTRACE*() macro stubs
Commit b6d40b3c4e removed most uses of the
'fctx' variable from the rctx_dispfail() function: it is now only needed
by the FCTXTRACE3() macro.  However, when --enable-querytrace is not in
effect, that macro evaluates to a list of UNUSED() macros that does not
include "UNUSED(fctx);".  This triggers the following compilation
warning when building without --enable-querytrace:

    resolver.c: In function 'rctx_dispfail':
    resolver.c:7888:21: warning: unused variable 'fctx' [-Wunused-variable]
     7888 |         fetchctx_t *fctx = rctx->fctx;
          |                     ^~~~

Fix by adding "UNUSED(fctx);" lines to all FCTXTRACE*() macros.  This is
safe to do because all of those macros use the 'fctx' local variable, so
there is no danger of introducing new errors caused by use of undeclared
identifiers.
2022-02-21 10:50:38 +01:00
Ondřej Surý
d0c2113693 Merge branch '3140-make-keep-response-order-obsolete' into 'main'
Declare the keep-response-order obsolete

Closes #3140

See merge request isc-projects/bind9!5852
2022-02-18 21:37:39 +00:00
Ondřej Surý
f216eb0d64 Add CHANGES and release note for [GL #3140] 2022-02-18 09:16:03 +01:00
Ondřej Surý
ddd5b0ff89 Downgrade -Wstringop-overread from error to warning
Due to a bug in gcc-11, the build fails when AddressSanitizer is
enabled.  Downgrading the -Wstringop-overread to just a warning in the
gcc:asan build allows the code to compile.
2022-02-18 09:16:03 +01:00
Ondřej Surý
30fda4cb52 Remove the keep-response-order system test
Remove the keep-response-order from the system test and cleanup the
pipelined system test to be shell check clean and use the helper
functions.
2022-02-18 09:16:03 +01:00