Commit graph

10019 commits

Author SHA1 Message Date
Matthijs Mekking
fa2e4e66b0 Add tests for going from secure to insecure
Add two test zones that will be reconfigured to go insecure, by
setting the 'dnssec-policy' option to 'none'.

One zone was using inline-signing (implicitly through dnssec-policy),
the other is a dynamic zone.

Two tweaks to the kasp system test are required: we need to set
when to except the CDS/CDS Delete Records, and we need to know
when we are dealing with a dynamic zone (because the logs to look for
are slightly different, inline-signing prints "(signed)" after the
zone name, dynamic zones do not).
2020-12-23 09:02:11 +01:00
Mark Andrews
09f00ad5dd PYTHON may be null
When Python is not present, PYTHON=$(command -v "@PYTHON@") will exit
the script with 1, prevent that by adding "|| true".
2020-12-23 09:16:26 +11:00
Matthijs Mekking
f1a097964c Add test for cpu affinity
Add a test to check BIND 9 honors CPU affinity mask. This requires
some changes to the start script, to construct the named command.
2020-12-23 09:16:26 +11:00
Mark Andrews
77372e9e24 Handle shared library platforms that don't support inter library dependancies 2020-12-21 01:09:45 +00:00
Mark Andrews
08df4f420a Reorder in library dependancy order 2020-12-21 01:09:45 +00:00
Michal Nowak
befcbcac28
Fix a reference to rndc(8) in named(8) manual page 2020-12-14 13:10:10 +01:00
Mark Andrews
eb1b29b19e Update dnssec-signzone -N soa-serial-format description
document the autoincrement when the serial would go backwards.
2020-12-11 10:48:28 +01:00
Ondřej Surý
ef685bab5c Print warning when falling back to increment soa serial method
When using the `unixtime` or `date` method to update the SOA serial,
`named` and `dnssec-signzone` would silently fallback to `increment`
method to prevent the new serial number to be smaller than the old
serial number (using the serial number arithmetics).  Add a warning
message when such fallback happens.
2020-12-11 10:48:28 +01:00
Mark Andrews
5684c21bcf Generate PTR records for DNS64 mapped ipv4only.arpa reverses.
Rather than generating CNAMES records pointing into IN-ADDR.ARPA,
generate PTR records directly as the names are known as per RFC 8880.
2020-12-11 14:17:52 +11:00
Mark Andrews
cdfe660326 Checking synthesis of AAAA of builtin ipv4only.arpa 2020-12-11 14:17:47 +11:00
Mark Andrews
c51ef23c22 Implement ipv4only.arpa forward and reverse zones as per RFC 8880. 2020-12-11 14:16:40 +11:00
Ondřej Surý
7ba18870dc Reformat sources using clang-format-11 2020-12-08 18:36:23 +01:00
Ondřej Surý
151852f428 Fix datarace when UDP/TCP connect fails and we are in nmthread
When we were in nmthread, the isc__nm_async_<proto>connect() function
executes in the same thread as the isc__nm_<proto>connect() and on a
failure, it would block indefinitely because the failure branch was
setting sock->active to false before the condition around the wait had a
chance to skip the WAIT().

