Commit graph

11077 commits

Author SHA1 Message Date
Ondřej Surý
fcd1569e2b Turn (int & flag) into (int & flag) != 0 when implicitly typed to bool
(cherry picked from commit b2b43fd235)
2018-11-08 14:37:14 +07:00
Ondřej Surý
b222783ae9 Add small tweaks to the code to fix compilation when ISC assertions are disabled
While implementing the new unit testing framework cmocka, it was found that the
BIND 9 code doesn't compile when assertions are disabled or replaced with any
function (such as mock_assert() from cmocka unit testing framework) that's not
directly recognized as assertion by the compiler.

This made the compiler to complain about blocks of code that was recognized as
unreachable before, but now it isn't.

The changes in this commit include:

* assigns default values to couple of local variables,
* moves some return statements around INSIST assertions,
* adds __builtin_unreachable(); annotations after some INSIST assertions,
* fixes one broken assertion (= instead of ==)

(cherry picked from commit fbd2e47f51)
2018-11-08 14:05:23 +07:00
Mark Andrews
5d1244a831 check requireservercookie even if rrl is configured
(cherry picked from commit d6f6eeda9d)
2018-11-06 10:20:43 +11:00
Evan Hunt
d99a9db93a silence warning from missing print.h
(cherry picked from commit a0de6707c0)
2018-10-30 08:09:28 -07:00
Michał Kępień
a21c1aacdf Fix isc_buffer_copyregion() for auto-reallocated buffers
While isc_buffer_copyregion() calls isc_buffer_reserve() to ensure the
target buffer will have enough available space to append the contents of
the source region to it, the variables used for subsequently checking
available space are not updated accordingly after that call.  This
prevents isc_buffer_copyregion() from working as expected for
auto-reallocated buffers: ISC_R_NOSPACE will be returned if enough space
is not already available in the target buffer before it is reallocated.
Fix by calling isc_buffer_used() and isc_buffer_availablelength()
directly instead of assigning their return values to local variables.

(cherry picked from commit e1f0aed034)
2018-10-30 13:33:42 +01:00
Michał Kępień
72caf33ffb Add unit tests for isc_buffer_copyregion()
Add some basic checks for isc_buffer_copyregion() to ensure it behaves
as expected for both fixed-size buffers and buffers which can be
automatically reallocated.  Adjust the list of headers included by
lib/isc/tests/buffer_test.c so that it matches what that test program
really uses.

(cherry picked from commit 15440d8027)
2018-10-30 13:33:42 +01:00
Witold Kręcicki
c209bb1400 <stdlib.h> include in rpz.c for strtoul
(cherry picked from commit 8283cbabdc)
2018-10-30 06:51:47 +00:00
Michał Kępień
7258535655 Release all resources when shutting down an RPZ zone during an update
If an RPZ zone is to be freed during an update, canceling the
update_quantum() event is not enough because the resources released when
an update completes also need to be accounted for.  Failure to do this
results in a hang upon shutdown.  Fix by copying cleanup code from the
end of update_quantum() to rpz_detach().

(cherry picked from commit 139bc2c6ab)
2018-10-30 06:51:47 +00:00
Witold Kręcicki
384b3ef596 Fix a race in RPZ with min-update-interval set to 0
If another RPZ update is pending when processing the previous one nears
completion and min-update-interval is set to 0, isc_timer_reset() gets
called with 'interval' set to 0, which triggers an assertion failure.
To prevent such a scenario from causing a crash, queue the update event
directly instead of asking the timer thread to do it.

