Commit graph

11013 commits

Author SHA1 Message Date
Aram Sargsyan
789ce76dd1 Add a catz system test check for [GL #3911]
The trick is to configure a duplicate zone, which comes after the
catalog zone, where the duplicate zone is an existing member zone.

In that scenario, all the zones which come before the "faulty" zone
in the configuration file will fail to be reverted to the previous
version of the view after a reconfiguration error, and in this
particular case that will result in an assertion failure when the
catalog zone update is initiated, because it will be still tied to
the new version of the view, which was dismissed.

(cherry picked from commit 93c4f382f4)
2023-03-01 15:39:39 +00:00
Aram Sargsyan
7e4d450c1e Add a system test for [GL #3777]
Add the 'ixfr-from-differences yes;' option to trigger a failed
zone postload operation when a zone is updated but the serial
number is not updated, then issue two successive 'rndc reload'
commands to trigger the bug, which causes an assertion failure.

(cherry picked from commit a73b67456e)
2023-02-28 13:47:18 +00:00
Artem Boldariev
c392b57e50
Increase server start timeout for system tests
This commit increases server start timeout from 60 to 90 seconds in
order to avoid system test failures on some platforms due to inability
to initialise TLS contexts in time.

(cherry picked from commit 705f0d1ed1)
2023-02-28 14:26:13 +01:00
Mark Andrews
aa8bcc0a5a Fix 'checking drop statistics' test
Wait for the desired log message to appear in ns3/named.stats rather
than the creation of the file.

(cherry picked from commit c7ae975ecf)
2023-02-28 12:26:45 +00:00
Mark Andrews
1c0ef5fabe Fix 'lame server clients are dropped below the hard limit' test
The test was setting a minimum count for recursive clients which
was not always being met (e.g. 91 instead of 100) producing a false
positive.  Lower the lower bound on recursive clients for this
test to 1.

(cherry picked from commit af47090d99)
2023-02-28 12:26:45 +00:00
Michał Kępień
8fcf05a724 (Mostly) fix building bin/tests/system/rpz/dnsrps
Building the bin/tests/system/rpz/dnsrps helper binary is currently not
possible at all as the necessary compiler and linker flag definitions
are missing from bin/tests/system/Makefile.am.  Add these as a basis for
addressing the problem.

Unfortunately, this is where the "mostly" bit mentioned in this commit's
subject line comes into play.  The dlopen() parts of DNSRPS code have
not yet been reworked to use libuv's dlopen() API (uv_dlopen() etc.)
(See commit 37b9511ce1 for prior work in
this area.)  While it is certainly possible to do that, implementing
such a change without testing it in practice against a usable librpz.so
(i.e. a DNSRPS provider library) is bound to cause more trouble and
confusion than keeping the code the way it is right now.  However,
making that code buildable as-is requires linking against a C standard
library that exports the dlopen(), dlsym(), and dlclose() symbols used
by the DNSRPS dynamic loading code.  glibc 2.34+ satisfies that
requirement, but older glibc versions do not (these come with a separate
libdl shared library that would need to be linked in as well).  (Other
C standard library implementations have not been examined.)  Since the
long-term plan is to rely on libuv's dlopen() API exclusively and
detecting the shared object containing dlopen() & friends would only
pull in build system complexity for no good reason, assume for now that
the target system provides the dlopen() API in its C standard library.

This change enables the system test suite to be run for a BIND 9 build
prepared using --enable-dnsrps --enable-dnsrps-dl (on systems satisfying
the requirement explained above).  However, it is important to note that
this change by itself does NOT enable actual testing of the DNSRPS
feature as doing that requires a DNSRPS provider library to be present
on the test host.

(cherry picked from commit b396f55586)
2023-02-28 12:57:41 +01:00
Aram Sargsyan
ed942f5536 Add shutdown signaling for catalog zones
This change should make sure that catalog zone update processing
doesn't happen when the catalog zone is being shut down. This
should help avoid races when offloading the catalog zone updates
in the follow-up commit.

(cherry picked from commit 246b7084d6)
2023-02-28 09:50:42 +00:00
Aram Sargsyan
f8663976ff Add reference count tracing for dns_catz_zone_t and dns_catz_zones_t
Tracing can be activated by defining DNS_RPZ_TRACE in catz.h.

(cherry picked from commit 53f0c5a9ac)
2023-02-27 20:43:48 +00:00
Aram Sargsyan
43d99eb8b8 Light refactoring of catz.c
* Change 'dns_catz_new_zones()' function's prototype (the order of the
  arguments) to synchronize it with the similar function in rpz.c.
* Rename 'refs' to 'references' in preparation of ISC_REFCOUNT_*
  macros usage for reference tracking.
* Unify dns_catz_zone_t naming to catz, and dns_catz_zones_t naming to
  catzs, following the logic of similar changes in rpz.c.
* Use C compound literals for structure initialization.
* Synchronize the "new zone version came too soon" log message with the
  one in rpz.c.
* Use more of 'sizeof(*ptr)' style instead of the 'sizeof(type_t)' style
  expressions when allocating or freeing memory for 'ptr'.

(cherry picked from commit 8cb79fec9d)
2023-02-27 20:43:48 +00:00
Mark Andrews
dfaf3b7b78
Test RRSIG queries with serve-stale enabled
Make RRSIG queries where the existing tests trigger a DNS_EVENT_TRYSTALE
event.

(cherry picked from commit add40273df)
2023-02-22 13:38:59 +01:00
Aram Sargsyan
e7f03ec3ac
Add tests for CVE-2022-3924
Reproduce the assertion by configuring a 'named' resolver with
'recursive-clients 10;' configuration option and running 20
queries is parallel.

Also tweak the 'ans2/ans.pl' to simulate a 50ms network latency
when qname starts with "latency". This makes sure that queries
running in parallel don't get served immediately, thus allowing
the configured recursive clients quota limitation to be activated.

(cherry picked from commit 4b52b0b4a9)
2023-02-22 10:50:44 +01:00
Mark Andrews
87602eecd7 Fix dns_kasp_attach / dns_kasp_detach usage
The kasp pointers in dns_zone_t should consistently be changed by
dns_kasp_attach and dns_kasp_detach so the usage is balanced.

(cherry picked from commit b41882cc75)
2023-02-21 16:54:53 +01:00
Aram Sargsyan
722b116905 Detach rpzs and catzs from the previous view
When switching to a new view during a reconfiguration (or reverting
to the old view), detach the 'rpzs' and 'catzs' from the previuos view.

The 'catzs' case was earlier solved slightly differently, by detaching
from the new view when reverting to the old view, but we can not solve
this the same way for 'rpzs', because now in BIND 9.19 and BIND 9.18
a dns_rpz_shutdown_rpzs() call was added in view's destroy() function
before detaching the 'rpzs', so we can not leave the 'rpzs' attached to
the previous view and let it be shut down when we intend to continue
using it with the new view.

Instead, "re-fix" the issue for the 'catzs' pointer the same way as
for 'rpzs' for consistency, and also because a similar shutdown call
is likely to be implemented for 'catzs' in the near future.

(cherry picked from commit 121a095a22)
2023-02-21 09:04:19 +00:00
Aram Sargsyan
568f685856 Add an "rpz" system test check for a failed reconfiguration
The faulty "DLZ" configuration triggers a reconfiguration failure
in such a place where view reverting code is covered.

(cherry picked from commit 95f4bac002)
2023-02-21 09:04:10 +00:00
Evan Hunt
61692942b8 remove named_os_gethostname()
this function was just a front-end for gethostname(). it was
needed when we supported windows, which has a different function
for looking up the hostname; it's not needed any longer.

(cherry picked from commit 197334464e)
2023-02-18 12:27:19 -08:00
Michal Nowak
da49342f26
Fix unnecessary "else" after "raise" with pylint 2.16.2
bin/tests/system/get_algorithms.py:225:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)

