Commit Graph
11337 Commits
Author SHA1 Message Date
Mark Andrews a4c16515de Assert tsigout is non-NULL
(cherry picked from commit 827746e89b)
2020-07-13 13:10:19 +10:00
Mark Andrews d953381d75 check returns from inet_pton()
(cherry picked from commit 9499adeb5e)
2020-07-13 11:45:09 +10:00
Mark Andrews 040eb8f07f Check that handle is non-NULL before dereferencing it 2020-07-13 10:16:47 +10:00
Michał Kępień 25818ac81f Fix locking for LMDB 0.9.26
When "rndc reconfig" is run, named first configures a fresh set of views
and then tears down the old views.  Consider what happens for a single
view with LMDB enabled; "envA" is the pointer to the LMDB environment
used by the original/old version of the view, "envB" is the pointer to
the same LMDB environment used by the new version of that view:

 1. mdb_env_open(envA) is called when the view is first created.
 2. "rndc reconfig" is called.
 3. mdb_env_open(envB) is called for the new instance of the view.
 4. mdb_env_close(envA) is called for the old instance of the view.

This seems to have worked so far.  However, an upstream change [1] in
LMDB which will be part of its 0.9.26 release prevents the above
sequence of calls from working as intended because the locktable mutexes
will now get destroyed by the mdb_env_close() call in step 4 above,
causing any subsequent mdb_txn_begin() calls to fail (because all of the
above steps are happening within a single named process).

Preventing the above scenario from happening would require either
redesigning the way we use LMDB in BIND, which is not something we can
easily backport, or redesigning the way BIND carries out its
reconfiguration process, which would be an even more severe change.

To work around the problem, set MDB_NOLOCK when calling mdb_env_open()
to stop LMDB from controlling concurrent access to the database and do
the necessary locking in named instead.  Reuse the view->new_zone_lock
mutex for this purpose to prevent the need for modifying struct dns_view
(which would necessitate library API version bumps).  Drop use of
MDB_NOTLS as it is made redundant by MDB_NOLOCK: MDB_NOTLS only affects
where LMDB reader locktable slots are stored while MDB_NOLOCK prevents
the reader locktable from being used altogether.

[1] https://git.openldap.org/openldap/openldap/-/commit/2fd44e325195ae81664eb5dc36e7d265927c5ebc

(cherry picked from commit 53120279b5)
2020-07-10 11:31:43 +02:00
Mark Andrews 902c1292c9 Adjust range limit of unknown meta types
(cherry picked from commit 092a159dcd)
2020-07-08 13:42:03 +10:00
Witold KręcickiandOndřej Surý e73702e821 rbtdb: cleanup_dead_nodes should ignore alive nodes on the deadlist
(cherry picked from commit c8f2d55acf)
2020-07-01 15:37:01 +02:00
Evan Hunt 8d52602daf append "0" to IPv6 addresses ending in "::" when printing YAML
such addresses broke some YAML parsers.

(cherry picked from commit a8baf79e33)
2020-06-25 19:35:31 -07:00
Mark Andrews 145b7f0b26 The validator could fail when select_signing_key/get_dst_key failed
to select the signing key because the algorithm was not supported
and the loop was prematurely aborted.

(cherry picked from commit d475f3aeed)
2020-06-25 22:46:41 +10:00
Mark Andrews a878e8d4bc Address potential thread issues:
Assign and then check node for NULL to address another thread
changing radix->head in the meantime.

Move 'node != NULL' check into while loop test to silence cppcheck
false positive.

Fix pointer != NULL style.

(cherry picked from commit 51f08d2095)
2020-06-25 21:18:45 +10:00
Mark AndrewsandOndřej Surý 915d94643f Address race between zone_maintenance and dns_zone_setview_helper
There was a possible NULL dereference due to data race between accessing
zone->view and zone->view->adb.

(cherry picked from commit 67c8f7329d)
2020-06-22 12:28:41 +02:00
Tinderbox UserandMichał Kępień fc8107adca prep 9.11.20 2020-06-18 10:37:47 +02:00
Mark AndrewsandMichał Kępień 90a7416d15 Remove INSIST from from new_reference
RBTDB node can now appear on the deadnodes lists following the changes
to decrement_reference in 4db29f1f7d to
defer checking of node->down when the tree write lock is not held.  The
node should be unlinked instead.