(cherry picked from commit faf2c7711a)
2018-10-30 06:51:40 +00:00
Mark Andrews
7074cbdacd compare_nxt compared records with identical next fields case insensitively
(cherry picked from commit cf83016682)
2018-10-30 15:09:45 +11:00
Mark Andrews
bc53e5e5d4 move declaration of pending 2018-10-30 11:51:38 +11:00
Mark Andrews
d09955736a document eol
(cherry picked from commit 97a680e5ce)
2018-10-30 11:16:49 +11:00
Mark Andrews
dce7bb3f82 Record types which support a empty rdata field were not handling the empty rdata field case.
(cherry picked from commit 2ff57d8a39)
2018-10-30 11:16:43 +11:00
Evan Hunt
aa797579ef allow unquoted response-policy zone names
(cherry picked from commit 507230aa88)
2018-10-29 09:59:44 -07:00
Mark Andrews
18e7934959 always call RUNTIME_CHECK(result == ISC_R_SUCCESS); for dns_rdata_tostruct
(cherry picked from commit e11cfafff2)
2018-10-29 18:25:57 +11:00
Mark Andrews
7ccca052c0 Only set IPV6_USE_MIN_MTU on IPv6.
(cherry picked from commit 561b780ba0)
2018-10-29 17:28:57 +11:00
Mark Andrews
c8276a29e6 Initalize TZ environment variable before calling dns_test_begin in dnstap_test.
(cherry picked from commit 1cf1254051)
2018-10-29 16:35:06 +11:00
Mark Andrews
b4b006a686 Add support for EID and NIMLOC
(cherry picked from commit fbab100426)
2018-10-25 15:30:58 -07:00
Mark Andrews
f569c8ad26 GID, UID and UINFO could not be loaded using unknown record format.
(cherry picked from commit eb7ca65b78)
2018-10-25 13:34:49 -07:00
Michał Kępień
7b9a5ed7d5 Fix the configuration type used by the "server-addresses" option
Contrary to what the documentation states, the "server-addresses"
static-stub zone option does not accept custom port numbers.  Fix the
configuration type used by the "server-addresses" option to ensure
documentation matches source code.  Remove a check_zoneconf() test which
is unnecessary with this fix in place.

(cherry picked from commit b324576858)
2018-10-25 08:58:56 +02:00
Mark Andrews
f6515be8f6 Add support for ATMA
(cherry picked from commit f9ceddd8ca)
2018-10-25 14:08:42 +11:00
Mark Andrews
7f07a0bb5d expand the pool then copy over the old entries so we that failures do not break the old pool; also don't leak the new pool on error
(cherry picked from commit afde30fe9b)
2018-10-25 13:20:03 +11:00
Mark Andrews
e388288322 free key on error
(cherry picked from commit 607c2d7441)
2018-10-24 11:57:46 +11:00
Michał Kępień
97c7021e24 libirs: handle scoped IPv6 addresses in /etc/resolv.conf
Commonly used network configuration tools write scoped IPv6 nameserver
addresses to /etc/resolv.conf.  libirs only handles these when it is
compiled with -DIRS_HAVE_SIN6_SCOPE_ID, which is not the default, and
only handles numeric scopes, which is not what network configuration
tools typically use.  This causes dig to be practically unable to handle
scoped IPv6 nameserver addresses in /etc/resolv.conf.

Fix the problem by:

  - not requiring a custom compile-time flag to be set in order for
    scoped IPv6 addresses to be processed by getaddrinfo(),

  - parsing non-numeric scope identifiers using if_nametoindex(),

  - setting the sin6_scope_id field in struct sockaddr_in6 structures
    returned by getaddrinfo() even if the AI_CANONNAME flag is not set.

(cherry picked from commit 76d49c05be)
2018-10-23 14:54:07 +02:00
Witold Kręcicki
886cc5f64d Set result to SERVFAIL if upstream responded with FORMERR
Commit 2bc4c92ed4 causes the resolver to
respond to a client query with FORMERR when all upstream queries sent to
the servers authoritative for QNAME elicit FORMERR responses.  This
happens because resolver code returns DNS_R_FORMERR in such a case and
dns_result_torcode() acts as a pass-through for all arguments which are
already a valid RCODE.

The correct RCODE to set in the response returned to the client in the
case described above is SERVFAIL.  Make sure this happens by overriding
the RCODE in query_gotanswer(), on the grounds that any format errors in
the client query itself should be caught long before execution reaches
that point.  This change should not reduce query error logging accuracy
as the resolver code itself reports the exact reason for returning a
DNS_R_FORMERR result using log_formerr().

