Commit Graph

35751 Commits

Author SHA1 Message Date
Ondřej Surý
64265f1c0e Add option to configure load balance sockets
Previously, the option to enable kernel load balancing of the sockets
was always enabled when supported by the operating system (SO_REUSEPORT
on Linux and SO_REUSEPORT_LB on FreeBSD).

It was reported that in scenarios where the networking threads are also
responsible for processing long-running tasks (like RPZ processing, CATZ
processing or large zone transfers), this could lead to intermitten
brownouts for some clients, because the thread assigned by the operating
system might be busy.  In such scenarious, the overall performance would
be better served by threads competing over the sockets because the idle
threads can pick up the incoming traffic.

Add new configuration option (`load-balance-sockets`) to allow enabling
or disabling the load balancing of the sockets.

(cherry picked from commit 85c6e797aa)
2022-04-04 23:59:59 +02:00
Ondřej Surý
eef9459d87 Merge branch '3190-offload-rpz-updates-v9_18' into 'v9_18'
General cleanup of dns_rpz implementation [v9.18]

See merge request isc-projects/bind9!6072
2022-04-04 22:00:27 +00:00
Ondřej Surý
f3ae14d8c3 Add CHANGES and release note for [GL #3190]
(cherry picked from commit 23a4559b34)
2022-04-04 22:59:59 +02:00
Ondřej Surý
e128b6a951 Run the RPZ update as offloaded work
Previously, the RPZ updates ran quantized on the main nm_worker loops.
As the quantum was set to 1024, this might lead to service
interruptions when large RPZ update was processed.

Change the RPZ update process to run as the offloaded work.  The update
and cleanup loops were refactored to do as little locking of the
maintenance lock as possible for the shortest periods of time and the db
iterator is being paused for every iteration, so we don't hold the rbtdb
tree lock for prolonged periods of time.

(cherry picked from commit f106d0ed2b)
2022-04-04 22:59:59 +02:00
Ondřej Surý
f4cba0784e Refactor the dns_rpz_add/delete to use local rpz copy
Previously dns_rpz_add() were passed dns_rpz_zones_t and index to .zones
array.  Because we actually attach to dns_rpz_zone_t, we should be using
the local pointer instead of passing the index and "finding" the
dns_rpz_zone_t again.

Additionally, dns_rpz_add() and dns_rpz_delete() were used only inside
rpz.c, so make them static.

(cherry picked from commit b6e885c97f)
2022-04-04 22:59:59 +02:00
Ondřej Surý
bfee462403 General cleanup of dns_rpz implementation
Do a general cleanup of lib/dns/rpz.c style:

 * Removed deprecated and unused functions
 * Unified dns_rpz_zone_t naming to rpz
 * Unified dns_rpz_zones_t naming to rpzs
 * Add and use rpz_attach() and rpz_attach_rpzs() functions
 * Shuffled variables to be more local (cppcheck cleanup)

(cherry picked from commit 840179a247)
2022-04-04 22:59:59 +02:00
Tony Finch
cc1988187c Merge branch 'fanf/macos-ifconfig-v9_18' into 'v9_18'
MacOS needs more IP addresses to run the system tests (backport to 9.18)

See merge request isc-projects/bind9!6069
2022-04-04 14:24:30 +00:00
Tony Finch
541222043d MacOS needs more IP addresses to run the system tests
The launchd script only counted up to 8 whereas ifconfig.sh went all
the way up to 10, and even a bit further than that.

(cherry picked from commit 29a3e77425)
2022-04-04 15:06:31 +01:00
Arаm Sаrgsyаn
83b7563111 Merge branch '3248-dig-stuck-using-a-server-with-a-mapped-ip-address-v9_18' into 'v9_18'
[v9_18] Fix dig hanging issue in cases when the lookup's next query can't start

See merge request isc-projects/bind9!6068
2022-04-04 10:20:35 +00:00
Aram Sargsyan
5c6580b31f Add CHANGES note for [GL #3248]
(cherry picked from commit 438e9b5587)
2022-04-04 09:19:44 +00:00
Aram Sargsyan
1294de8e36 Fix dig hanging issue in cases when the lookup's next query can't start
In recv_done(), when dig decides to start the lookup's next query in
the line using `start_udp()` or `start_tcp()`, and for some reason,
no queries get started, dig doesn't cancel the lookup.

This can occur, for example, when there are two queries in the lookup,
one with a regular IP address, and another with a IPv4 mapped IPv6
address. When the regular IP address fails to serve the query, its
`recv_done()` callback starts the next query in the line (in this
case the one with a mapped IP address), but because `dig` doesn't
connect to such IP addresses, and there are no other queries in the
list, no new queries are being started, and the lookup keeps hanging.

After calling `start_udp()` or `start_tcp()` in `recv_done()`, check
if there are no pending/working queries then cancel the lookup instead
of only detaching from the current query.

(cherry picked from commit 7e2f50c369)
2022-04-04 09:18:46 +00:00
Evan Hunt
2c4e7c1702 Merge branch '3250-resolver-test-non-querytrace-v9_18' into 'v9_18'
fix resolver test when built without --enable-querytrace

See merge request isc-projects/bind9!6065
2022-04-01 17:30:01 +00:00
Evan Hunt
a18c824f6a fix resolver test when built without --enable-querytrace
a test case in the 'resolver' system test was reliant on
logged output that would only be present when query tracing
was enabled, as in developer builds. that test case is now
disabled when query tracing is not available. Thanks to
Anton Castelli.

(cherry picked from commit 5319d8adea)
2022-04-01 10:17:00 -07:00
Arаm Sаrgsyаn
71201fa71e Merge branch '3145-dig-+nssearch-does-not-exit-until-interrupted-v9_18' into 'v9_18'
[v9_18] Fix "dig +nssearch" indefinitely hanging issue

See merge request isc-projects/bind9!6057
2022-04-01 12:25:54 +00:00
Aram Sargsyan
cfdf95d437 Synchronze udp_ready() and tcp_connected() functions entry behavior
The `udp_ready()` and `tcp_connected()` functions in dighost.c are
used for similar purposes for UDP and TCP respectively.

Synchronize the `udp_ready()` function entry code to behave like
`tcp_connected()` by adding input validation, debug messages and
early exit code when `cancel_now` is `true`.

(cherry picked from commit 4477f71868)
2022-04-01 11:53:47 +00:00
Aram Sargsyan
09e9aabb11 Add CHANGES note for [GL #3145]
(cherry picked from commit 3a5793ece2)
2022-04-01 11:53:40 +00:00
Aram Sargsyan
16bdced2ca Fix "dig +nssearch" indefinitely hanging issue
When finishing the NSSEARCH task and there is no more followup
lookups to start, dig does not destroy the last lookup, which
causes it to hang indefinitely.

Rename the unused `first_pass` member of `dig_query_t` to `started`
and make it `true` in the first callback after `start_udp()` or
`start_tcp()` of the query to indicate that the query has been
started.

Create a new `check_if_queries_done()` function to check whether
all of the queries inside a lookup have been started and finished,
or canceled.

Use the mentioned function in the TRACE code block in `recv_done()`
to check whether the current query is the last one in the lookup and
cancel the lookup in that case to free the resources.

(cherry picked from commit 7d360bd05e)
2022-04-01 11:53:33 +00:00
Mark Andrews
49320f73df Merge branch '3191-issue-45178-in-oss-fuzz-bind9-dns_master_load_fuzzer-integer-overflow-in-generate-v9_18' into 'v9_18'
Prevent arithmetic overflow of 'i' in master.c:generate

See merge request isc-projects/bind9!6055
2022-04-01 11:01:42 +00:00
Evan Hunt
953f62c1e7 add a system test for $GENERATE with an integer overflow
the line "$GENERATE 19-28/2147483645 $ CNAME x" should generate
a single CNAME with the owner "19.example.com", but prior to the
overflow bug it generated several CNAMEs, half of them with large
negative values.

we now test for the bugfix by using "named-checkzone -D" and
grepping for a single CNAME in the output.

(cherry picked from commit bd814b79d4)
2022-04-01 21:42:35 +11:00
Evan Hunt
8ac8197f0d update shell syntax
clean up the shell syntax in the checkzone test prior to adding
a new test.

(cherry picked from commit 2261c853b5)
2022-04-01 21:42:35 +11:00
Mark Andrews
3a3219fd3f Add test case for issue-45178
(cherry picked from commit 9039aad0f8)
2022-04-01 21:42:35 +11:00
Mark Andrews
1eff9bbf37 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:35 +11:00
Tony Finch
05224c32a7 Merge branch '3209-notauth-subdomain-v9_18' into 'v9_18'
Log "not authoritative for update zone" more clearly (v9.18)

See merge request isc-projects/bind9!6047
2022-03-30 13:20:58 +00:00
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