(cherry picked from commit 8064ac6bec)
2023-02-17 16:03:30 +01:00
Michal Nowak
d89f1056df
Adapt to Python scripts to black 23.1.0
(cherry picked from commit 3cd2cc6254)
2023-02-17 16:03:30 +01:00
Mark Andrews
cf5e81ed7b Cleanup OpenSSL reference on bad option
Another exit path that needs to be cleaned up.

(cherry picked from commit e27fc4bbc5)
2023-02-16 22:31:52 +00:00
Mark Andrews
4dfc183fbd Cleanup OpenSSL reference on bad domain name
Free/detach tsigkey and sig0key when exiting and then call
dst_lib_destroy if we have previously called dst_lib_init.  This will,
in theory, allow OPENSSL_cleanup to free all memory.

(cherry picked from commit 4c2525c418)
2023-02-16 22:31:52 +00:00
Petr Menšík
0915738c46 FIPS tests changes for RHEL
Include MD5 feature detection in featuretest tool and use it in some
places. When RHEL distribution or Fedora ELN is in FIPS mode, then MD5
algorithm is unavailable completely and even hmac-md5 algorithm usage
will always fail. Work that around by checking MD5 works and if not,
skipping its usage.

Those changes were dragged as downstream patch bind-9.11-fips-tests.patch
in Fedora and RHEL.