(cherry picked from commit 569cc155b8680d8ed12db1fabbe20947db24a0f9)
2020-06-18 10:37:16 +02:00
Mark Andrews dcf3941f17 Fix #define of activeemptynode for rbtdb64 2020-06-12 11:41:06 +10:00
Witold KręcickiandOndřej Surý b0707ebba0 Fix a data access race in resolver
We were passing client address to dns_resolver_createfetch as a pointer
and it was saved as a pointer. The client (with its address) could be
gone before the fetch is finished, and in a very odd scenario
log_formerr would call isc_sockaddr_format() which first checks if the
address family is valid (and at this point it still is), then the
sockaddr is cleared, and then isc_netaddr_fromsockaddr is called which
fails an assertion as the address family is now invalid.

(cherry picked from commit 175c4d9055)
2020-06-06 07:10:13 +02:00
Mark Andrews 1f1209e1f6 Add +yaml support for EDE
(cherry picked from commit 0ec77c2b92)
2020-06-05 12:10:53 +10:00
Ondřej Surý 7e2d9531a7 Change the invalid CIDR from parser error to warning
In [RT #43367], the BIND 9 changed the strictness of address / prefix
length checks:

    Check prefixes in acls to make sure the address and
    prefix lengths are consistent.  Warn only in
    BIND 9.11 and earlier.

Unfortunately, a regression slipped in and the check was made an error
also in the BIND 9.11.  This commit fixes the regression, but turning
the error into a warning.
2020-06-03 22:17:02 +02:00
Witold KręcickiandOndřej Surý c6ec2aaedc tests: fix isc/socket_test.c teardown
In case of a test failure we weren't tearing down sockets and tasks
properly, causing the test to hang instead of failing nicely.

(cherry picked from commit 4a8d9250cf)
2020-06-03 14:17:16 +02:00
Mark Andrews 20e848bc3b Force promotion to unsigned int then shift the result 2020-05-28 09:59:40 +10:00
Tinderbox UserandMichał Kępień 85a5d7392e prep 9.11.19 2020-05-19 14:25:05 +02:00
Mark AndrewsandMichał Kępień 8b93271edc Count queries to the root and TLD servers as well 2020-05-19 14:24:53 +02:00
Mark AndrewsandMichał Kępień 850ca8498c Reduce the number of fetches we make when looking up addresses
If there are more that 5 NS record for a zone only perform a
maximum of 4 address lookups for all the name servers.  This
limits the amount of remote lookup performed for server
addresses at each level for a given query.
2020-05-19 14:24:53 +02:00
Mark AndrewsandMichał Kępień 086b0e4f1c Only look at tsig.error in responses 2020-05-19 14:24:52 +02:00
Mark Andrews 0339907d19 Also print out valid printable utf8
(cherry picked from commit 1c8f9d06e2)
(cherry picked from commit c13fb2c67f)
2020-05-13 12:18:55 +10:00
Mark Andrews c0d34e8b05 Report Extended DNS Error codes
(cherry picked from commit b144ae1bb0)
(cherry picked from commit eed4fab37b)
2020-05-13 12:18:55 +10:00
Evan Hunt c18dd943da don't bother checking for empty nodes when searching the NSEC3 tree
this avoids a time-wasting search that could occur during an
IXFR that replaced an NSEC3 chain.

(cherry picked from commit 7192edf9c2)
2020-05-12 13:39:03 -07:00
Evan Hunt 1df4141279 initialize sockaddrdscp to prevent spurious output from 'named-checkconf -p'
(cherry picked from commit f8d753d452)
2020-05-06 12:48:13 -07:00
Evan Hunt 7e76da18f2 Fix outstanding cppcheck errors
lib/dns/sdb.c:1145:warning: Either the condition '(sdb)!=((void*)0)' is
redundant or there is possible null pointer dereference: sdb."

lib/dns/sdb.c:1208: Either the condition '(node)!=((void*)0)' is
redundant or there is possible null pointer dereference: sdbnode.
2020-05-04 14:23:23 -07:00
Mark Andrews 48f7566b61 Mimic nzf_append from bin/named/server.c
nzf_append is conditionally compiled and this is intended to
catch error introduced by changes to the called functions on all
systems before the changes are run through the CI.

(cherry picked from commit a66c6fc883)
2020-05-01 10:10:09 +10:00
Mark Andrews 453ec7c3b5 Escape double quote when printing quoted string.
When we were printing quoted string, the double quotes where unescaped
leading to prematurely ending the quoted string.

(cherry picked from commit b02081d423)
2020-05-01 09:15:11 +10:00
Mark Andrews a05a6dedcb Warn about AXFR streams that are incompatible with BIND 9.18
(cherry picked from commit 998b2d5a57)
2020-04-21 09:31:24 +10:00
Michał Kępień 255be080cf Tweak library API versions 2020-04-16 23:10:26 +02:00
Ondřej Surý 5e2d19911f _getcwd() on Windows needs direct.h header
The _getcwd() compatibility function on Microsoft CRT requires direct.h
header to pull a proper function prototype.

The (misleading) warning generated:

  bin\named\server.c(1074): warning C4047: '==': 'int' differs in levels of indirection from 'void *'
2020-04-16 13:13:00 +02:00
Ondřej Surý ebb6165839 Disable C4090 in libisccfg
The MSVC detects mismatch of const qualifiers in cfg_map_{first,next}clause
functions just in BIND 9.11.  As this is harmless in this particular
case, just disable the warning for these two functions.

The warnings reported:

  lib\isccfg\parser.c(2160): warning C4090: '=': different 'const' qualifiers
  lib\isccfg\parser.c(2184): warning C4090: '=': different 'const' qualifiers
2020-04-16 13:01:55 +02:00
Ondřej Surý 7f672ab47d Add default return value in win32 isc_thread_join() 2020-04-16 08:22:40 +02:00
Ondřej Surý 5fd1df8cfa Disable MSB8028 warning
All our MSVS Project files share the same intermediate directory.  We
know that this doesn't cause any problems, so we can just disable the
detection in the project files.

Example of the warning:

  warning MSB8028: The intermediate directory (.\Release\) contains files shared from another project (dnssectool.vcxproj).  This can lead to incorrect clean and rebuild behavior.

(cherry picked from commit b6c2012d93)
2020-04-16 08:12:39 +02:00
Ondřej Surý 90108d479f Don't return from void function
(cherry picked from commit 948a23e6bb)
2020-04-16 08:12:39 +02:00
Ondřej Surý 1eb5a77baa Set WarningLevel to Level1 for Release, treat warnings as errors
Our vcxproj files set the WarningLevel to Level3, which is too verbose
for a code that needs to be portable.  That basically leads to ignoring
all the errors that MSVC produces.  This commits downgrades the
WarningLevel to Level1 and enables treating warnings as errors for
Release builds.  For the Debug builds the WarningLevel got upgraded to
Level4, and treating warnings as errors is explicitly disabled.

We should eventually make the code clean of all MSVC warnings, but it's
a long way to go for Level4, so it's more reasonable to start at Level1.

For reference[1], these are the warning levels as described by MSVC
documentation:

  * /W0 suppresses all warnings. It's equivalent to /w.
  * /W1 displays level 1 (severe) warnings. /W1 is the default setting
    in the command-line compiler.
  * /W2 displays level 1 and level 2 (significant) warnings.
  * /W3 displays level 1, level 2, and level 3 (production quality)
    warnings. /W3 is the default setting in the IDE.
  * /W4 displays level 1, level 2, and level 3 warnings, and all level 4
    (informational) warnings that aren't off by default. We recommend
    that you use this option to provide lint-like warnings. For a new
    project, it may be best to use /W4 in all compilations. This option
    helps ensure the fewest possible hard-to-find code defects.
  * /Wall displays all warnings displayed by /W4 and all other warnings
    that /W4 doesn't include — for example, warnings that are off by
    default.
  * /WX treats all compiler warnings as errors. For a new project, it
    may be best to use /WX in all compilations; resolving all warnings
    ensures the fewest possible hard-to-find code defects.

1. https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=vs-2019

(cherry picked from commit 789d253e3d)
2020-04-16 08:12:39 +02:00
Diego FronzaandOndřej Surý 8beba5ee09 Fixed rebinding protection bug when using forwarder setups
BIND wasn't honoring option "deny-answer-aliases" when configured to
forward queries.

Before the fix it was possible for nameservers listed in "forwarders"
option to return CNAME answers pointing to unrelated domains of the
original query, which could be used as a vector for rebinding attacks.

The fix ensures that BIND apply filters even if configured as a forwarder
instance.
2020-04-08 09:21:03 +02:00
Ondřej Surý ff814288af Fix 'Dead nested assignment' from scan-build-10
This is the warning:

In file included from print_test.c:47:
./../print.c:203:9: warning: Although the value stored to 'neg' is used in the enclosing expression, the value is never actually read from 'neg'
                dot = neg = space = plus = left = zero = alt = h = l = q = z = 0;
                      ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
2020-03-26 13:52:28 +01:00
Ondřej Surý 138dded9d9 Fix 'Dead nested assignment's from scan-build-10
The 3 warnings reported are:

os.c:872:7: warning: Although the value stored to 'ptr' is used in the enclosing expression, the value is never actually read from 'ptr'
        if ((ptr = strtok_r(command, " \t", &last)) == NULL) {
             ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

--

rpz.c:1117:10: warning: Although the value stored to 'zbits' is used in the enclosing expression, the value is never actually read from 'zbits'
        return (zbits &= x);
                ^        ~
1 warning generated.

--

openssleddsa_link.c:532:10: warning: Although the value stored to 'err' is used in the enclosing expression, the value is never actually read from 'err'
        while ((err = ERR_get_error()) != 0) {
                ^     ~~~~~~~~~~~~~~~
1 warning generated.

(cherry picked from commit 262f087bcf)
2020-03-25 18:08:12 +01:00
Tinderbox UserandMatthijs Mekking 4236979e90 Adjust lib/isc/api version
The libisc LIBINTERFACE bump for 9.11.17 is unnecessary.
A lot of headers were altered but the ABI tool did not report anything.
Trust the ABI tool on this and decrement LIBINTERFACE and increment
LIBREVISION.
2020-03-20 10:32:32 +01:00
Tinderbox UserandMatthijs Mekking d050ec2429 prep 9.11.17
Bumped the version file and added release line in CHANGES.

API files:
- lib/bind9/api:
  No changes because only changes in comments.
- lib/dns/api:
  Increment LIBINTERFACE because of the added field structure in
  dns_struct_update.
- lib/isc/api:
  Increment LIBINTERFACE because of the PKCS#11 replacement.
- lib/isccc/api:
  No changes because no source code changes.
- lib/isccfg/api:
  Increment LIBREVISION because of minor source code changes.
- lib/lwres/api:
  No changes because no source code changes.

I decided no changes to README.md or the release notes were necessary.

Perflab graphs look sane.
2020-03-20 10:31:29 +01:00
Mark Andrews 0ddfa675e4 Just return tv_sec field 2020-03-18 06:36:10 +00:00
Ondřej SurýandEvan Hunt 5ae4d3d94a Add C11 localtime_r and gmtime_r shims for Windows
On Windows, C11 localtime_r() and gmtime_r() functions are not
available.  While localtime() and gmtime() functions are already thread
safe because they use Thread Local Storage, it's quite ugly to #ifdef
around every localtime_r() and gmtime_r() usage to make the usage also
thread-safe on POSIX platforms.

The commit adds wrappers around Windows localtime_s() and gmtime_s()
functions.

NOTE: The implementation of localtime_s and gmtime_s in Microsoft CRT
are incompatible with the C standard since it has reversed parameter
order and errno_t return type.

(cherry picked from commit 08f4c7d6c0)
2020-03-17 15:45:35 -07:00
Evan Hunt bdb8e3ad85 silence a warning about unsafe snprintf() call
(cherry picked from commit ec95b84e8d)
2020-03-17 15:42:14 -07:00
Evan Hunt c16c095b32 replace unsafe ctime() and gmtime() function calls
This silences LGTM warnings that these functions are not thread-safe.

(cherry picked from commit 5703f70427)
2020-03-17 15:39:08 -07:00
Evan Hunt beaca3e8db remove or comment empty conditional branches
some empty conditional branches which contained a semicolon were
"fixed" by clang-format to contain nothing. add comments to prevent this.

(cherry picked from commit 735be3b816)
2020-03-17 15:39:03 -07:00
Evan Hunt 1dbd238c15 fix a pointer-to-int cast error
(cherry picked from commit 6b76646037)
2020-03-17 13:16:07 -07:00
Mark Andrews f438d7f0e6 Add MAXMINDDB_CFLAGS to CINCLUDES
(cherry picked from commit 81a80274bd)
2020-03-16 18:53:20 +11:00
Mark Andrews e62b2b2933 Silence missing unlock from Coverity.
Save 'i' to 'locknum' and use that rather than using
'header->node->locknum' when performing the deferred
unlock as 'header->node->locknum' can theoretically be
different to 'i'.

(cherry picked from commit 8dd8d48c9f)
2020-03-13 13:37:04 +11:00