This also fixes the zero system test being stuck on FreeBSD 11, so we
re-enable the test in the commit.
2020-12-03 13:56:34 +01:00
Michał Kępień
6697f6f066 Temporarily disable the "legacy" test on Windows
The current issues with the way dig handles TCP "connection refused"
errors cause the "legacy" system test to consistently fail on Windows
due to the expected strings not being present in dig output.
Temporarily disable the "legacy" system test on Windows by moving it
from the PARALLEL_COMMON list to the PARALLEL_UNIX list until the
situation is rectified.
2020-12-03 12:48:43 +01:00
Ondřej Surý
94afea9325 Don't use stack allocated buffer for uv_write()
On FreeBSD, the stack is destroyed more aggressively than on Linux and
that revealed a bug where we were allocating the 16-bit len for the
TCPDNS message on the stack and the buffer got garbled before the
uv_write() sendback was executed.  Now, the len is part of the uvreq, so
we can safely pass it to the uv_write() as the req gets destroyed after
the sendcb is executed.
2020-12-03 08:58:16 +01:00
Ondřej Surý
79c196fc77 Change the default value for nocookie-udp-size back to 4096
The DNS Flag Day 2020 reduced all the EDNS buffer sizes to 1232.  In
this commit, we revert the default value for nocookie-udp-size back to
4096 because the option is too obscure and most people don't realize
that they also need to change this configuration option in addition to
max-udp-size.
2020-12-02 11:06:42 +01:00
Ondřej Surý
0f57732d13 Skip the zero, xfer and ixfr tests on non-Linux platforms
Due to the platform differences, on non-Linux platforms, the xfer and
ixfr tests fails and zero test gets stuck.

This commit will get reverted when we add support for netmgr
multi-threading.
2020-12-01 17:24:06 +01:00
Ondřej Surý
634bdfb16d Refactor netmgr and add more unit tests
This is a part of the works that intends to make the netmgr stable,
testable, maintainable and tested.  It contains a numerous changes to
the netmgr code and unfortunately, it was not possible to split this
into smaller chunks as the work here needs to be committed as a complete
works.

NOTE: There's a quite a lot of duplicated code between udp.c, tcp.c and
tcpdns.c and it should be a subject to refactoring in the future.

The changes that are included in this commit are listed here
(extensively, but not exclusively):

* The netmgr_test unit test was split into individual tests (udp_test,
  tcp_test, tcpdns_test and newly added tcp_quota_test)

* The udp_test and tcp_test has been extended to allow programatic
  failures from the libuv API.  Unfortunately, we can't use cmocka
  mock() and will_return(), so we emulate the behaviour with #define and
  including the netmgr/{udp,tcp}.c source file directly.

* The netievents that we put on the nm queue have variable number of
  members, out of these the isc_nmsocket_t and isc_nmhandle_t always
  needs to be attached before enqueueing the netievent_<foo> and
  detached after we have called the isc_nm_async_<foo> to ensure that
  the socket (handle) doesn't disappear between scheduling the event and
  actually executing the event.

* Cancelling the in-flight TCP connection using libuv requires to call
  uv_close() on the original uv_tcp_t handle which just breaks too many
  assumptions we have in the netmgr code.  Instead of using uv_timer for
  TCP connection timeouts, we use platform specific socket option.

* Fix the synchronization between {nm,async}_{listentcp,tcpconnect}

  When isc_nm_listentcp() or isc_nm_tcpconnect() is called it was
  waiting for socket to either end up with error (that path was fine) or
  to be listening or connected using condition variable and mutex.

  Several things could happen:

    0. everything is ok

    1. the waiting thread would miss the SIGNAL() - because the enqueued
       event would be processed faster than we could start WAIT()ing.
       In case the operation would end up with error, it would be ok, as
       the error variable would be unchanged.

    2. the waiting thread miss the sock->{connected,listening} = `true`
       would be set to `false` in the tcp_{listen,connect}close_cb() as
       the connection would be so short lived that the socket would be
       closed before we could even start WAIT()ing

* The tcpdns has been converted to using libuv directly.  Previously,
  the tcpdns protocol used tcp protocol from netmgr, this proved to be
  very complicated to understand, fix and make changes to.  The new
  tcpdns protocol is modeled in a similar way how tcp netmgr protocol.
  Closes: #2194, #2283, #2318, #2266, #2034, #1920