(cherry picked from commit 6ad794a8cd)
2023-02-16 08:34:47 +11:00
Tom Krizek
df2a962284
Ignore dig errors in +short comparisons in tests
Tests using diff to compare outputs of dig +short shall ignore lines
starting with ";". In dig +short output, such lines should only be
present for errors such as network issues. Since we utilize dig's
default timeout/retry mechanisms, these transitory issues should be
ignored and only the final output should be considered during the diff
comparison.

(cherry picked from commit bd1ef66f83)
2023-02-14 13:41:06 +01:00
Ondřej Surý
5baf3ac3b6 Refactor dns_rpz unit to use single reference counting
The dns_rpz_zones structure was using .refs and .irefs for strong and
weak reference counting.  Rewrite the unit to use just a single
reference counting + shutdown sequence (dns_rpz_destroy_rpzs) that must
be called by the creator of the dns_rpz_zones_t object.  Remove the
reference counting from the dns_rpz_zone structure as it is not needed
because the zone objects are fully embedded into the dns_rpz_zones
structure and dns_rpz_zones_t object must never be destroyed before all
dns_rpz_zone_t objects.

The dns_rps_zones_t reference counting uses the new ISC_REFCOUNT_TRACE
capability - enable by defining DNS_RPZ_TRACE in the dns/rpz.h header.

Additionally, add magic numbers to the dns_rpz_zone and dns_rpz_zones
structures.

(cherry picked from commit 77659e7392)
2023-02-14 09:58:16 +00:00
Mark Andrews
90aa1ba971 Add islands of trust to mkeys test
This adds an island of trust that is reachable from the root
where the trust anchors are added to island.conf.

This add an island of trust that is not reachable from the root
where the trust anchors are added to private.conf.

(cherry picked from commit 41bdb5b9fe)
2023-02-14 10:44:39 +11:00
Tony Finch
6c19848836 Fix the reference to RFC 1035 in named-compilezone(1)
There was a stray backquote

(cherry picked from commit ef1170b3fc)
2023-02-13 16:33:38 +00:00
Tom Krizek
b4d01b0175
Increase named startup wait time for runtime test
Occasionally, the allotted 10 seconds for the "running" line to appear
in log after named is started proved insufficient in CI, especially
during increased load. Give named up to 60 seconds to start up to
mitigate this issue.

(cherry picked from commit b8bb4233e8)
2023-02-13 16:08:56 +01:00
Evan Hunt
342286ecdb remove isc_bind9 variable
isc_bind9 was a global bool used to indicate whether the library
was being used internally by BIND or by an external caller. external
use is no longer supported, but the variable was retained for use
by dyndb, which needed it only when being built without libtool.
building without libtool is *also* no longer supported, so the variable
can go away.

(cherry picked from commit 935879ed11)
2023-02-09 10:07:39 -08:00
Mark Andrews
7ca00e674f Make notify source port test reliable
Send the test message from ns3 to ns2 instead of ns2 to ns3 as ns2
is started first and therefore the test doesn't have to wait on the
resend of the the NOTIFY message to be successful.

