2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-25 19:47:42 +00:00

305 Commits

Author SHA1 Message Date
Ondřej Surý
994e656977 Replace custom isc_boolean_t with C standard bool type 2018-08-08 09:37:30 +02:00
Ondřej Surý
cb6a185c69 Replace custom isc_u?intNN_t types with C99 u?intNN_t types 2018-08-08 09:37:28 +02:00
Michał Kępień
8e3fc5725f Extract code preparing a delegation response to a separate function
Changes introduced by the previous two commits make the parts of
query_delegation() and query_zone_delegation() which prepare a
delegation response functionally equivalent.  Extract this code into a
separate function, query_prepare_delegation_response(), and then call
the latter from both query_delegation() and query_zone_delegation() in
order to reduce code duplication.  Add a comment describing the purpose
of the extracted code.  Fix coding style issues.
2018-08-08 08:08:40 +02:00
Michał Kępień
7db4dedf6b Remove unused NS_QUERYATTR_CACHEGLUEOK query attribute
The NS_QUERYATTR_CACHEGLUEOK query attribute has no influence on query
processing.  Remove it.
2018-08-08 08:08:40 +02:00
Michał Kępień
b6c77202cb Restore zone database and zone node if cache search results are to be ignored
When query processing hits a delegation from a locally configured zone,
an attempt may be made to look for a better answer in the cache.  In
such a case, the zone-sourced delegation data is set aside and the
lookup is retried using the cache database.  When that lookup is
completed, a decision is made whether the answer found in the cache is
better than the answer found in the zone.

Currently, if the zone-sourced answer turns out to be better than the
one found in the cache:

  - qctx->zdb is not restored into qctx->db,
  - qctx->node, holding the zone database node found, is not even saved.

Thus, in such a case both qctx->db and qctx->node will point at cache
data.  This is not an issue for BIND versions which do not support
mirror zones because in these versions non-recursive queries always
cause the zone-sourced delegation to be returned and thus the
non-recursive part of query_delegation() is never reached if the
delegation is coming from a zone.  With mirror zones, however,
non-recursive queries may cause cache lookups even after a zone
delegation is found.  Leaving qctx->db assigned to the cache database
when query_delegation() determines that the zone-sourced delegation is
the best answer to the client's query prevents DS records from being
added to delegations coming from mirror zones.  Fix this issue by
keeping the zone database and zone node in qctx while the cache is
searched for an answer and then restoring them into qctx->db and
qctx->node, respectively, if the zone-sourced delegation turns out to be
the best answer.  Since this change means that qctx->zdb cannot be used
as the glue database any more as it will be reset to NULL by RESTORE(),
ensure that qctx->db is not a cache database before attaching it to
qctx->client->query.gluedb.

Furthermore, current code contains a conditional statement which
prevents a mirror zone from being used as a source of glue records.
Said statement was added to prevent assertion failures caused by
attempting to use a zone database's glue cache for finding glue for an
NS RRset coming from a cache database.  However, that check is overly
strict since it completely prevents glue from being added to delegations
coming from mirror zones.  With the changes described above in place,
the scenario this check was preventing can no longer happen, so remove
the aforementioned check.

If qctx->zdb is not NULL, qctx->zfname will also not be NULL;
qctx->zsigrdataset may be NULL in such a case, but query_putrdataset()
handles pointers to NULL pointers gracefully.  Remove redundant
conditional expressions to make the cleanup code in query_freedata()
match the corresponding sequences of SAVE() / RESTORE() macros more
closely.
2018-08-08 08:07:46 +02:00
Mark Andrews
69fd3f5ba4 use extracted netaddr rather than client->destaddr 2018-07-10 18:17:54 -07:00
Michał Kępień
c3f3b824e7 Treat mirror zone data as cache data for access control purposes
As mirror zone data should be treated the way validated, cached DNS
responses are, it should not be used when responding to clients who are
not allowed cache access.  Reuse code responsible for determining cache
database access for evaluating mirror zone access.
2018-06-28 13:38:39 +02:00
Michał Kępień
18ced94241 Rework query_checkcacheaccess()
Modify query_checkcacheaccess() so that it only contains a single return
statement rather than three and so that the "check_acl" variable is no
longer needed.  Tweak and expand comments.  Fix coding style issues.
2018-06-28 13:38:39 +02:00
Michał Kępień
cde16236fb Simplify query_getcachedb()
Modify query_getcachedb() so that it uses a common return path for both
success and failure.  Remove a redundant NULL check since 'db' will
never be NULL after being passed as a target pointer to dns_db_attach().
Fix coding style issues.
2018-06-28 13:38:39 +02:00
Michał Kępień
e9f17da6e9 Extract cache access checks in query_getcachedb() to a separate function
Extract the parts of query_getcachedb() responsible for checking whether
the client is allowed to access the cache to a separate function, so
that it can be reused for determining mirror zone access.
2018-06-28 13:38:39 +02:00
Michał Kępień
8d996fd79c Fall back to normal recursion when mirror zone data is unavailable
If transferring or loading a mirror zone fails, resolution should still
succeed by means of falling back to regular recursive queries.
Currently, though, if a slave zone is present in the zone table and not
loaded, a SERVFAIL response is generated.  Thus, mirror zones need
special handling in this regard.