* The tcp and tcpdns is now not using isc_uv_import/isc_uv_export to
  pass accepted TCP sockets between netthreads, but instead (similar to
  UDP) uses per netthread uv_loop listener.  This greatly reduces the
  complexity as the socket is always run in the associated nm and uv
  loops, and we are also not touching the libuv internals.

  There's an unfortunate side effect though, the new code requires
  support for load-balanced sockets from the operating system for both
  UDP and TCP (see #2137).  If the operating system doesn't support the
  load balanced sockets (either SO_REUSEPORT on Linux or SO_REUSEPORT_LB
  on FreeBSD 12+), the number of netthreads is limited to 1.

* The netmgr has now two debugging #ifdefs:

  1. Already existing NETMGR_TRACE prints any dangling nmsockets and
     nmhandles before triggering assertion failure.  This options would
     reduce performance when enabled, but in theory, it could be enabled
     on low-performance systems.

  2. New NETMGR_TRACE_VERBOSE option has been added that enables
     extensive netmgr logging that allows the software engineer to
     precisely track any attach/detach operations on the nmsockets and
     nmhandles.  This is not suitable for any kind of production
     machine, only for debugging.

* The tlsdns netmgr protocol has been split from the tcpdns and it still
  uses the old method of stacking the netmgr boxes on top of each other.
  We will have to refactor the tlsdns netmgr protocol to use the same
  approach - build the stack using only libuv and openssl.

* Limit but not assert the tcp buffer size in tcp_alloc_cb
  Closes: #2061
2020-12-01 16:47:07 +01:00
Mark Andrews
ab0bf49203 Adjust default value of "max-recursion-queries"
Since the queries sent towards root and TLD servers are now included in
the count (as a result of the fix for CVE-2020-8616),
"max-recursion-queries" has a higher chance of being exceeded by
non-attack queries.  Increase its default value from 75 to 100.
2020-12-01 23:47:23 +11:00
Michal Nowak
9567cefd39
Drop bin/tests/headerdep_test.sh.in
The bin/tests/headerdep_test.sh script has not been updated since it was
first created and it cannot be used as-is with the current BIND source
code.  Better tools (e.g. "include-what-you-use") emerged since the
script was committed back in 2000, so instead of trying to bring it up
to date, remove it from the source repository.
2020-11-27 13:11:41 +01:00
Mark Andrews
bd9155590e Check that missing cookies are handled 2020-11-26 20:48:46 +00:00
Michal Nowak
6428fc26af
Write traceback file to the same directory as core file
The traceback files could overwrite each other on systems which do not
use different core dump file names for different processes.  Prevent
that by writing the traceback file to the same directory as the core
dump file.

These changes still do not prevent the operating system from overwriting
a core dump file if the same binary crashes multiple times in the same
directory and core dump files are named identically for different
processes.
2020-11-26 18:01:34 +01:00
Mark Andrews
0f0a006c7e
Unify whitespace in bin/tests/system/run.sh.in
Replace tabs with spaces to make whitespace consistent across the entire
bin/tests/system/run.sh.in script.
2020-11-26 18:01:33 +01:00
Matthijs Mekking
6b5d7357df Detect NSEC3 salt collisions
When generating a new salt, compare it with the previous NSEC3
paremeters to ensure the new parameters are different from the
previous ones.

This moves the salt generation call from 'bin/named/*.s' to
'lib/dns/zone.c'. When setting new NSEC3 parameters, you can set a new
function parameter 'resalt' to enforce a new salt to be generated. A
new salt will also be generated if 'salt' is set to NULL.

Logging salt with zone context can now be done with 'dnssec_log',
removing the need for 'dns_nsec3_log_salt'.
2020-11-26 10:43:59 +01:00
Matthijs Mekking
3b4c764b43 Add zone context to "generated salt" logs 2020-11-26 10:43:59 +01:00
Matthijs Mekking
7878f300ff Move logging of salt in separate function
There may be a desire to log the salt without losing the context
of log module, level, and category.
2020-11-26 10:43:59 +01:00
Matthijs Mekking
6f97bb6b1f Change nsec3param salt config to saltlen
Upon request from Mark, change the configuration of salt to salt
length.

Introduce a new function 'dns_zone_checknsec3aram' that can be used
upon reconfiguration to check if the existing NSEC3 parameters are
in sync with the configuration. If a salt is used that matches the
configured salt length, don't change the NSEC3 parameters.
2020-11-26 10:43:59 +01:00
Matthijs Mekking
00c5dabea3 Add check for NSEC3 and key algorithms
NSEC3 is not backwards compatible with key algorithms that existed
before the RFC 5155 specification was published.
2020-11-26 10:43:59 +01:00
Matthijs Mekking
f10790b02d Disable one nsec3 test due to GL #2216
This known bug makes the test fail. There is no trivial fix so disable
test case for now.
2020-11-26 10:43:59 +01:00
Matthijs Mekking
a5b45bdd03 Add some NSEC3 optout tests
Make sure that just changing the optout value recreates the chain.
2020-11-26 10:43:27 +01:00
Matthijs Mekking
7039c5f805 Check nsec3param configuration values
Check 'nsec3param' configuration for the number of iterations.  The
maximum number of iterations that are allowed are based on the key
size (see https://tools.ietf.org/html/rfc5155#section-10.3).

Check 'nsec3param' configuration for correct salt. If the string is
not "-" or hex-based, this is a bad salt.
2020-11-26 10:43:27 +01:00
Matthijs Mekking
eae9a6d297 Don't use 'rndc signing' with kasp
The 'rndc signing' command allows you to manipulate the private
records that are used to store signing state. Don't use these with
'dnssec-policy' as such manipulations may violate the policy (if you
want to change the NSEC3 parameters, change the policy and reconfig).
2020-11-26 10:43:27 +01:00
Matthijs Mekking
ba8128ea00 Fix a reconfig bug wrt inline-signing
When doing 'rndc reconfig', named may complain about a zone not being
reusable because it has a raw version of the zone, and the new
configuration has not set 'inline-signing'. However, 'inline-signing'
may be implicitly true if a 'dnssec-policy' is used for the zone, and
the zone is not dynamic.

Improve the check in 'named_zone_reusable'.  Create a new function for
checking 'inline-signing' configuration that matches existing code in
'bin/named/server.c'.
2020-11-26 10:43:27 +01:00
Matthijs Mekking
114af58ee2 Support for NSEC3 in dnssec-policy
Implement support for NSEC3 in dnssec-policy.  Store the configuration
in kasp objects. When configuring a zone, call 'dns_zone_setnsec3param'
to queue an nsec3param event. This will ensure that any previous
chains will be removed and a chain according to the dnssec-policy is
created.

Add tests for dnssec-policy zones that uses the new 'nsec3param'
option, as well as changing to new values, changing to NSEC, and
changing from NSEC.
2020-11-26 10:43:27 +01:00
Matthijs Mekking
f7ca96c805 Add kasp nsec3param configuration
Add configuration and documentation on how to enable NSEC3 when
using dnssec-policy for signing your zones.
2020-11-26 10:43:27 +01:00
Matthijs Mekking
84a4273074 Move generate_salt function to lib/dns/nsec3
We will be using this function also on reconfig, so it should have
a wider availability than just bin/named/server.
2020-11-26 10:43:27 +01:00
Michał Kępień
d9701e22b5 Teach cppcheck that fatal() does not return
cppcheck is not aware that the bin/dnssec/dnssectool.c:fatal() function
does not return.  This triggers certain cppcheck 2.2 false positives,
for example:

    bin/dnssec/dnssec-signzone.c:3471:13: warning: Either the condition 'ndskeys==8' is redundant or the array 'dskeyfile[8]' is accessed at index 8, which is out of bounds. [arrayIndexOutOfBoundsCond]
       dskeyfile[ndskeys++] = isc_commandline_argument;
                ^
    bin/dnssec/dnssec-signzone.c:3468:16: note: Assuming that condition 'ndskeys==8' is not redundant
       if (ndskeys == MAXDSKEYS) {
                   ^
    bin/dnssec/dnssec-signzone.c:3471:13: note: Array index out of bounds
       dskeyfile[ndskeys++] = isc_commandline_argument;
                ^

    bin/dnssec/dnssec-signzone.c:772:20: warning: Either the condition 'l->hashbuf==NULL' is redundant or there is pointer arithmetic with NULL pointer. [nullPointerArithmeticRedundantCheck]
     memset(l->hashbuf + l->entries * l->length, 0, l->length);
                       ^
    bin/dnssec/dnssec-signzone.c:768:18: note: Assuming that condition 'l->hashbuf==NULL' is not redundant
      if (l->hashbuf == NULL) {
                     ^
    bin/dnssec/dnssec-signzone.c:772:20: note: Null pointer addition
     memset(l->hashbuf + l->entries * l->length, 0, l->length);
                       ^

Instead of suppressing all such warnings individually, conditionally
define a preprocessor macro which prevents them from being triggered.
2020-11-25 12:45:47 +01:00
Evan Hunt
c3a90b1d2c create system test with asynchronous plugin
the test-async plugin uses ns_query_hookasync() at the
NS_QUERY_DONE_SEND hook point to call an asynchronous function.
the only effect is to change the query response code to "NOTIMP",
so we can confirm that the hook ran and resumed correctly.
2020-11-24 15:11:39 -08:00
Mark Andrews
9a224a3c27 add +dns64prefix to dig to display any DNS64 prefixes at IPV4ONLY.ARPA 2020-11-25 08:25:29 +11:00
Evan Hunt
17145e4ef4 dig could crash on interrupt
dig could crash if it was shut down by an interrupt while a connection
was pending.
2020-11-23 20:00:04 +00:00
Matthijs Mekking
53188daf5b Fix syntax in echo_i messages
It's either "record returns" or "records return".
2020-11-19 11:40:19 +01:00
Mark Andrews
da1243fe9d bin/tests/system/stop.sh was not working
It failed to export builddir srcdir resulting in stop.pl failing
when these where looked for in the environment.
2020-11-19 16:15:26 +11:00
Mark Andrews
e980affba0 Fix DNAME when QTYPE is CNAME or ANY
The synthesised CNAME is not supposed to be followed when the
QTYPE is CNAME or ANY as the lookup is satisfied by the CNAME
record.
2020-11-19 10:18:01 +11:00
Diego Fronza
1ba2215c29 Update ARM and other documents 2020-11-11 12:53:24 -03:00
Diego Fronza
8cca23a147 Adjusted test to match new rndc serve-stale status output 2020-11-11 12:53:24 -03:00
Diego Fronza
d4142d2bed Output 'stale-refresh-time' value on rndc serve-stale status 2020-11-11 12:53:24 -03:00
Diego Fronza
581e2a8f28 Check 'stale-refresh-time' when sharing cache between views
This commit ensures that, along with previous restrictions, a cache is
shareable between views only if their 'stale-refresh-time' value are
equal.
2020-11-11 12:53:24 -03:00
Matthijs Mekking
e99671e8dd Add two more system tests for stale-refresh-time
Add one test that checks the behavior when serve-stale is enabled
via configuration (as opposed to enabled via rndc).

Add one test that checks the behavior when stale-refresh-time is
disabled (set to 0).
2020-11-11 12:53:24 -03:00
Matthijs Mekking
dee778de12 Change serve-stale test stale-answer-ttl
Using a 'stale-answer-ttl' the same value as the authoritative ttl
value makes it hard to differentiate between a response from the
stale cache and a response from the authoritative server.

Change the stale-answer-ttl from 2 to 4, so that it differs from the
authoritative ttl.
2020-11-11 12:53:24 -03:00
Diego Fronza
cc70ea860b Wait for multiple parallel dig commands to fully finish
The strategy of running many dig commands in parallel and
waiting for the respective output files to be non empty was
resulting in random test failures, hard to reproduce, where
it was possible that the subsequent reading of the files could
have been failing due to the file's content not being fully flushed.

Instead of checking if output files are non empty, we now wait
for the dig processes to finish.
2020-11-11 12:53:24 -03:00