(cherry picked from commit e7e1f59a3a)
2023-02-09 19:40:19 +11:00
Mark Andrews
66a3802507 dnssec-checkds: cleanup memory on error paths
Move and give unique names to the dns_db_t, dns_dbnode_t and
dns_dbversion_t pointers, so they have global scope and therefore
are visible to cleanup.  Unique names are not strictly necessary,
as none of the functions involved call each other.

Change free_db to handle NULL pointers and also an optional
(dns_dbversion_t **).

In match_keyset_dsset and free_keytable, ki to be handled
differently to prevent a false positive NULL pointer dereference
warning from scan.

In formatset moved dns_master_styledestroy earlier and freed
buf before calling check_result to prevent memory leak.

In append_new_ds_set freed ds on the default path before
calling check_result to prevent memory leak.

(cherry picked from commit 13f9d29954)
2023-02-09 09:00:28 +11:00
Mark Andrews
af051282bc dnssec-cds failed to cleanup on non error paths
dnssec-cds failed to cleanup on non error paths which meant that
the OpenSSL libraries could not cleanup properly.

(cherry picked from commit 81bde388e4)
2023-02-09 08:58:15 +11:00
Evan Hunt
1d6721c5fa increase simultaneous updates for quota test
the nsupdate system test was intermittently failing due to the update
quota not being exceeded when it should have been.  this is most likely
a timing issue: the client is sending updates too slowly, or the server
is processing them too quickly, for the quota to fill. this commit
attempts to make that the failure less likely by increasing the number
of update transactions from 10 to 20.

(cherry picked from commit 06b1faf068)
2023-02-07 23:41:24 -08:00
Mark Andrews
11065c810a Allow some time to the root trust anchor to appear
Following deleting the root trust anchor and reconfiguring the
server it takes some time to for trust anchor to appear in 'rndc
managed-keys status' output.  Retry several times.

(cherry picked from commit 71dbd09796)
2023-02-08 00:42:15 +11:00
Evan Hunt
29ccc052dd add source port configuration tests
check in the log files of receiving servers that the originating
ports for notify and SOA query messages were set correctly from
configured notify-source and transfer-source options.

(cherry picked from commit 9cffd5c431)
2023-02-06 17:02:02 -08:00
Mark Andrews
c705467d30 named-rrchecker: have fatal cleanup
It is trivial to fully cleanup memory on all the error paths in
named-rrchecker, many of which are triggered by bad user input.
This involves freeing lex and mctx if they exist when fatal is
called.

(cherry picked from commit dbe82813e6)
2023-02-07 11:15:21 +11:00
Evan Hunt
ac150939d5 delay trust anchor management until zones are loaded
it was possible for a managed trust anchor needing to send a key
refresh query to be unable to do so because an authoritative zone
was not yet loaded. this has been corrected by delaying the
synchronization of managed-keys zones until after all zones are
loaded.

(cherry-picked from commit bafbbd2465)
2023-02-06 14:27:16 -08:00
Matthijs Mekking
64f5e83ef4 Test deprecate source port configuration
Add 'port' token to deprecated.conf. Also add options
'use-v4-udp-ports', 'use-v6-udp-ports', 'avoid-v4-udp-ports',
and 'avoid-v6-udp-ports'.

All of these should trigger warnings (except when deprecation warnings
are being ignored).

(cherry picked from commit 531914e660)
2023-02-02 12:21:08 +01:00
Evan Hunt
5fa4aa2fec mark "port" as deprecated for source address options
Deprecate the use of "port" when configuring query-source(-v6),
transfer-source(-v6), notify-source(-v6), parental-source(-v6),
etc. Also deprecate use-{v4,v6}-udp-ports and avoid-{v4,v6}udp-ports.

(cherry picked from commit 470ccbc8ed)
2023-02-02 12:21:08 +01:00
Mark Andrews
e0090d4639 Handle address lookup failure more gracefully
If the address lookup of the primary server fails just abort
the current update request rather than calling exit.  This allows
nsupdate to cleanup gracefully.

