Commit Graph

36048 Commits

Author SHA1 Message Date
Matthijs Mekking
58690ec11c Warn if multiple keys have same role
If a dnssec-policy has multiple keys configured with the
same algorithm and role.

(cherry picked from commit f54dad005e)
2022-05-31 17:16:29 +02:00
Matthijs Mekking
125cad030b Merge branch '3341-servestale-extendederrors-test-failure-v9_18' into 'v9_18'
[v9_18] Tweak timings in serve-stale system test

See merge request isc-projects/bind9!6350
2022-05-31 14:27:39 +00:00
Matthijs Mekking
659804eab0 Tweak timings in serve-stale system test
Give a little bit more time if we wait on a time out from the
authoritative (aka resolver failure), and give up after one try
(because the second attempt will likely result in a different EDE).

(cherry picked from commit f764cee136)
2022-05-31 13:51:51 +00:00
Ondřej Surý
178442f735 Merge branch 'ondrej-unit-tests-refactoring-v9_18' into 'v9_18'
Give the unit tests a big overhaul [v9.18]

See merge request isc-projects/bind9!6366
2022-05-31 10:31:58 +00:00
Ondřej Surý
45584af257 Add CHANGES note for [GL !6243]
(cherry picked from commit cd1f9c3d36)
2022-05-31 12:06:00 +02:00
Evan Hunt
a0bf5ab2c5 Exclude unit tests from gcov
Modify the .gitlab-ci.yml to match the previous lib/.*/tests/.* pattern
for excluding the unit tests from the gcov.

(cherry picked from commit 2321cab4ee)
2022-05-31 12:06:00 +02:00
Evan Hunt
a67ba6e0b9 Stop the unit tests from running twice
Move the libtest code into a 'libtest' subdirectory and make it
one of the SUBDIRS in the tests Makefile. having it at the top level
required having "." as one of the subdirs, and that caused the
unit tests to be executed twice.

(cherry picked from commit 568f65cc56)
2022-05-31 12:06:00 +02:00
Ondřej Surý
f128a9bcf2 Move all the unit tests to /tests/<libname>/
The unit tests are now using a common base, which means that
lib/dns/tests/ code now has to include lib/isc/include/isc/test.h and
link with lib/isc/test.c and lib/ns/tests has to include both libisc and
libdns parts.

Instead of cross-linking code between the directories, move the
/lib/<foo>/test.c to /tests/<foo>.c and /lib/<foo>/include/<foo>test.h
to /tests/include/tests/<foo>.h and create a single libtest.la
convenience library in /tests/.

At the same time, move the /lib/<foo>/tests/ to /tests/<foo>/ (but keep
it symlinked to the old location) and adjust paths accordingly.  In few
places, we are now using absolute paths instead of relative paths,
because the directory level has changed.  By moving the directories
under the /tests/ directory, the test-related code is kept in a single
place and we can avoid referencing files between libns->libdns->libisc
which is unhealthy because they live in a separate Makefile-space.

In the future, the /bin/tests/ should be merged to /tests/ and symlink
kept, and the /fuzz/ directory moved to /tests/fuzz/.

(cherry picked from commit 2c3b2dabe9)
2022-05-31 12:06:00 +02:00
Ondřej Surý
f0df0d679a Give the unit tests a big overhaul
The unit tests contain a lot of duplicated code and here's an attempt
to reduce code duplication.

This commit does several things:

1. Remove #ifdef HAVE_CMOCKA - we already solve this with automake
   conditionals.

2. Create a set of ISC_TEST_* and ISC_*_TEST_ macros to wrap the test
   implementations, test lists, and the main test routine, so we don't
   have to repeat this all over again.  The macros were modeled after
   libuv test suite but adapted to cmocka as the test driver.

   A simple example of a unit test would be:

    ISC_RUN_TEST_IMPL(test1) { assert_true(true); }

    ISC_TEST_LIST_START
    ISC_TEST_ENTRY(test1)
    ISC_TEST_LIST_END

    ISC_TEST_MAIN (Discussion: Should this be ISC_TEST_RUN ?)

   For more complicated examples including group setup and teardown
   functions, and per-test setup and teardown functions.