Add a new dns_zt_find() flag, DNS_ZTFIND_MIRROR, and set it every time a
domain name is looked up rather than a zone itself.  Handle that flag in
dns_zt_find() in such a way that a mirror zone which is expired or not
yet loaded is ignored when looking up domain names, but still possible
to find when the caller wants to know whether the zone is configured.
This causes a fallback to recursion when mirror zone data is unavailable
without making unloaded mirror zones invisible to code checking a zone's
existence.
2018-06-28 13:38:39 +02:00
Michał Kępień
ad0ec2ea93 Do not treat mirror zone data as authoritative
Section 4 of RFC 7706 suggests that responses sourced from a local copy
of a zone should not have the AA bit set.  Follow that recommendation by
setting 'qctx->authoritative' to ISC_FALSE when a response to a query is
coming from a mirror zone.
2018-06-28 13:38:39 +02:00
Michał Kępień
179d5faa28 Ensure delegations inside mirror zones are properly handled for non-recursive queries
When a resolver is a regular slave (i.e. not a mirror) for some zone,
non-recursive queries for names below that slaved zone will return a
delegation sourced from it.  This behavior is suboptimal for mirror
zones as their contents should rather be treated as validated, cached
DNS responses.  Modify query_delegation() and query_zone_delegation() to
permit clients allowed cache access to check its contents for a better
answer when responding to non-recursive queries.
2018-06-28 13:38:39 +02:00
Evan Hunt
c8015eb33b style nits (mostly line length) 2018-06-12 09:18:47 +02:00
Witold Kręcicki
0698158eb0 QNAME minimization 2018-06-12 09:18:46 +02:00
Evan Hunt
8d923a05a9 ensure that we attempt to validate glue if it's signed
- incidentally fixed a bug in the dnssec system test where TTLs in the
  answer section rather than the additional section were being checked
2018-06-08 11:39:25 -07:00
Tony Finch
4b442c309d Move serve-stale logging to its own category, so that its verbosity can be curtailed. 2018-05-25 22:00:51 -07:00
Evan Hunt
9147a31b94 copyrights 2018-05-23 12:39:40 -04:00
Michał Kępień
46bb4dd124 Detect recursion loops during query processing
Interrupt query processing when query_recurse() attempts to ask the same
name servers for the same QNAME/QTYPE tuple for two times in a row as
this indicates that query processing may be stuck for an indeterminate
period of time, e.g. due to interactions between features able to
restart query_lookup().
2018-05-21 09:50:10 -07:00
Mukund Sivaraman
31bd3147d1 Don't validate non-pending glue when adding to the additional section 2018-05-16 08:15:36 +02:00
Mark Andrews
92e540df1e Silence clang static analyzer warnings; Consolidate multiple instances of splitting of batchline in dig into a single function. 2018-05-11 10:54:21 +10:00
Mark Andrews
68e9315c7d add named.conf option root-key-sentinel 2018-04-18 08:49:55 -07:00
Mark Andrews
8fc9f64df9 detect and processes root-key-sentinel labels. 2018-04-18 08:49:55 -07:00
Michał Kępień
4df4a8e731 Use dns_fixedname_initname() where possible
Replace dns_fixedname_init() calls followed by dns_fixedname_name()
calls with calls to dns_fixedname_initname() where it is possible
without affecting current behavior and/or performance.

This patch was mostly prepared using Coccinelle and the following
semantic patch:

    @@
    expression fixedname, name;
    @@
    -	dns_fixedname_init(&fixedname);
    	...
    -	name = dns_fixedname_name(&fixedname);
    +	name = dns_fixedname_initname(&fixedname);

The resulting set of changes was then manually reviewed to exclude false
positives and apply minor tweaks.