(cherry picked from commit f1387514c6)
2023-02-01 00:36:42 +11:00
Mark Andrews
4263afa31d Call dns_lib_destroy in bin/named/main.c:printversion
There were unbalanced calls to dns_lib_init and dns_lib_destroy
leading to an OpenSSL memory leak.

(cherry picked from commit 8b3c018f54)
2023-01-31 10:06:02 +11:00
Matthijs Mekking
68f0fc6309 Force set DS state after 'rndc dnssec -checkds'
Set the DS state after issuing 'rndc dnssec -checkds'. If the DS
was published, it should go in RUMOURED state, regardless whether it
is already safe to do so according to the state machine.

Leaving it in HIDDEN (or if it was magically already in OMNIPRESENT or
UNRETENTIVE) would allow for easy shoot in the foot situations.

Similar, if the DS was withdrawn, the state should be set to
UNRETENTIVE. Leaving it in OMNIPRESENT (or RUMOURED/HIDDEN)
would also allow for easy shoot in the foot situations.

(cherry picked from commit ee42f66fbe)
2023-01-30 09:27:38 +01:00
Michał Kępień
8b4dcc27ef BIND 9.18.11
-----BEGIN PGP SIGNATURE-----
 
 iQJDBAABCgAtFiEENKwGS3ftSQfs1TU17QVz/8hFYQUFAmPAh6gPHG1pY2hhbEBp
 c2Mub3JnAAoJEO0Fc//IRWEFyGsQAJuggfdFRAFzH6QTlE+jYPGGPGGAEp9+lFuP
 ufCdlek5FKN/V/NFpuMfNeyQ3NhK93ofMzaluAg47vM5Cj2/lPxUUFea7w20tHVm
 Nqsxk4Lc+RsnngVNUwWtA6CkwAGHDQA0Rwa3OEjqPkm33KLwCeC3w3ufv6KPlT7m
 MubNOd7BogMBxDg63TnOlSBjcKFi/TzGCNmOVj1cyOj9QP52XeIe6iKol4g47mWG
 erQ8ZKV/vWoIRCwLdPheRgCgO/2KyHLGbtI+uJ53OExiYnrKL18wGnt1Foo8Er9V
 hOkBykzgtWTtgrl8Ljd1lbR6FjZvLgcWWIZ6oM2RXjD25942lNgyWYubQHsRHchi
 /vnFD3qg5SBBbCHuzIzy9QCk2YYwJiDpI8t2RngzhJOexHGcCLYyM99yriqNYnFw
 DHoFkcUbJiHGhtEzzGuhz7LrSySclvqQRYbWLh7qcuUIKGdbPiWB8BmZtAkaFyaN
 fOJYwk8pSlpgvFqaAOicG3hAWTUxcJ5U/wWdBFk7Xg3wZ/K2XLuA88QgxePh2S2L
 kYBwwD81amWMEZct1hq9PW42vFFiWjJtZnTceZjCVARQamJ/+QgjUapMfbnYb1jN
 ry4XQoFz3FhfT4Ow2cKfRUzrh8lrNUJNqMoNiXDnj4jjH1YwIN6NqIYqrXJUGeCU
 yaaBGMu/
 =XdZL
 -----END PGP SIGNATURE-----

Merge tag 'v9_18_11' into v9_18

BIND 9.18.11
2023-01-25 21:26:22 +01:00
Artem Boldariev
f408cacd86 Use SO_REUSEADDR for "ans9" mock server in "cookie" system test
This commit ensures that it is possible to run the 'cookie' test
multiple times in a row.

(cherry picked from commit 8fdf7bad76)
2023-01-24 16:05:46 +02:00
Matthijs Mekking
7ce0f7fb9e Add checkds test case with resolver parental-agent
Add a test case for a server that uses a resolver as an parental-agent.

We need two root servers, ns1 and ns10, one that delegates to the
'checkds' tld with the DS published (ns2), and one that delegates to
the 'checkds' tld with the DS removed (ns5). Both root zones are
being setup in the 'ns1/setup.sh' script.

We also need two resolvers, ns3 and ns8, that use different root hints
(one uses ns1 address as a hint, the other uses ns10).

Then add the checks to test_checkds.py is similar to the existing tests.