3. The macros prefix the test functions and cmocka entries, so the name
   of the test can now match the tested function name, and we don't have
   to append `_test` because `run_test_` is automatically prepended to
   the main test function, and `setup_test_` and `teardown_test_` is
   prepended to setup and teardown function.

4. Update all the unit tests to use the new syntax and fix a few bits
   here and there.

5. In the future, we can separate the test declarations and test
   implementations which are going to greatly help with uncluttering the
   bigger unit tests like doh_test and netmgr_test, because the test
   implementations are not declared static (see `ISC_RUN_TEST_DECLARE`
   and `ISC_RUN_TEST_IMPL` for more details.

NOTE: This heavily relies on preprocessor macros, but the result greatly
outweighs all the negatives of using the macros.  There's less
duplicated code, the tests are more uniform and the implementation can
be more flexible.

(cherry picked from commit 63fe9312ff)
2022-05-31 11:34:54 +02:00
Ondřej Surý
5e9c9e3539 Merge branch '2801-unittest-isc-netmgr-s390x-v9_18' into 'v9_18'
Fix failures in isc netmgr_test on big endian machines

See merge request isc-projects/bind9!6353
2022-05-24 18:28:09 +00:00
Petr Menšík
d074386ef1 Fix failures in isc netmgr_test on big endian machines
Typing from libuv structure to isc_region_t is not possible, because
their sizes differ on 64 bit architectures. Little endian machines seems
to be lucky and still result in test passed. But big endian machine such
as s390x fails the test reliably.

Fix by directly creating the buffer as isc_region_t and skipping the
type conversion. More readable and still more correct.

(cherry picked from commit 057438cb45)
2022-05-24 20:22:57 +02:00
Tony Finch
44c4ff2d2d Merge branch '3361-dnssec-settime-unset-v9_18' into 'v9_18'
Teach dnssec-settime to read unset times that it writes (backport to v9.18)

See merge request isc-projects/bind9!6349
2022-05-23 14:01:23 +00:00
Tony Finch
84113b237a Teach dnssec-settime to read unset times that it writes
When there is no time in a key file, `dnssec-settime` will print
"UNSET", but to unset a time the user must specify "none" or "never".
This change allows "unset" or "UNSET" as well as "none" or "never".
The "UNSET" output remains the same to avoid compatibility problems
with wrapper scripts.

I have also re-synchronized the "Timing Options" sections of the man
pages.

(cherry picked from commit 4c96efac5c)
2022-05-23 15:15:10 +02:00
Tony Finch
0486bdeae3 Merge branch 'u/fanf2/dnssec-settime-ctime-v9_18' into 'v9_18'
Teach dnssec-settime to read times that it writes

See merge request isc-projects/bind9!6324
2022-05-23 12:58:50 +00:00
Tony Finch
fa5d44becf Add CHANGES note for [GL !6324]
(cherry picked from commit fcca62859d)
2022-05-23 13:46:07 +02:00
Tony Finch
f84cd02b0c Teach dnssec-settime to read times that it writes
The dnssec-settime -p and -up options print times in asctime() and
UNIX time_t formats, respectively. The asctime() format can also be
found inside K*.key public key files. Key files also contain times in
the YYYYMMDDHHMMSS format that can be used in timing parameter
options.

The dnssec-settime -p and -up time formats are now acceptable in
timing parameter options to dnssec-settime and dnssec-keygen, so it is
no longer necessary to parse key files to retrieve times that are
acceptable in timing parameter options.

(cherry picked from commit c38a323082)
2022-05-23 13:44:50 +02:00
Matthijs Mekking
1b15ff89b5 Merge branch '3354-cid-352776-missing_lock-v9_18' into 'v9_18'
[v9_18] Fix CID 352776: Concurrent data access violations

See merge request isc-projects/bind9!6344
2022-05-23 10:39:43 +00:00
Matthijs Mekking
0ae48af8b2 Require valid key for dst_key functions
Make sure that the key structure is valid when calling the following
functions:
- dst_key_setexternal
- dst_key_isexternal
- dst_key_setmodified
- dst_key_ismodified

(cherry picked from commit 888ec4e0d4)
2022-05-23 12:00:53 +02:00
Matthijs Mekking
ca7e3e25c4 Fix CID 352776: Concurrent data access violations
*** CID 352776:  Concurrent data access violations  (MISSING_LOCK)
/lib/dns/dst_api.c: 474 in dst_key_setmodified()
468     dst_key_isexternal(dst_key_t *key) {
469		return (key->external);
470     }
471
472     void
473     dst_key_setmodified(dst_key_t *key, bool value) {
>>>     CID 352776:  Concurrent data access violations  (MISSING_LOCK)
>>>     Accessing "key->modified" without holding lock
>>>	"dst_key.mdlock". Elsewhere, "dst_key.modified" is accessed with
>>>	"dst_key.mdlock" held 8 out of 11 times (8 of these accesses
>>>	strongly imply that it is necessary).
474		key->modified = value;
475     }
476
477     bool
478     dst_key_ismodified(dst_key_t *key) {
479		return (key->modified);

(cherry picked from commit 1fa24d0afb)
2022-05-23 12:00:45 +02:00
Ondřej Surý
18881c15aa Merge branch '3344-threadsanitizer-data-race-in-isc__nm_tcpdns_send-v9_18' into 'v9_18'
Move setting the sock->write_timeout to the async_*send [v9.18]

See merge request isc-projects/bind9!6341
2022-05-19 20:53:11 +00:00
Ondřej Surý
eabee4d7d9 Move setting the sock->write_timeout to the async_*send
Setting the sock->write_timeout from the TCP, TCPDNS, and TLSDNS send
functions could lead to (harmless) data race when setting the value for
the first time when the isc_nm_send() function would be called from
thread not-matching the socket we are sending to.  Move the setting the
sock->write_timeout to the matching async function which is always
called from the matching thread.

(cherry picked from commit 61117840c1)
2022-05-19 22:37:52 +02:00
Ondřej Surý
acfec1bff0 Merge branch '3371-check-for-__attribute__-fallthrough-support-is-sometimes-incorrect-v9_18' into 'v9_18'
Use C2x [[fallthrough]] when supported by LLVM/clang [v9.18]

See merge request isc-projects/bind9!6339
2022-05-19 20:34:20 +00:00
Ondřej Surý
b4521486ed Use C2x [[fallthrough]] when supported by LLVM/clang
Clang added support for the gcc-style fallthrough
attribute (i.e. __attribute__((fallthrough))) in version 10.  However,
__has_attribute(fallthrough) will return 1 in C mode in older versions,
even though they only support the C++11 fallthrough attribute. At best,
the unsupported attribute is simply ignored; at worst, it causes errors.

The C2x fallthrough attribute has the advantages of being supported in
the broadest range of clang versions (added in version 9) and being easy
to check for support. Use C2x [[fallthrough]] attribute if possible, and
fall back to not using an attribute for clang versions that don't have
it.

Courtesy of Joshua Root

(cherry picked from commit 14c8d43863)
2022-05-19 22:01:59 +02:00
Michal Nowak
4dde80f655 Merge tag 'v9_18_3' into v9_18
BIND 9.18.3
2022-05-19 12:07:45 +02:00
Evan Hunt
c00545a168 Merge branch '3350-rndc-dnssec-checkds-doc-v9_18' into 'v9_18'
specify time format in the documentation for 'rdnc dnssec -checkds'

See merge request isc-projects/bind9!6331
2022-05-18 22:37:35 +00:00
Evan Hunt
dfe196844c specify time format in the documentation for 'rdnc dnssec -checkds'
also clarified the writing in the surrounding paragraph.

(cherry picked from commit 83f9466d61)
2022-05-18 15:30:18 -07:00
Ondřej Surý
98e13fbc09 Merge branch '3366-configure-fails-to-find-uv-h-on-bsd-v9_18' into 'v9_18'
Use libuv CFLAGS and LIBS when checking for features [v9.18]

See merge request isc-projects/bind9!6329
2022-05-18 20:01:50 +00:00
Ondřej Surý
a50231adc1 Use libuv CFLAGS and LIBS when checking for features
When autoconf was checking for libuv features, the LIBUV_CFLAGS was not
added to CFLAGS and LIBUV_LIBS to LIBS which resulted in false
negatives.

Use AX_SAVE_FLAGS and AX_RESTORE_FLAGS to temporarily add LIBUV_CFLAGS
and LIBUV_LIBS to their respective variables.

(cherry picked from commit f063ee276e)
2022-05-18 21:22:03 +02:00
Michal Nowak
48012449de Merge branch 'mnowak/fix-typo-in-ednscompliance-test-v9_18' into 'v9_18'
[v9_18] Fix typo in ednscompliance test

See merge request isc-projects/bind9!6327
2022-05-18 17:19:23 +00:00
Michal Nowak
9c8fdec57b Fix typo in ednscompliance test
Caused by ba0313e649, an incomplete fix of
spelling errors.

(cherry picked from commit 9de2c06a21)
2022-05-18 19:16:43 +02:00
Mark Andrews
d7fd8faa57 Merge branch '3356-wrong-path-for-geoip-directory-v9_18' into 'v9_18'
Remove extraneous '$' in AS_VAR_COPY([MAXMINDDB_PREFIX], [with_maxminddb])

See merge request isc-projects/bind9!6318
2022-05-17 19:34:40 +00:00
Mark Andrews
d6b07d2787 Remove extraneous '$' in AS_VAR_COPY([MAXMINDDB_PREFIX], [with_maxminddb])
(cherry picked from commit 686d691fa9)
2022-05-18 05:03:05 +10:00
Matthijs Mekking
d4d516ca89 Merge branch '3352-kasp-test-broken-on-freebsd-v9_18' into 'v9_18'
[v9_18] Fix "kasp test broken on freebsd"

See merge request isc-projects/bind9!6312
2022-05-16 16:38:55 +00:00
Matthijs Mekking
646e00fbb2 Replace stat with PERL stat in kasp system test
7249bad7 introduced the -c option to stat(1) command, but BSD systems
do not know about it. Replace the stat(1) command with a PERL script
that achieves the same.

Why PERL? For consistency purposes, there are more places in the
system test where we use the same method.

(cherry picked from commit fe601c5915)
2022-05-16 18:02:38 +02:00
Matthijs Mekking
b777649fda Merge branch '3302-keymgr-updates-key-files-each-run-v9_18' into 'v9_18'
[v9_18] Fix "keymgr updates key files each run"

See merge request isc-projects/bind9!6300
2022-05-16 15:36:50 +00:00
Matthijs Mekking
7cfc5e51ed Add changes and release notes for #3302
Add a comment to make danger happy.

(cherry picked from commit 0f89f0b134)
2022-05-16 10:37:39 +02:00
Matthijs Mekking
9b6a20b42e Check if key metadata is modified before writing
Add a new parameter to the dst_key structure, mark a key modified if
dst_key_(un)set[bool,num,state,time] is called. Only write out key
files during a keymgr run if the metadata has changed.

(cherry picked from commit 1da91b3ab4)
2022-05-16 10:37:23 +02:00
Matthijs Mekking
90ceb24b1c Add kasp test for #3302
Add a test case that triggers a keymgr run that will not trigger any
metadata changes. Ensure that the last status change of the key files
is unmodified.

(cherry picked from commit 7249bad706)
2022-05-16 10:37:23 +02:00
Evan Hunt
c77fcc61eb Merge branch '3327-fetches-per-server-quota-v9_18' into 'v9_18'
fix the fetches-per-server quota calculation

See merge request isc-projects/bind9!6307
2022-05-14 08:29:03 +00:00
Evan Hunt
ef963cf5e4 Add CHANGES note for [GL #3327]
(cherry picked from commit 3f478a3bed)
2022-05-14 00:59:12 -07:00
Evan Hunt
37bd035d39 Add lower bound checks to fetchlimit test
Check that the recursing client count is above a reasonable
minimum, as well as below a maximum, so that we can detect
bugs that cause recursion to fail too early or too often.

(cherry picked from commit 8834c44683)
2022-05-14 00:59:12 -07:00
Evan Hunt
60e25826c6 Cleanup: always count ns_statscounter_recursclients
The ns_statscounter_recursclients counter was previously only
incremented or decremented if client->recursionquota was non-NULL.
This was harmless, because that value should always be non-NULL if
recursion is enabled, but it made the code slightly confusing.

(cherry picked from commit 0201eab655)
2022-05-14 00:59:09 -07:00
Evan Hunt
fa8b33ce56 Disable EDNS for the fetchlimit test server
The fetchlimit test depends on a resolver continuing to try UDP
and timing out while the client waits for resolution to succeed.
but since commit bb990030 (flag day 2020), a fetch will always
switch to TCP after two timeouts, unless EDNS was disabled for
the query.

This commit adds "edns no;" to server statements in the fetchlimit
resolver, to restore the behavior expected by the test.

(cherry picked from commit 81deb24deb)
2022-05-14 00:43:17 -07:00
Evan Hunt
bca7f19541 Fix the fetches-per-server quota calculation
Since commit bad5a523c2, when the fetches-per-server quota
was increased or decreased, instead of the value being set to
the newly calculated quota, it was set to the *minimum* of
the new quota or 1 - which effectively meant it was always set to 1.
it should instead have been the maximum, to prevent the value from
ever dropping to zero.

(cherry picked from commit 694bc50273)
2022-05-14 00:43:17 -07:00
Evan Hunt
eaf5745554 Merge branch '3351-checkconf-overflow-v9_18' into 'v9_18'
prevent a possible buffer overflow in configuration check

See merge request isc-projects/bind9!6304
2022-05-14 03:49:45 +00:00
Evan Hunt
e117244850 prevent a possible buffer overflow in configuration check
corrected code that could have allowed a buffer overfow while
parsing named.conf.

(cherry picked from commit 921043b541)
2022-05-13 20:29:36 -07:00
Ondřej Surý
57f50fcd13 Merge branch 'ondrej-fix-trampoline-locking-v9_18' into 'v9_18'
Lock the trampoline when attaching [v9.18]

See merge request isc-projects/bind9!6298
2022-05-13 12:05:47 +00:00
Ondřej Surý
71b0e9e5b7 Lock the trampoline when attaching
When attaching to the trampoline, the isc__trampoline_max was access
unlocked.  This would not manifest under normal circumstances because we
initialize 65 trampolines by default and that's enough for most
commodity hardware, but there are ARM machines with 128+ cores where
this would be reported by ThreadSanitizer.

Add locking around the code in isc__trampoline_attach().  This also
requires the lock to leak on exit (along with memory that we already)
because a new thread might be attaching to the trampoline while we are
running the library destructor at the same time.

(cherry picked from commit 933162ae14)
2022-05-13 13:21:49 +02:00
Matthijs Mekking
9eb02cc50a Merge branch '3335-confusing-parental-source-documentation-v9_18' into 'v9_18'
[v9_18] Remove confusing parental-source line

See merge request isc-projects/bind9!6286
2022-05-11 15:06:50 +00:00
Matthijs Mekking
4dbfa40e95 Remove confusing parental-source line
Remove the line "This address must appear in the secondary server’s
parental-agents zone clause". This line is a copy paste error from
notify-source.

Rewrap.

(cherry picked from commit 313f606692)
2022-05-11 15:02:58 +00:00