Commit Graph
34180 Commits
Author SHA1 Message Date
Mark Andrews f06c446ae8 Add test case for issue-45178
(cherry picked from commit 9039aad0f8)
2022-04-01 21:42:53 +11:00
Mark Andrews c284112bec Prevent arithmetic overflow of 'i' in master.c:generate
the value of 'i' in generate could overflow when adding 'step' to
it in the 'for' loop.  Use an unsigned int for 'i' which will give
an additional bit and prevent the overflow.  The inputs are both
less than 2^31 and and the result will be less than 2^32-1.

(cherry picked from commit 5abdee9004)
2022-04-01 21:42:53 +11:00
Tony Finch 6cb79ead4c Merge branch '3209-notauth-subdomain-v9_16' into 'v9_16'
Log "not authoritative for update zone" more clearly (v9.16)

See merge request isc-projects/bind9!6048
2022-03-30 13:24:49 +00:00
Tony Finch a5d65815bc Log "not authoritative for update zone" more clearly
Ensure the update zone name is mentioned in the NOTAUTH error message
in the server log, so that it is easier to track down problematic
update clients. There are two cases: either the update zone is
unrelated to any of the server's zones (previously no zone was
mentioned); or the update zone is a subdomain of one or more of the
server's zones (previously the name of the irrelevant parent zone was
misleadingly logged).

Closes #3209

(cherry picked from commit 84c4eb02e7)
2022-03-30 13:24:56 +01:00
Ondřej Surý 78971e9a57 Merge branch 'ondrej/cleanup-unreachable-calls-v9_16' into 'v9_16'
Consistenly use UNREACHABLE() instead of ISC_UNREACHABLE()

See merge request isc-projects/bind9!6044
2022-03-28 22:16:38 +00:00
Ondřej Surý 79b7804ce8 Consistenly use UNREACHABLE() instead of ISC_UNREACHABLE()
In couple places, we have missed INSIST(0) or ISC_UNREACHABLE()
replacement on some branches with UNREACHABLE().  Replace all
ISC_UNREACHABLE() or INSIST(0) calls with UNREACHABLE().
2022-03-28 23:28:05 +02:00
Ondřej Surý 3512e4985a Merge branch 'ondrej/dont-use-__builtin_unreachable-on-win32-v9_16' into 'v9_16'
Add win32 __builtin_unreachable() shim

See merge request isc-projects/bind9!6039
2022-03-28 21:22:23 +00:00
Ondřej Surý 4d1d91d709 Add win32 __builtin_unreachable() shim
The backport of using modern compiler features broken Windows debug
build because there's no __builtin_unreachable() in MSVC.

Define __builtin_unreachable() shim on MSVC using __assume(0).
2022-03-28 12:57:42 +02:00
Ondřej Surý 626c17af72 Merge branch '3210-dns64-errors-v9_16' into 'v9_16'
More explicit dns64 prefix errors [v9.16]