Update 'types' because for zones that have the DS withdrawn (or to be
withdrawn), the CDS and CDNSKEY records should not be published and
thus should not be in the NSEC bitmap.

(cherry picked from commit 0b9a9f9955)
2023-01-19 16:56:22 +01:00
Aram Sargsyan
8f209c7dcf Refactor isc_nm_xfr_allowed()
Return 'isc_result_t' type value instead of 'bool' to indicate
the actual failure. Rename the function to something not suggesting
a boolean type result. Make changes in the places where the API
function is being used to check for the result code instead of
a boolean value.

(cherry picked from commit 41dc48bfd7)
2023-01-19 12:20:10 +00:00
Ondřej Surý
e26aa4cbb1
Don't use reference counting in isc_timer unit
The reference counting and isc_timer_attach()/isc_timer_detach()
semantic are actually misleading because it cannot be used under normal
conditions.  The usual conditions under which is timer used uses the
object where timer is used as argument to the "timer" itself.  This
means that when the caller is using `isc_timer_detach()` it needs the
timer to stop and the isc_timer_detach() does that only if this would be
the last reference.  Unfortunately, this also means that if the timer is
attached elsewhere and the timer is fired it will most likely be
use-after-free, because the object used in the timer no longer exists.

Remove the reference counting from the isc_timer unit, remove
isc_timer_attach() function and rename isc_timer_detach() to
isc_timer_destroy() to better reflect how the API needs to be used.

The only caveat is that the already executed event must be destroyed
before the isc_timer_destroy() is called because the timer is no longet
attached to .ev_destroy_arg.

(cherry picked from commit ae01ec2823)
2023-01-18 22:39:26 +01:00
Ondřej Surý
fe0e9cf301
Commit the change of view for view->managed_keys
When we change the view in the view->managed_keys, we never commit the
change, keeping the previous view possibly attached forever.

Call the dns_zone_setviewcommit() immediately after changing the view as
we are detaching the previous view anyway and there's no way to recover
from that.

(cherry picked from commit 7e8b53720d)
2023-01-17 22:47:44 +01:00
Tom Krizek
58ff3b4fc0
Fix feature detection for pytest markers in tests
The condition was accidentally reversed during refactoring in
9730ac4c56 . It would result in skipped
tests on builds with proper support and false negatives on builds
without proper feature support.

Credit for reporting the issue and the fix goes to Stanislav Levin.

(cherry picked from commit 473cb530f4)
2023-01-17 14:50:23 +01:00
Tom Krizek
dd5f0d2c4c
Tweak dupsigs test output
Use a different visual separator, since "====", "----" and "____" is
used by pytest to separate the log output.

(cherry picked from commit 9593ff9347)
2023-01-16 10:13:53 +01:00
Tom Krizek
8033857295
Look for ifconfig.sh.in in testsock.pl parent dir
Instead of using the current working directory to find the ifconfig.sh
script, look for the ifconfig.sh.in template in the directory where the
testsock.pl script is located. This enables the testsock.pl script to be
called from any working directory.

Using the ifconfig.sh.in template is sufficient, since it contains
the necessary information to be extracted: the max= value (which is
hard-coded in the template).

(cherry picked from commit e24d3b21d0)
2023-01-16 10:13:53 +01:00
Tom Krizek
bcf1f5c808
Factor out script to handle system test core dumps
Move the core dump detection functionality for system test runs into a
separate script. This enables reuse by the pytest runner. The
functionality remains the same.

(cherry picked from commit d9a97200d5)
2023-01-16 10:13:53 +01:00
Tom Krizek
db03296683
testcrypto.sh: run in TMPDIR if possible
Avoid creating any temporary files in the current workdir.

Additional/changing files in the bin/tests/system directory are
problematic for pytest/xdist collection phase, which assumes the list of
files doesn't change between the collection phase of the main pytest
thread and the subsequent collection phase of the xdist worker threads.

Since the testcrypto.sh is also called during pytest initialization
through conf.sh.common (to detect feature support), this could
occasionally cause a race condition when the list of files would be
different for the main pytest thread and the xdist worker.

(cherry picked from commit 61330a7863)
2023-01-16 10:13:51 +01:00