(cherry picked from commit b5c9a8caad)
2018-10-23 14:00:12 +02:00
Ondřej Surý
a5116a777c Fix missing enable_fips_mode merged in wrong place 2018-10-22 21:34:16 +02:00
Ondřej Surý
38777de529 Add support for enabling and enforcing FIPS mode in OpenSSL:
* Add configure option --enable-fips-mode that detects and enables FIPS mode
* Add a function to enable FIPS mode and call it on crypto init
* Log an OpenSSL error when FIPS_mode_set() fails and exit
* Report FIPS mode status in a separate log message from named

(cherry picked from commit c4cee27f9b)
2018-10-22 21:28:34 +02:00
Michał Kępień
2bc4c92ed4 Do not set qctx->result to DNS_R_SERVFAIL unless necessary
In some cases, setting qctx->result to DNS_R_SERVFAIL causes the value
of a 'result' variable containing a more specific failure reason to be
effectively discarded.  This may cause certain query error log messages
to lack specificity despite a more accurate problem cause being
determined during query processing.

In other cases, qctx->result is set to DNS_R_SERVFAIL even though a more
specific error (e.g. ISC_R_NOMEMORY) could be explicitly indicated.

Since the response message's RCODE is derived from qctx->result using
dns_result_torcode(), which handles a number of possible isc_result_t
values and returns SERVFAIL for anything not explicitly listed, it is
fine to set qctx->result to something more specific than DNS_R_SERVFAIL
(in fact, this is already being done in a few cases).  Modify most
QUERY_ERROR() calls so that qctx->result is set to a more specific error
code when possible.  Adjust query_error() so that statistics are still
calculated properly.  Remove the RECURSE_ERROR() macro which was
introduced exactly because qctx->result could be set to DNS_R_SERVFAIL
instead of DNS_R_DUPLICATE or DNS_R_DROP, which need special handling.
Modify dns_sdlz_putrr() so that it returns DNS_R_SERVFAIL when a DLZ
driver returns invalid RDATA, in order to prevent setting RCODE to
FORMERR (which is what dns_result_torcode() translates e.g. DNS_R_SYNTAX
to) while responding authoritatively.

(cherry picked from commit ba91243542)
2018-10-08 12:50:14 +02:00
Michał Kępień
3d0cde3fe8 Remove the 'want_stale' field from struct query_ctx
As the previous commit makes the 'want_stale' field of struct query_ctx
redundant, remove it.

(cherry picked from commit b3cd868c4b)
2018-10-08 12:50:14 +02:00
Michał Kępień
6736b08c13 Set up stale response lookup before query_done() is called
When something goes wrong while recursing for an answer to a query,
query_gotanswer() sets a flag (qctx->want_stale) in the query context.
query_done() is subsequently called and it can either set up a stale
response lookup (if serve-stale is enabled) or conclude that a SERVFAIL
response should be sent.  This may cause confusion when looking at query
error logs since the QUERY_ERROR() line responsible for setting the
response's RCODE to SERVFAIL is not in a catch-all branch of a switch
statement inside query_gotanswer() (like it is for authoritative
responses) but rather in a code branch which appears to have something
to do with serve-stale, even when the latter is not enabled.

Extract the part of query_done() responsible for checking serve-stale
configuration and optionally setting up a stale response lookup into a
separate function, query_usestale(), shifting the responsibility for
setting the response's RCODE to SERVFAIL to the same QUERY_ERROR() line
in query_gotanswer() which is evaluated for authoritative responses.

