Commit Graph

35139 Commits

Author SHA1 Message Date
Ondřej Surý
15ce1737fa Fix the isc_hp initialization and memory usage
Previously, the isc_hp_init() could not lower the value of
isc__hp_max_threads, but because of a mistake the isc__hp_max_threads
would be set to HP_MAX_THREADS (e.g. 128 threads) thus it would be
always set to 128.  This would result in increased memory usage even
when small number of workers were in use.

Change the default value of isc__hp_max_threads to be 1.

Additionally, enforce the max_hps value in isc_hp_new() to be smaller or
equal to HP_MAX_HPS.  The only user is isc_queue which uses just 1
hazard pointer, so it's only theoretical issue.
2021-12-07 20:41:46 +01:00
Petr Špaček
5e69cd6329 Merge branch '1265-deprecate-broken-nsec' into 'main'
Mark broken-nsec option as deprecated

See merge request isc-projects/bind9!5618
2021-12-06 16:06:25 +00:00
Petr Špaček
74d83910d5 Mark broken-nsec option as deprecated
It's unclear if we are going to keep it or not, so let's mark it as
deprecated for a good measure. It's easier to un-deprecate it than the
other way around.
2021-12-06 16:55:55 +01:00
Michał Kępień
236a19ce40 Merge branch '3040-restore-the-fetch-context-expiry-timer' into 'main'
Restore the fetch context expiry timer

Closes #3040

See merge request isc-projects/bind9!5612
2021-12-03 09:07:27 +00:00
Evan Hunt
3a52250286 CHANGES for [GL #3040] 2021-12-03 09:51:06 +01:00
Evan Hunt
4d4cea243a restore the fetch lifetime timer
the lifetime expiry timer for the fetch context was removed
when we switched to using in-band netmgr timeouts. however,
it turns out some dependency loops can occur between a fetch
and the ADB the validator; these deadlocks were formerly broken
when the timer fired, and now there's no timer. we can fix these
errors individually, but in the meantime we don't want the server
to get hung at shutdown because of dangling fetches.

this commit puts back a single timer, which fires two seconds
after the fetch should have completed, and shuts it down. it also
logs a message at level INFO so we know about the problems when
they occur.
2021-12-03 09:49:24 +01:00
Petr Špaček
9f790f75b4 Merge branch '1265-bind-9-14-option-synth-from-dnssec-causing-high-cpu-consumption-and-degraded-client-experience' into 'main'
Rework rbtdb.c:find_coveringnsec to use shadow NSEC tree

Closes #1265

See merge request isc-projects/bind9!5446
2021-12-02 13:52:40 +00:00
Petr Špaček
d24dab6430 Clarify that NSEC3 is not supported by synth-from-dnssec yet 2021-12-02 14:27:18 +01:00
Mark Andrews
41d14210de Check reject-000-label 2021-12-02 14:27:18 +01:00
Mark Andrews
0aaaa8768f Reject NSEC records with next field with \000 label
A number of DNS implementation produce NSEC records with bad type
maps that don't contain types that exist at the name leading to
NODATA responses being synthesize instead of the records in the
zone.  NSEC records with these bad type maps often have the NSEC
NSEC field set to '\000.QNAME'.  We look for the first label of
this pattern.

e.g.
	example.com NSEC \000.example.com SOA NS NSEC RRSIG
	example.com RRRSIG NSEC ...
	example.com SOA ...
	example.com RRRSIG SOA ...
	example.com NS ...
	example.com RRRSIG NS ...
	example.com A ...
	example.com RRRSIG A ...

	A is missing from the type map.

This introduces a temporary option 'reject-000-label' to control
this behaviour.
2021-12-02 14:27:18 +01:00
Mark Andrews
8878adcd61 Check SOA without DNSKEY behaviour 2021-12-02 14:27:18 +01:00
Mark Andrews
dfe31e61d2 Check 'server { broken-nsec yes; };' 2021-12-02 14:27:18 +01:00
Mark Andrews
3faccb16cc Add server christmas tree test
This sets as many server options as possible at once to detect
cut-and-paste bugs when implementing new server options in peer.c.
Most of the accessor functions are similar and it is easy to miss
updating a macro name or structure element name when adding new
accessor functions.

checkconf/setup.sh is there to minimise the difference to branches
with optional server options where the list is updated at runtime.
2021-12-02 14:27:18 +01:00
Mark Andrews
733f58a7a5 Allow servers that emit broken NSEC records to be identified
'server <prefix> { broken-nsec yes; };' can now be used to stop
NSEC records from negative responses from servers in the given
prefix being cached and hence available to synth-from-dnssec.
2021-12-02 14:27:14 +01:00
Mark Andrews
454c29046f Check that SOA and DNSKEY are consistent in NSEC typemaps
If there is a SOA record present then there should also be a
DNSKEY record present as the DNSKEY is supposed to live at the
zone apex like the SOA.
2021-12-02 14:24:37 +01:00
Mark Andrews
d733eeba75 Add data lookups into nodata tests 2021-12-02 14:24:37 +01:00
Mark Andrews
b25ff302ac Check synthesis of wildcard NODATA with 2 NSEC 2021-12-02 14:24:37 +01:00
Mark Andrews
5252985a21 Look for covering NSEC under two more conditions
1) when after processing a node there where no headers that
   contained active records.

   When

       if (check_stale_header(node, header, &locktype, lock, &search,
			      &header_prev);

   succeeds or

       if (EXISTS(header) && !ANCIENT(header))

   fails for all entries in the list leading to 'empty_node' remaining
   true.

   If there is are no active records we know nothing about the
   current state of the name so we treat is as ISC_R_NOTFOUND.

2) when there was a covering NOQNAME proof found or all the
   active headers where negative.

   When

	if (header->noqname != NULL &&
	    header->trust == dns_trust_secure)

   succeeds or

	if (!NEGATIVE(header))

   never succeeds.  Under these conditions there could (should be for
   found_noqname) be a covering NSEC earlier in the tree.