It is likely that more occurrences of this pattern can be refactored in
an identical way.  This commit only takes care of the low-hanging fruit.
2018-04-09 12:14:16 +02:00
Witold Kręcicki
42ee8c853a libdns refactoring: get rid of 3 versions of dns_resolver_createfetch 2018-04-06 08:04:41 +02:00
Witold Kręcicki
25cd3168a7 libdns refactoring: get rid of multiple versions of dns_dnssec_findmatchingkeys and dns_dnssec_findzonekeys 2018-04-06 08:04:41 +02:00
Mark Andrews
f1def91625 check insist on every call; make conditional block constistent with rest of code 2018-03-07 15:18:16 -05:00
Ondřej Surý
843d389661 Update license headers to not include years in copyright in all applicable files 2018-02-23 10:12:02 +01:00
Mark Andrews
b492700759 use %u instead of %d 2018-02-16 10:20:38 +11:00
Mark Andrews
d26f90241d 4880. [bug] Named wasn't returning the target of a cross zone
CNAME between to served zones when recursion was
                        desired and available (RD=1, RA=1). Don't return
                        the CNAME target otherwise to prevent accidental
                        cache poisoning. [RT #47078]
2018-01-30 13:10:06 +11:00
Mark Andrews
af034ef188 silence clang static analyser warning. [RT #46881] 2018-01-22 09:47:53 +11:00
Mark Andrews
67faaa41c9 test devent->sigrdataset rather than devent->rdataset before calling query_putrdataset 2018-01-05 12:36:21 +11:00
Mark Andrews
9e6b394410 use RESTORE rather than SAVE as is better describes the operation 2018-01-04 13:11:28 +11:00
Mark Andrews
eed2f6cef0 4857. [bug] Maintain attach/detach semantics for event->db,
event->node, event->rdataset and event->sigrdataset
                        in query.c. [RT #46891]
2018-01-04 10:48:18 +11:00
Tinderbox User
7bba3a7c44 update copyright notice / whitespace 2018-01-02 23:45:28 +00:00
Mark Andrews
c9ee9718ae 4854. [bug] query_synthcnamewildcard should stop generating the
response if query_synthwildcard fails. [RT #46939]
2018-01-03 10:07:42 +11:00
Mark Andrews
3d905e0533 4817. [cleanup] Use DNS_NAME_INITABSOLUTE and DNS_NAME_INITNONABSOLUTE.
[RT #45433]
2017-11-13 16:58:12 +11:00
Mark Andrews
c0e3e1fe44 4813. [bug] Address potential read after free errors from
query_synthnodata, query_synthwildcard and
                        query_synthnxdomain. [RT #46547]
2017-11-10 13:33:18 +11:00
Evan Hunt
65314b0fd8 [master] "enable-filter-aaaa" no longer optional
4786.	[func]		The "filter-aaaa-on-v4" and "filter-aaaa-on-v6"
			options are no longer conditionally compiled.
			[RT #46340]
2017-10-25 00:33:51 -07:00
Evan Hunt
0207f6ff9e [master] omit NS from authority section if it was in answer
4780.	[bug]		When answering ANY queries, don't include the NS
			RRset in the authority section if it was already
			in the answer section. [RT #44543]
2017-10-23 19:16:27 -07:00
Mark Andrews
a59d687db4 4778. [test] Improve synth-from-dnssec testing. [RT #46352] 2017-10-24 09:49:07 +11:00
Michał Kępień
6853af8fc5 [master] Deconstify hook tables as replacing single entries is allowed 2017-10-23 14:17:07 +02:00
Michał Kępień
defa292088 [master] expanded libns unit tests
4772.	[test]		Expanded unit testing framework for libns, using
			hooks to interrupt query flow and inspect state
			at specified locations. [RT #46173]
2017-10-11 15:02:50 -07:00
Mark Andrews
5df3f839b2 4766. [cleanup] Addresss Coverity warnings. [RT #46150]
4765.   [bug]           Address potential INSIST in dnssec-cds. [RT #46150]
2017-10-09 18:34:31 +11:00
Mark Andrews
b41c1aacbc 4759. [func] Add logging channel "trust-anchor-telementry" to
record trust-anchor-telementry in incoming requests.
                        Both _ta-XXXX.<anchor>/NULL and EDNS KEY-TAG options
                        are logged.  [RT #46124]
2017-10-06 13:01:14 +11:00
Mark Andrews
c85b467dc0 4747. [func] Synthesis of responses from DNSSEC-verified records.
Stage 3 - synthesize NODATA responses. [RT #40138]
2017-10-03 11:16:37 +11:00
Evan Hunt
24172bd2ee [master] completed and corrected the crypto-random change
4724.	[func]		By default, BIND now uses the random number
			functions provided by the crypto library (i.e.,
			OpenSSL or a PKCS#11 provider) as a source of
			randomness rather than /dev/random.  This is
			suitable for virtual machine environments
			which have limited entropy pools and lack
			hardware random number generators.

			This can be overridden by specifying another
			entropy source via the "random-device" option
			in named.conf, or via the -r command line option;
			however, for functions requiring full cryptographic
			strength, such as DNSSEC key generation, this
			cannot be overridden. In particular, the -r
			command line option no longer has any effect on
			dnssec-keygen.

			This can be disabled by building with
			"configure --disable-crypto-rand".
			[RT #31459] [RT #46047]
2017-09-28 10:09:22 -07:00
Mark Andrews
f735293431 4743. [func] Exclude trust-anchor-telementry queries from
synth-from-dnssec processing. [RT #46123]
2017-09-28 16:40:45 +10:00
Mark Andrews
e00fdad191 4742. [func] Synthesis of responses from DNSSEC-verified records.
Stage 2 - synthesis of records from wildcard data.
                        If the dns64 or filter-aaaa* is configured then the
                        involved lookups are currently excluded. [RT #40138]
2017-09-28 15:16:26 +10:00
Mark Andrews
f9f3f20d2d 4739. [cleanup] Address clang static analysis warnings. [RT #45952] 2017-09-27 10:27:09 +10:00