(cherry picked from commit cb48d410d8)
2018-10-08 12:50:14 +02:00
Tony Finch
b895e7eaaf Fix crash at shutdown during an RPZ reload. [RT #46210]
(cherry picked from commit 7a2b0ac92a)
2018-10-05 11:12:17 -07:00
Evan Hunt
d67b5cd65b make update_log() work if zone is not set
- update_log() is called to log update errors, but if those errors
  occur before the zone is set (for example, when returning NOTAUTH)
  it returns without logging anything.

(cherry picked from commit 395f6a1474)
2018-10-03 02:39:02 -04:00
Thomas Jach
b39bd2816e Couple additional Windows build fixes in VCX files
(cherry picked from commit f2d6b1b859)
2018-10-02 13:37:03 -04:00
Mark Andrews
90fdf40bda improve case presevation
(cherry picked from commit 0fc1b1bffa)
2018-10-02 15:21:22 +10:00
Tinderbox User
7f5e4faed8 prep 9.12.3rc1 2018-09-29 04:21:11 +00:00
Evan Hunt
6452c017f5 fix chaosnet address comparison
(cherry picked from commit b4dca44ad2)
2018-09-28 08:58:45 -07:00
Tony Finch
98f9c5fb26 RPZ now treats covering NSEC records the same as negative answers
(cherry picked from commit 9407d9e266)
2018-09-27 15:22:43 -07:00
Mark Andrews
3992a37c06 only emit a single space between mac length and the orginal id if the mac length is zero
(cherry picked from commit ac1c3aaa27)
2018-09-27 14:28:47 -07:00
Zhaolong Zhang
811c5ebf92 Fix crash caused by race condition in timer creation
The race condition is the timer elapses before isc__timer_create()
returns the pointer to the caller.  Assigning the return pointer before
enabling the timer will fix it.

(cherry picked from commit 21966423cd)
2018-09-27 12:59:51 -07:00
Michał Kępień
3c43ba5fec Prevent a race after zone load
Zone loading happens in a different task (zone->loadtask) than other
zone actions (zone->task).  Thus, when zone_postload() is called in the
context of zone->loadtask, it may cause zone maintenance to be queued in
zone->task and another thread can then execute zone_maintenance() before
zone_postload() gets a chance to finish its work in the first thread.
This would not be a problem if zone_maintenance() accounted for this
possibility by locking the zone before checking the state of its
DNS_ZONEFLG_LOADPENDING flag.  However, the zone is currently not locked
before the state of that flag is checked, which may prevent zone
maintenance from happening despite zone_postload() scheduling it.  Fix
by locking the zone in zone_maintenance() before checking the state of
the zone's DNS_ZONEFLG_LOADPENDING flag.

(cherry picked from commit 56003e9f9f)
2018-09-26 19:46:09 -07:00
Mark Andrews
c827981de2 add krb5-selfsub and ms-selfsub
(cherry picked from commit fbeefd4990)
2018-09-10 17:18:38 +10:00
Mark Andrews
eae8d858e5 check that name field is not a valid type
(cherry picked from commit 5fb75a3d75)
2018-09-10 17:16:10 +10:00
Mark Andrews
4375370ba6 fix dns_ssumatchtype_subdomainms dns_ssumatchtype_subdomainkrb5 as they don't require the name field to be '.'
(cherry picked from commit 156d86e673)
2018-09-10 17:16:10 +10:00
Mark Andrews
9a14141676 avoid macro name collision with system defined macro
(cherry picked from commit 81b133d963)
2018-09-10 09:30:38 +10:00
Witold Kręcicki
0f6dee2a45 Align CMSG buffers to a void* boundary, fixes crash on architectures with strict alignment
CHANGES entry

(cherry picked from commit 17212cf996)
2018-09-07 10:27:20 +02:00
Ondřej Surý
f24af7deac Add C++ declarations to dns/fixedname.h
(cherry picked from commit 94a1c85366)
2018-09-06 08:11:04 +10:00
Ondřej Surý
3fbceba0a8 Bail-out early in the for install loops instead of continuing because for masks the error in the middle
(cherry picked from commit 25248eb097)
2018-09-03 13:31:17 +02:00
Witold Krecicki
0f0dfc7f86 Silence some warnings and errors 2018-08-31 17:33:03 -07:00
Mark Andrews
2289ba8b48 increase jitter to cover the entire potential steady state expire range when initially signing the zone
(cherry picked from commit 050fca2139)
2018-08-31 13:07:45 +10:00
Mark Andrews
3b9a6f0db8 fclose origfile and zonefile
(cherry picked from commit 455bb23236)
2018-08-31 12:24:46 +10:00