2021-12-02 14:24:37 +01:00
Mark Andrews
94935e7e34 Check synthesis of wildcard NODATA with 1 NSEC 2021-12-02 14:24:37 +01:00
Mark Andrews
3fa3b11ef8 Add synthesis of NODATA at wildcard
The old code rejected NSEC that proved the wildcard name existed
(exists).  The new code rejects NSEC that prove that the wildcard
name exists and that the type exists (exists && data) but accept
NSEC that prove the wildcard name exists.

query_synthnxdomain (renamed query_synthnxdomainnodata) already
took the NSEC records and added the correct records to the message
body for NXDOMAIN or NODATA responses with the above change.  The
only additional change needed was to ensure the correct RCODE is
set.
2021-12-02 14:24:37 +01:00
Mark Andrews
12c64d55f2 Add CHANGES and release note for [GL #1265] 2021-12-02 14:24:31 +01:00
Mark Andrews
4bdd5a9953 Ignore NSEC records without RRSIG and NSEC present
dns_nsec_noexistnodata now checks that RRSIG and NSEC are
present in the type map.  Both types should be present in
a correctly constructed NSEC record.  This check is in
addition to similar checks in resolver.c and validator.c.
2021-12-02 14:18:42 +01:00
Mark Andrews
8ff2c133b5 Add dns_nsec_requiredtypespresent
checks an NSEC rdataset to ensure that both NSEC and RRSIG are
present in the type map.  These types are required for the NSEC
to be valid
2021-12-02 14:18:42 +01:00
Mark Andrews
571f3af6e8 Check 'rndc stats' output for 'cache NSEC auxiliary database nodes' 2021-12-02 14:18:41 +01:00
Mark Andrews
0e1048ff25 Check synth-from-dnssec JSON counters 2021-12-02 14:18:41 +01:00
Mark Andrews
6dcea1531d Check synth-from-dnssec XML counters 2021-12-02 14:18:41 +01:00
Mark Andrews
98cab76295 Check reported synthesized responses in named.stats 2021-12-02 14:18:41 +01:00
Mark Andrews
48bf5f143b Correct spelling of synthesized 2021-12-02 14:18:41 +01:00
Mark Andrews
fe8bc79f2b Check 'rndc stats' output for 'covering nsec returned' 2021-12-02 14:18:41 +01:00
Mark Andrews
43316a40a0 Record how often DNS_R_COVERINGNSEC is returned from the cache
reported as "covering nsec returned" when dumping cache stats
and as "CoveringNSEC" in json and xml cache statistics.
2021-12-02 14:18:41 +01:00
Mark Andrews
90dbdb2cb5 Restore 'synth-from-dnssec yes;' as the default 2021-12-02 14:18:41 +01:00
Mark Andrews
62dd9ec9c1 Report Cache NSEC auxilary database size 2021-12-02 14:18:41 +01:00
Mark Andrews
85bfcaeb2e Extend dns_db_nodecount to access auxilary rbt node counts
dns_db_nodecount can now be used to get counts from the auxilary
rbt databases.  The existing node count is returned by
tree=dns_dbtree_main.  The nsec and nsec3 node counts by dns_dbtree_nsec
and dns_dbtree_nsec3 respectively.
2021-12-02 14:18:41 +01:00
Mark Andrews
cad24b8dc4 Check Cloudflare "black lies" response
"black lies" with a different QTYPE should synthesis NODATA responses.
2021-12-02 14:18:41 +01:00
Mark Andrews
c8a7f92b9e Allow "black lies" to be cached
"black lies" differ from "white lies" in that the owner name of the
NSEC record matches the QNAME and the intent is to return NODATA
instead of NXDOMAIN for all types.  Caching this NSEC does not lead
to unexpected behaviour on synthesis when the QNAME matches the
NSEC owner which it does for the the general "white lie" response.

"black lie" QNAME NSEC \000.QNAME NSEC RRSIG

"white lie" QNAME- NSEC QNAME+ NSEC RRSIG

where QNAME- is a name that is close to QNAME but sorts before QNAME
and QNAME+ is a that is close to QNAME but sorts after QNAME.

Black lies are safe to cache as they don't bring into existence
names that are not intended to exist.  "Black lies" intentional change
NXDOMAIN to NODATA. "White lies" bring QNAME- into existence and named
would synthesis NODATA for QNAME+ if it is queried for that name
instead of discovering the, presumable, NXDOMAIN response.

Note rejection NSEC RRsets with NEXT names starting with the label
'\000' renders this change ineffective (see reject-000-label).
2021-12-02 14:18:41 +01:00
Mark Andrews
0d75ec9ee3 Check that minimal NSEC records are not cached
construct a test zone which contains a minimal NSEC record,
emit priming queries for this record, and then check that
a respose that would be synthesised from it isn't.
2021-12-02 14:18:41 +01:00
Mark Andrews
6fae151c9d Do not cache minimal NSEC records (NSEC + RRSIG only)
these are not useful for dnssec synthesis as they can result in
false NODATA responses and just consume cache memory
2021-12-02 14:18:41 +01:00
Mark Andrews
e906fefb7d Extend synthfromdnssec to test with dnssec validation disabled 2021-12-02 14:18:41 +01:00
Mark Andrews
10a05dc26a Extend synthfromdnssec to check insecure responses
add matching tests against a insecure zone to those which
which are synthesised.
2021-12-02 14:18:40 +01:00
Mark Andrews
27acf56ba3 Remove unnecessary dns_rbt_fullnamefromnode call
the results from dns_rbt_fullnamefromnode are not used.
2021-12-02 14:18:40 +01:00
Mark Andrews
48f1f51870 Extend checking of synthesised respones
add digcomp checks to cover wildcard and cname wildcard case
(nxdomain and nodata already covered)
2021-12-02 14:18:40 +01:00
Mark Andrews
89542b8a15 Count DNS_R_COVERINGNSEC as a cache {query}hit
Note when synthesising answer involving wildcards we look in the
cache multiple times, once for the QNAME and once for the wildcard
name which is constucted by looking at the names from the covering
NSEC return by the QNAME miss.
2021-12-02 14:18:40 +01:00
Mark Andrews
e5ce159b5b Add additional checks that upstream queries are not made
Check the named.run of authorative server that queries for the
synthesis target name are only made when expected and not when
unexpected.
2021-12-02 14:18:40 +01:00
Mark Andrews
67d4c783fa Check synthesis of CNAME record from wildcard CNAME 2021-12-02 14:18:40 +01:00
Mark Andrews
25915e81b4 Check synthesis of A record from wildcard A 2021-12-02 14:18:40 +01:00
Mark Andrews
b8563db96a Check whether soa responses are synthesised or not 2021-12-02 14:18:40 +01:00
Mark Andrews
95ec47a460 Add and use check_status 2021-12-02 14:18:40 +01:00
Mark Andrews
d06e8366b4 Add and use check_ad_flag 2021-12-02 14:18:40 +01:00
Mark Andrews
3a5652ccb1 Rework rbtdb.c:find_coveringnsec() to use the auxilary nsec rbt
this improves the performance of looking for NSEC and RRSIG(NSEC)
records in the cache by skipping lots of nodes in the main trees
in the cache without these records present.  This is a simplified
version of previous_closest_nsec() which uses the same underlying
mechanism to look for NSEC and RRSIG(NSEC) records in authorative
zones.

The auxilary NSEC tree was already being maintained as a side effect
of looking for the covering NSEC in large zones where there can be
lots of glue records that needed to be skipped.  Nodes are added
to the tree whenever a NSEC record is added to the primary tree.
They are removed when the corresponding node is removed from the
primary tree.

Having nodes in the NSEC tree w/o NSEC records in the primary tree
should not impact on synth-from-dnssec efficiency as that node would
have held the NSEC we would have been needed to synthesise the
response.  Removing the node when the NSEC RRset expires would only
cause rbtdb to return a NSEC which would be rejected at a higher
level.
2021-12-02 14:18:40 +01:00
Ondřej Surý
240b8a3afc Merge branch '2700-improve-failed-tcp-accept-logging' into 'main'
Improve the logging on failed TCP accept

Closes #2700

See merge request isc-projects/bind9!5611
2021-12-02 13:18:10 +00:00