See merge request isc-projects/bind9!6031
2022-03-25 15:48:20 +00:00
Tony FinchandOndřej Surý b000f5a7c1 Add CHANGES note for [GL #3210]
(cherry picked from commit 132f30b623)
2022-03-25 16:09:34 +01:00
Tony FinchandOndřej Surý aaa923845d More explicit dns64 prefix errors
Quote the dns64 prefix in error messages that complain about
problems with it, to avoid confusion with the following ACLs.

Closes #3210

(cherry picked from commit 496c02d32a)
2022-03-25 16:09:12 +01:00
Ondřej Surý dcf562b2cf Merge branch 'ondrej/statements-following-return-break-continue-or-goto-will-never-be-executed-v9_16' into 'v9_16'
Remove UNREACHABLE() statements after exit() [v9.16]

See merge request isc-projects/bind9!6029
2022-03-25 09:20:24 +00:00
Ondřej Surý 81614b4304 Merge branch 'ondrej/use-newer-compiler-features-v9_16' into 'v9_16'
Use modern C and modern compiler features [v9.16]

See merge request isc-projects/bind9!6026
2022-03-25 09:08:58 +00:00
Ondřej Surý 888dcc6aab Remove UNREACHABLE() statements after exit()
Couple of UNREACHABLE() statements following exit() were found and
removed.

(cherry picked from commit 81fdc4a822)
2022-03-25 10:08:39 +01:00
Ondřej Surý 8b1d60933c Remove workaround for ancient clang versions (<< 3.2 and << 4.0.1)
Some ancient versions of clang reported uninitialized memory use false
positive (see https://bugs.llvm.org/show_bug.cgi?id=14461).  Since clang
4.0.1 has been long obsoleted, just remove the workarounds.

(cherry picked from commit ae508c17bc)
2022-03-25 09:37:22 +01:00
Ondřej SurýandOndřej Surý b624be2544 Remove use of the inline keyword used as suggestion to compiler
Historically, the inline keyword was a strong suggestion to the compiler
that it should inline the function marked inline.  As compilers became
better at optimising, this functionality has receded, and using inline
as a suggestion to inline a function is obsolete.  The compiler will
happily ignore it and inline something else entirely if it finds that's
a better optimisation.

Therefore, remove all the occurences of the inline keyword with static
functions inside single compilation unit and leave the decision whether
to inline a function or not entirely on the compiler

NOTE: We keep the usage the inline keyword when the purpose is to change
the linkage behaviour.

(cherry picked from commit 20f0936cf2)
2022-03-25 09:37:18 +01:00
Ondřej SurýandOndřej Surý 75f9dd8e82 Simplify way we tag unreachable code with only ISC_UNREACHABLE()
Previously, the unreachable code paths would have to be tagged with:

    INSIST(0);
    ISC_UNREACHABLE();

There was also older parts of the code that used comment annotation:

    /* NOTREACHED */

Unify the handling of unreachable code paths to just use:

    UNREACHABLE();

The UNREACHABLE() macro now asserts when reached and also uses
__builtin_unreachable(); when such builtin is available in the compiler.

(cherry picked from commit 584f0d7a7e)
2022-03-25 09:33:51 +01:00
Ondřej SurýandOndřej Surý 673e53f81d Add FALLTHROUGH macro for __attribute__((fallthrough))
Gcc 7+ and Clang 10+ have implemented __attribute__((fallthrough)) which
is explicit version of the /* FALLTHROUGH */ comment we are currently
using.

Add and apply FALLTHROUGH macro that uses the attribute if available,
but does nothing on older compilers.

In one case (lib/dns/zone.c), using the macro revealed that we were
using the /* FALLTHROUGH */ comment in wrong place, remove that comment.

(cherry picked from commit fe7ce629f4)
2022-03-25 09:30:16 +01:00
Ondřej Surý 374fe8c70e Merge branch 'ondrej-save-tsan-files-with-txt-extension-v9_16' into 'v9_16'
Save parsed tsan files with .txt extension [v9.16]

See merge request isc-projects/bind9!6021
2022-03-25 07:20:02 +00:00
Ondřej Surý f2a5ba0250 Save parsed tsan files with .txt extension
When the parse tsan files have text extension they can be viewed
directly in the GitLab web UI without downloading them locally.

(cherry picked from commit 80582073a5)
2022-03-23 20:31:50 +01:00
Ondřej Surý ae9b9ca0a1 Merge branch '3201-no-vla-v9_16' into 'v9_16'
Remove a redundant variable-length array

See merge request isc-projects/bind9!6005
2022-03-18 18:12:51 +00:00
Tony Finch afb5f59a6f Remove a redundant variable-length array
In the GSS-TSIG verification code there was an alarming
variable-length array whose size came off the network, from the
signature in the request. It turned out to be safe, because the caller
had previously checked that the signature had a reasonable size.
However, the safety checks are in the generic TSIG implementation, and
the risky VLA usage was in the GSS-specific code, and they are
separated by the DST indirection layer, so it wasn't immediately
obvious that the risky VLA was in fact safe.

In fact this risky VLA was completely unnecessary, because the GSS
signature can be verified in place without being copied to the stack,
like the message covered by the signature. The `REGION_TO_GBUFFER()`
macro backwardly assigns the region in its left argument to the GSS
buffer in its right argument; this is just a pointer and length
conversion, without copying any data. The `gss_verify_mic()` call uses
both message and signature GSS buffers in a read-only manner.
2022-03-18 17:21:57 +00:00
Ondřej Surý 865808939b Merge branch 'ondrej/remove-ATOMIC_VAR_INIT-v9_16' into 'v9_16'
Remove usage of deprecated ATOMIC_VAR_INIT() macro

See merge request isc-projects/bind9!5951
2022-03-17 21:43:13 +00:00
Ondřej Surý 2c86bd4ed9 Remove debugging implementation of stdatomic using mutexes
Upcoming LLVM/Clang 15 has marked the ATOMIC_VAR_INIT() as deprecated
breaking the build.  In the previous commit, we have removed the use of
ATOMIC_VAR_INIT(), but as that was a prerequisite to using the
--enable-mutexatomic debugging mode, we have to remove the debugging
mode.
2022-03-17 21:44:04 +01:00
Ondřej Surý 25732d818d Remove usage of deprecated ATOMIC_VAR_INIT() macro
The C17 standard deprecated ATOMIC_VAR_INIT() macro (see [1]).  Follow
the suite and remove the ATOMIC_VAR_INIT() usage in favor of simple
assignment of the value as this is what all supported stdatomic.h
implementations do anyway:

  * MacOSX.plaform: #define ATOMIC_VAR_INIT(__v) {__v}
  * Gcc stdatomic.h: #define ATOMIC_VAR_INIT(VALUE)	(VALUE)

1. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1138r0.pdf

(cherry picked from commit f251d69eba)
2022-03-17 21:44:04 +01:00
Ondřej Surý 87cd661638 Merge branch '3208-fix-xfrout-maxtimer-timer-log-message-log-level-v9_16' into 'v9_16'
Change xfer-out timer message log level to DEBUG(1)

See merge request isc-projects/bind9!5997
2022-03-17 20:41:20 +00:00
Ondřej Surý 821be88002 Change xfer-out timer message log level to DEBUG(1)
When max-transfer-*-out timeouts were reintroduced, the log message
about starting the timer was errorneously left as ISC_LOG_ERROR.
Change the log level of said message to ISC_LOG_DEBUG(1).

(cherry picked from commit 8f6e4dfa15)
2022-03-17 21:39:20 +01:00
Ondřej Surý dfb2e611de Merge branch 'ondrej/add-missing-braces-clang-format-15-v9_16' into 'v9_16'
Add couple missing braces around single-line statements [v9.16]

See merge request isc-projects/bind9!5970
2022-03-17 19:45:06 +00:00
Ondřej Surý be47b2e5e4 Add couple missing braces around single-line statements
The clang-format-15 has new option InsertBraces that could add missing
branches around single line statements.  Use that to our advantage
without switching to not-yet-released LLVM version to add missing braces
in couple of places.
2022-03-17 18:31:36 +01:00
Ondřej Surý f81b183c78 Merge branch '3200-add-per-send-timer-v9_16' into 'v9_16'
Change single write timer to per-send timers [v9.16]

See merge request isc-projects/bind9!5962
2022-03-17 16:25:04 +00:00
Ondřej Surý 96e01d40bf Add CHANGES and release note for [GL #3200]
(cherry picked from commit 8ace9e0c62)
2022-03-17 16:07:52 +01:00
Ondřej Surý 7a386256b6 On shutdown, reset the established TCP connections
Previously, the established TCP connections (both client and server)
would be gracefully closed waiting for the write timeout.

Don't wait for TCP connections to gracefully shutdown, but directly
reset them for faster shutdown.

(cherry picked from commit 6ddac2d56d)
2022-03-17 16:07:52 +01:00
Ondřej Surý d17d043499 Change single write timer to per-send timers
Previously, there was a single per-socket write timer that would get
restarted for every new write.  This turned out to be insufficient
because the other side could keep reseting the timer, and never reading
back the responses.

Change the single write timer to per-send timer which would in turn
reset the TCP connection on the first send timeout.

(cherry picked from commit a761aa59e3)
2022-03-17 16:07:52 +01:00
Michał Kępień 25382f1d2d Merge branch 'v9_16_27-release' into 'v9_16'
Merge 9.16.27 release branch

See merge request isc-projects/bind9!5991
2022-03-16 23:26:55 +00:00
Michał Kępień e82ffa9b03 Set up release notes for BIND 9.16.28 2022-03-17 00:19:11 +01:00
Tinderbox UserandMichał Kępień 0eab4dd1ae Merge branch 'prep-release' into security-v9_16 2022-03-17 00:19:11 +01:00
Michał Kępień b6c6c70e33 Merge branch 'michal/prepare-documentation-for-bind-9.16.27' into 'security-v9_16'
Prepare documentation for BIND 9.16.27

See merge request isc-private/bind9!393
2022-03-17 00:19:11 +01:00
Tinderbox UserandMichał Kępień 05e2e8c98b prep 9.16.27 2022-03-17 00:19:11 +01:00
Michał Kępień 6066c45496 Merge branch '3112-ensure-correct-ordering-in-isc__nm_process_sock_buffer-v9_16' into 'security-v9_16'
[CVE-2022-0396] [v9_16] Resolve #3112 TCP sockets stuck in CLOSE_WAIT

See merge request isc-private/bind9!376
2022-03-17 00:19:11 +01:00
Michał Kępień 3849ad19fb Prepare release notes for BIND 9.16.27 2022-03-17 00:19:11 +01:00
Michał Kępień f1bc36f193 Merge branch '2950-confidential-cache-acceptance-rules-v9_16' into 'security-v9_16'
[CVE-2021-25220] [v9_16] prevent cache poisoning from forwarder responses

See merge request isc-private/bind9!380
2022-03-17 00:19:11 +01:00
Ondřej SurýandMichał Kępień e0565c3362 Add CHANGES and release note for [GL #3112] 2022-03-17 00:19:11 +01:00
Michał Kępień 768fdcd38b Reorder release notes 2022-03-17 00:19:11 +01:00
Petr ŠpačekandMichał Kępień 6939b9f47d Add Release Note for [GL #2950] 2022-03-17 00:19:11 +01:00
Ondřej SurýandMichał Kępień afee2b5a7b Run .closehandle_cb asynchrounosly in nmhandle_detach_cb()
When sock->closehandle_cb is set, we need to run nmhandle_detach_cb()
asynchronously to ensure correct order of multiple packets processing in
the isc__nm_process_sock_buffer().  When not run asynchronously, it
would cause:

  a) out-of-order processing of the return codes from processbuffer();

  b) stack growth because the next TCP DNS message read callback will
     be called from within the current TCP DNS message read callback.

The sock->closehandle_cb is set to isc__nm_resume_processing() for TCP
sockets which calls isc__nm_process_sock_buffer().  If the read callback
(called from isc__nm_process_sock_buffer()->processbuffer()) doesn't
attach to the nmhandle (f.e. because it wants to drop the processing or
we send the response directly via uv_try_write()), the
isc__nm_resume_processing() (via .closehandle_cb) would call
isc__nm_process_sock_buffer() recursively.

The below shortened code path shows how the stack can grow:

 1: ns__client_request(handle, ...);
 2: isc_nm_tcpdns_sequential(handle);
 3: ns_query_start(client, handle);
 4:   query_lookup(qctx);
 5:     query_send(qctcx->client);
 6:       isc__nmhandle_detach(&client->reqhandle);
 7:         nmhandle_detach_cb(&handle);
 8:           sock->closehandle_cb(sock); // isc__nm_resume_processing
 9:             isc__nm_process_sock_buffer(sock);
10:               processbuffer(sock); // isc__nm_tcpdns_processbuffer
11:                 isc_nmhandle_attach(req->handle, &handle);
12:                 isc__nm_readcb(sock, req, ISC_R_SUCCESS);
13:                   isc__nm_async_readcb(NULL, ...);
14:                     uvreq->cb.recv(...); // ns__client_request

Instead, if 'sock->closehandle_cb' is set, we need to run detach the
handle asynchroniously in 'isc__nmhandle_detach', so that on line 8 in
the code flow above does not start this recursion. This ensures the
correct order when processing multiple packets in the function
'isc__nm_process_sock_buffer()' and prevents the stack growth.

When not run asynchronously, the out-of-order processing leaves the
first TCP socket open until all requests on the stream have been
processed.

If the pipelining is disabled on the TCP via `keep-response-order`
configuration option, named would keep the first socket in lingering
CLOSE_WAIT state when the client sends an incomplete packet and then
closes the connection from the client side.
2022-03-17 00:19:11 +01:00
Michał Kępień 0470bce329 Tweak and reword release notes 2022-03-17 00:19:11 +01:00
Petr ŠpačekandMichał Kępień da84b6ea4f Add CHANGES note for [GL #2950] 2022-03-17 00:19:11 +01:00
Michał Kępień b622db776c Fix typo in CHANGES 2022-03-17 00:19:11 +01:00
Mark AndrewsandMichał Kępień 71b2421054 Look for zones deeper than the current domain or forward name
When caching glue, we need to ensure that there is no closer
source of truth for the name. If the owner name for the glue
record would be answered by a locally configured zone, do not
cache.
2022-03-17 00:19:11 +01:00
Mark AndrewsandMichał Kępień ea06552a3d Check cached names for possible "forward only" clause
When caching additional and glue data *not* from a forwarder, we must
check that there is no "forward only" clause covering the owner name
that would take precedence.  Such names would normally be allowed by
baliwick rules, but a "forward only" zone introduces a new baliwick
scope.
2022-03-17 00:19:11 +01:00