Commit Graph

35728 Commits

Author SHA1 Message Date
Tony Finch
ec54de9e47 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:19:46 +01:00
Ondřej Surý
d45abcbd2f Merge branch 'ondrej/cleanup-unreachable-calls-v9_18' into 'v9_18'
Consistenly use UNREACHABLE() instead of ISC_UNREACHABLE()

See merge request isc-projects/bind9!6043
2022-03-28 21:56:42 +00:00
Ondřej Surý
fc500b96eb 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:27:33 +02:00
Arаm Sаrgsyаn
8799add75e Merge branch '3221-catz-lightweight-cleanup-v9_18' into 'v9_18'
[v9_18] [1/5] Catalog zones lightweight cleanup

See merge request isc-projects/bind9!6038
2022-03-28 11:30:48 +00:00
Aram Sargsyan
8d3141ac10 Add CHANGES note for [GL #3221]
(cherry picked from commit 7fd24ded90)
2022-03-28 10:28:32 +00:00
Aram Sargsyan
a20acee77d Use 'bname' in dns_catz_update_from_db() only when it is ready
There is a possible code path of using the uninitialized `bname`
character array while logging an error message.

Initialize the `bname` buffer earlier in the function.

Also, change the initialization routine to use a helper function.

(cherry picked from commit a5a6362e92)
2022-03-28 10:26:58 +00:00
Aram Sargsyan
68bbce9813 Put some missing dns_rdata_freestruct() calls in catz.c
A successful call to `dns_rdata_tostruct()` expects an accompanying
call to `dns_rdata_freestruct()` to free up any memory that could have
been allocated during the first call.

In catz.c there are several places where `dns_rdata_freestruct()` call
is skipped.

Add the missing cleanup routines.

(cherry picked from commit f57c51fe05)
2022-03-28 10:26:49 +00:00
Aram Sargsyan
263b9d69af Cleanup the code to remove unnecessary indentation
Because of the "goto" in the "if" body the "else" part is unnecessary
and adds another level of indentation.

Cleanup the code to not have the "else" part.

(cherry picked from commit 9b84bfb5f4)
2022-03-28 10:26:42 +00:00
Aram Sargsyan
c79c059c4e Log a warning when catz is told to modify a zone not added by catz
Catz logs a warning message when it is told to modify a zone which was
not added by the current catalog zone.

When logging a warning, distinguish the two cases when the zone
was not added by a catalog zone at all, and when the zone was
added by a different catalog zone.

(cherry picked from commit d29e5f197b)
2022-03-28 10:26:35 +00:00
Aram Sargsyan
3c3653ad2a Fix invalid function name in the error log
The current function's name in one of the error logs in
catz_addmodzone_taskaction() function is invalid.

Fix the name.

(cherry picked from commit e861224cf4)
2022-03-28 10:26:26 +00:00
Ondřej Surý
78d6a20c88 Merge branch '3210-dns64-errors-v9_18' into 'v9_18'
More explicit dns64 prefix errors [v9.18]

See merge request isc-projects/bind9!6030
2022-03-25 20:21:32 +00:00
Tony Finch
fef36e6b6f Add CHANGES note for [GL #3210]
(cherry picked from commit 132f30b623)
2022-03-25 16:08:43 +01:00
Tony Finch
775281d14a 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:08:22 +01:00
Ondřej Surý
310169af9d Merge branch 'ondrej/statements-following-return-break-continue-or-goto-will-never-be-executed-v9_18' into 'v9_18'
Remove UNREACHABLE() statements after exit() [v9.18]

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

(cherry picked from commit 81fdc4a822)
2022-03-25 10:07:25 +01:00
Ondřej Surý
010583541a Merge branch 'ondrej/use-newer-compiler-features-v9_18' into 'v9_18'
Use modern C and modern compiler features [v9.18]

See merge request isc-projects/bind9!6025
2022-03-25 08:41:06 +00:00
Ondřej Surý
cd13d24ba2 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 08:42:19 +01:00
Ondřej Surý
5e19bbb48a 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 08:42:18 +01:00
Ondřej Surý
07022525ff Replace ISC_NORETURN with C11's noreturn
C11 has builtin support for _Noreturn function specifier with
convenience noreturn macro defined in <stdnoreturn.h> header.

Replace ISC_NORETURN macro by C11 noreturn with fallback to
__attribute__((noreturn)) if the C11 support is not complete.

(cherry picked from commit 04d0b70ba2)
2022-03-25 08:42:18 +01:00
Ondřej Surý
128c550a95 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 08:42:16 +01:00
Ondřej Surý
c62a94363d 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 08:41:09 +01:00
Ondřej Surý
3a4f6ae775 Merge branch 'ondrej-save-tsan-files-with-txt-extension-v9_18' into 'v9_18'
Save parsed tsan files with .txt extension [v9.18]

See merge request isc-projects/bind9!6020
2022-03-23 19:32:12 +00:00
Ondřej Surý
5f56fac2b9 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:30:52 +01:00
Matthijs Mekking
554d63fb51 Merge branch 'matthijs-engine_pkcs11-save-error-output-v9_18' into 'v9_18'
[v9_18] Save keyfromlabel error output

See merge request isc-projects/bind9!6008
2022-03-21 10:28:57 +00:00
Matthijs Mekking
61fcbdfd7c Save keyfromlabel error output
Save the error output from pkcs11-tool and dnssec-keyfromlabel in the
engine_pkcs11 system test.

(cherry picked from commit d6d107d804)
2022-03-21 10:36:09 +01:00
Tony Finch
54e37e89ce Merge branch '3201-no-vla-v9_18' into 'v9_18'
Avoid using C99 variable-length arrays

See merge request isc-projects/bind9!6003
2022-03-18 16:42:57 +00:00
Tony Finch
03e0083e3b Avoid using C99 variable length arrays
From an attacker's point of view, a VLA declaration is essentially a
primitive for performing arbitrary arithmetic on the stack pointer. If
the attacker can control the size of a VLA they have a very powerful
tool for causing memory corruption.

To mitigate this kind of attack, and the more general class of stack
clash vulnerabilities, C compilers insert extra code when allocating a
VLA to probe the growing stack one page at a time. If these probes hit
the stack guard page, the program will crash.

From the point of view of a C programmer, there are a few things to
consider about VLAs:

  * If it is important to handle allocation failures in a controlled
    manner, don't use VLAs. You can use VLAs if it is OK for
    unreasonable inputs to cause an uncontrolled crash.

  * If the VLA is known to be smaller than some known fixed size,
    use a fixed size array and a run-time check to ensure it is large
    enough. This will be more efficient than the compiler's stack
    probes that need to cope with arbitrary-size VLAs.

  * If the VLA might be large, allocate it on the heap. The heap
    allocator can allocate multiple pages in one shot, whereas the
    stack clash probes work one page at a time.

Most of the existing uses of VLAs in BIND are in test code where they
are benign, but there was one instance in `named`, in the GSS-TSIG
verification code, which has now been removed.

This commit adjusts the style guide and the C compiler flags to allow
VLAs in test code but not elsewhere.

(cherry picked from commit 599c1d2a6b)
2022-03-18 16:05:56 +00:00
Tony Finch
ac5d61541d 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.

(cherry picked from commit eeead1cfe7)
2022-03-18 16:05:56 +00:00
Arаm Sаrgsyаn
312bdb9e5c Merge branch '3205-dig-tcp-next-server-on-connection-error-crash-v9_18' into 'v9_18'
[v9_18] Fix dig error when trying the next server after a TCP connection failure

See merge request isc-projects/bind9!6001
2022-03-18 11:19:33 +00:00
Aram Sargsyan
964abb938f Add CHANGES note for [GL #3205]
(cherry picked from commit ced79790b3)
2022-03-18 10:31:17 +00:00
Aram Sargsyan
3c2816a5be Add various dig/host tests for TCP/UDP socket error handling cases
Rework the "ans8" server in the "digdelv" system test to support various
modes of operations using a control channel.

The supported modes are:

1. `silent` (do not respond)
2. `close` (UDP: same as `silent`; TCP: also close the connection)
3. `servfail` (always respond with `SERVFAIL`)
4. `unstable` (constantly switch between `silent` and `servfail`)

Add multiple tests to check the handling of both TCP and UDP socket
error scenarios in dig/host.

(cherry picked from commit 03697f1bcc)
2022-03-18 10:31:10 +00:00
Aram Sargsyan
19787fb752 Fix dig error when trying the next server after a TCP connection failure
When encountering a TCP connection error while trying to initiate a
connection to a server, dig erroneously cancels the lookup even when
there are other server(s) to try, which results in an assertion failure.

Cancel the lookup only when there are no more queries left in the
lookup's queries list (i.e. `next` is NULL).

(cherry picked from commit 0fb4fc1897)
2022-03-18 10:31:03 +00:00
Arаm Sаrgsyаn
893b6f2404 Merge branch '3128-dig-does-not-recover-from-a-isc_nm_udpconnect-failure-v9_18' into 'v9_18'
[v9_18] After dig request errors, try to use other servers when they exist

See merge request isc-projects/bind9!6000
2022-03-18 10:25:31 +00:00
Aram Sargsyan
956f022a2b Add CHANGES entry for [GL #3128]
(cherry picked from commit b3a058e7bb)
2022-03-18 09:21:07 +00:00
Aram Sargsyan
df7616ec09 Add digdelv system test to check that dig tries other servers on error
Add a test to check whether dig tries the next query/server after
a connection error.

Add a test to check whether dig tries the next query/server after
a one or more (default is 3) connection/request timeouts.

(cherry picked from commit e8a64d0cbe)
2022-03-18 09:20:57 +00:00
Aram Sargsyan
992997967b After dig request errors, try to use other servers when they exist
When timing-out or having other types of socket errors during a query,
dig isn't trying to perform the lookup using other servers which exist
in the lookup's queries list.

After configured amount of timeout retries, or after a socket error,
check if there are other queries/servers in the lookup's queries list,
and start the next one if it exists, instead of unconditionally failing.

(cherry picked from commit bc203d6082)
2022-03-18 09:20:50 +00:00
Arаm Sаrgsyаn
da7e4da2de Merge branch '3020-dighost-servfail-bug-v9_18' into 'v9_18'
[v9_18] When resending a UDP request, insert the query to the lookup's list

See merge request isc-projects/bind9!5998
2022-03-18 09:03:32 +00:00
Aram Sargsyan
f64cd23e7b Add digdelv system test to check timed-out result followed by a SERVFAIL
This test ensures that `dig` retries with another attempt after a
timed-out request, and that it does not crash when the retried
request returns a SERVFAIL result. See [GL #3020] for the latter
issue.

(cherry picked from commit 3ec5d2d6ed)
2022-03-18 08:29:13 +00:00
Aram Sargsyan
1e17d5a130 Add CHANGES note for [GL #3020]
(cherry picked from commit e353700189)
2022-03-18 08:28:42 +00:00
Aram Sargsyan
58685cd573 When resending a UDP request, insert the query to the lookup's list
When a query times out, and `dig` (or `host`) creates a new query
to resend the request, it is being prepended to the lookup's queries
list, which can cause a confusion later, making `dig` (or `host`)
believe that there is another new query in the list, but that is
actually the old one, which was timed out. That mistake will result
in an assertion failure.

That can happen, in particular, when after a timed out request,
the retried request returns a SERVFAIL result, and the recursion
is enabled, and `+nofail` option was used with `dig` (that is the
default behavior in `host`, unless the `-s` option is provided).

Fix the problem by inserting the query just after the current,
timed-out query, instead of prepending to the list.

Before calling start_udp() detach `l->current_query`, like it is
done in another place in the function.

Slightly update a couple of debug messages to make them more
consistent.

(cherry picked from commit a962475948)
2022-03-18 08:27:07 +00:00
Aram Sargsyan
b6bd2a5311 Fix an issue in dig when retrying with the next server after SERVFAIL
After a query results in a SERVFAIL result, and there is another
registered query in the lookup's queries list, `dig` starts the next
query to try another server, but for some reason, reports about that
also when the current query is in the head of the list, even if there
is no other query in the list to try.

Use the same condition for both decisions, and after starting the next
query, jump to the "detach_query" label instead of "next_lookup",
because there is no need to start the next lookup after we just started
a query in the current lookup.

(cherry picked from commit e888c62fbd)
2022-03-18 08:27:00 +00:00
Ondřej Surý
3d27a75eca Merge branch '3208-fix-xfrout-maxtimer-timer-log-message-log-level-v9_18' into 'v9_18'
Change xfer-out timer message log level to DEBUG(1)

See merge request isc-projects/bind9!5996
2022-03-17 20:40:26 +00:00
Ondřej Surý
5e253fd629 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:38:24 +01:00
Ondřej Surý
c965b315c5 Merge branch 'ondrej/add-missing-braces-clang-format-15-v9_18' into 'v9_18'
Add couple missing braces around single-line statements [v9.18]

See merge request isc-projects/bind9!5969
2022-03-17 19:42:49 +00:00
Ondřej Surý
485a2b329e 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:29:57 +01:00
Michał Kępień
d5cf60ab3d Merge branch 'v9_18_1-release' into 'v9_18'
Merge 9.18.1 release branch

See merge request isc-projects/bind9!5990
2022-03-16 22:36:26 +00:00
Michał Kępień
cc59e6fd3f Set up release notes for BIND 9.18.2 2022-03-16 23:18:18 +01:00
Michał Kępień
bd24843fa7 Update BIND version to 9.18.1 2022-03-16 23:18:18 +01:00
Michał Kępień
d76bab0c8c Add a CHANGES marker 2022-03-16 23:18:18 +01:00
Michał Kępień
6b5f682ff1 Merge branch 'michal/prepare-documentation-for-bind-9.18.1' into 'security-v9_18'
Prepare documentation for BIND 9.18.1

See merge request isc-private/bind9!392
2022-03-16 23:18:18 +01:00