2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00
Commit Graph

8548 Commits

Author SHA1 Message Date
Evan Hunt
aeef4719e9 add syntax and setter/getter functions to configure max-ixfr-ratio 2020-03-05 17:20:16 -08:00
Michał Kępień
b675d30f09 Fix lists of installed header files 2020-03-05 23:09:51 +00:00
Tony Finch
689ef89b67 Fix dns_client_addtrustedkey(dns_rdatatype_dnskey)
Use a buffer that is big enough for DNSKEY records as well as DS
records.
2020-03-04 08:59:29 -08:00
Evan Hunt
7a3fa9f593 list "validate-except" entries in "rndc nta -d" and "rndc secroots"
- no longer exclude these entries when dumping the NTA table
- indicate "validate-except" entries with the keyword "permanent" in
  place of an expiry date
- add a test for this feature, and update other tests to account for
  the presence of extra lines in some rndc outputs
- incidentally removed the unused function dns_ntatable_dump()
- CHANGES, release note
2020-03-04 00:44:32 -08:00
Mark Andrews
f171347b5f Restart zone maintenance if it had been stalled. 2020-03-04 08:45:34 +11:00
Ondřej Surý
aaaa7e67fa Adjust lock/unlock in zone_rekey() 2020-03-03 15:26:31 +11:00
Mark Andrews
a6626594aa Ensure that resigintime and the zone timer are set 2020-03-03 15:26:27 +11:00
Matthijs Mekking
143d1c9767 Add more zone locks
Add more zone locks around code that touches zone timer setting
in failure modes.
2020-03-03 15:26:27 +11:00
Mark Andrews
7212961849 Always call set_resigntime with the zone lock held 2020-03-03 15:26:27 +11:00
Mark Andrews
5ec57f31b0 Always call zone_settimer()
zone_needdump() could potentially not call zone_settimer() so
explitly call zone_settimer() as zone->resigntime could have
gone backward.
2020-03-03 15:26:27 +11:00
Mark Andrews
5d1611afdc Call set_resigntime() in receive_secure_serial()
With RRSIG records no longer being signed with the full
sig-validity-interval we need to ensure the zone->resigntime
as it may need to be set to a earlier time.
2020-03-03 15:26:27 +11:00
Witold Kręcicki
6c8f309745 Workaround for clang static analyzer bug. 2020-03-02 14:12:05 +01:00
Witold Kręcicki
47e5f5564c Badcache with multiple locks.
Previously badcache used one single mutex for everything, which
was causing performance issues. Use one global rwlock for the whole
hashtable and per-bucket mutexes.
2020-03-02 12:13:09 +01:00
Michał Kępień
fc967ba092 Add ZLIB_LIBS to ISCLIBS
When --with-zlib is passed to ./configure (or when the latter
autodetects zlib's presence), libisc uses certain zlib functions and
thus libisc's users should be linked against zlib in that case.  Adjust
Makefile variables appropriately to prevent shared build failures caused
by underlinking.
2020-02-28 15:22:29 +01:00
Witold Kręcicki
0344684385 Increase nodelock count for both cache and regular db. 2020-02-28 08:46:16 +01:00
Witold Kręcicki
fe584c01cc Don't update LRU if the node was recently used.
Updating LRU requires write-locking the node, which causes contention.
Update LRU only if time difference is large enough.
2020-02-28 08:46:16 +01:00
Mark Andrews
a24fd55836 sort RRSIG(SOA) to be last of RRSIGs with a common re-resign time 2020-02-27 22:30:14 +00:00
Mark Andrews
660dc3eba7 use the full sig-validity-interval for RRSIG(SOA) 2020-02-27 22:30:14 +00:00
Witold Kręcicki
3a3b5f557a Add an arena to compressctx 2020-02-26 07:57:44 +00:00
Michał Kępień
9f34e0d5af Bump library API versions for BIND 9.17 2020-02-24 10:56:47 +01:00
Evan Hunt
a2aa29ed4f some Fossies-reported spelling errors were accidentally left unfixed 2020-02-21 14:12:42 -08:00
Mark Andrews
3a8c8a2a31 Fix code to generate the test signatues.
* ctx needs to be destroyed before it is regenerated.
* emit the name of the signature to be replaced.
* cleanup memory before asserting so post longjump doesn't detect a
  memory leak.
* comment code.
2020-02-20 22:28:58 -08:00
Mark Andrews
40fc5809cd update signatures 2020-02-21 15:05:08 +11:00
Evan Hunt
ba0313e649 fix spelling errors reported by Fossies. 2020-02-21 15:05:08 +11:00
Diego Fronza
63c88f4a04 Enable named-checkzone and named-compilezone to take input from stdin
If a filename (the last argument) is not provided for named-checkzone or
named-compilezone, or if it is a single dash "-" character,
zone data will be read from stdin.

Example of invocation:
cat /etc/zone_name.db | named-compilezone -f text -F raw \
    -o zone_name.raw zone_name
2020-02-20 11:19:13 -03:00
Evan Hunt
0002377dca adjust the clang-format penalties to reduce string breaking
this corrects some style glitches such as:
```
        long_function_call(arg, arg2, arg3, arg4, arg5, "str"
                                                        "ing");
```
...by adjusting the penalties for breaking strings and call
parameter lists.
2020-02-17 14:23:58 -08:00
Ondřej Surý
3832e3ecc9 Fixup the missing clang-format bits 2020-02-16 17:34:24 +01:00
Diego Fronza
45543da802 Fixed disposing of resolver->references in destroy() function 2020-02-14 14:28:31 -03:00
Diego Fronza
e7b36924e2 Fixed potential-lock-inversion
This commit simplifies a bit the lock management within dns_resolver_prime()
and prime_done() functions by means of turning resolver's attribute
"priming" into an atomic_bool and by creating only one dependent object on the
lock "primelock", namely the "primefetch" attribute.

By having the attribute "priming" as an atomic type, it save us from having to
use a lock just to test if priming is on or off for the given resolver context
object, within "dns_resolver_prime" function.

The "primelock" lock is still necessary, since dns_resolver_prime() function
internally calls dns_resolver_createfetch(), and whenever this function
succeeds it registers an event in the task manager which could be called by
another thread, namely the "prime_done" function, and this function is
responsible for disposing the "primefetch" attribute in the resolver object,
also for resetting "priming" attribute to false.

It is important that the invariant "priming == false AND primefetch == NULL"
remains constant, so that any thread calling "dns_resolver_prime" knows for sure
that if the "priming" attribute is false, "primefetch" attribute should also be
NULL, so a new fetch context could be created to fulfill this purpose, and
assigned to "primefetch" attribute under the lock protection.

To honor the explanation above, dns_resolver_prime is implemented as follow:
	1. Atomically checks the attribute "priming" for the given resolver context.
	2. If "priming" is false, assumes that "primefetch" is NULL (this is
           ensured by the "prime_done" implementation), acquire "primelock"
	   lock and create a new fetch context, update "primefetch" pointer to
	   point to the newly allocated fetch context.
	3. If "priming" is true, assumes that the job is already in progress,
	   no locks are acquired, nothing else to do.

To keep the previous invariant consistent, "prime_done" is implemented as follow:
	1. Acquire "primefetch" lock.
	2. Keep a reference to the current "primefetch" object;
	3. Reset "primefetch" attribute to NULL.
	4. Release "primefetch" lock.
	5. Atomically update "priming" attribute to false.
	6. Destroy the "primefetch" object by using the temporary reference.

This ensures that if "priming" is false, "primefetch" was already reset to NULL.

It doesn't make any difference in having the "priming" attribute not protected
by a lock, since the visible state of this variable would depend on the calling
order of the functions "dns_resolver_prime" and "prime_done".

As an example, suppose that instead of using an atomic for the "priming" attribute
we employed a lock to protect it.
Now suppose that "prime_done" function is called by Thread A, it is then preempted
before acquiring the lock, thus not reseting "priming" to false.
In parallel to that suppose that a Thread B is scheduled and that it calls
"dns_resolver_prime()", it then acquires the lock and check that "priming" is true,
thus it will consider that this resolver object is already priming and it won't do
any more job.
Conversely if the lock order was acquired in the other direction, Thread B would check
that "priming" is false (since prime_done acquired the lock first and set "priming" to false)
and it would initiate a priming fetch for this resolver.

An atomic variable wouldn't change this behavior, since it would behave exactly the
same, depending on the function call order, with the exception that it would avoid
having to use a lock.

There should be no side effects resulting from this change, since the previous
implementation employed use of the more general resolver's "lock" mutex, which
is used in far more contexts, but in the specifics of the "dns_resolver_prime"
and "prime_done" it was only used to protect "primefetch" and "priming" attributes,
which are not used in any of the other critical sections protected by the same lock,
thus having zero dependency on those variables.
2020-02-14 14:28:31 -03:00
Ondřej Surý
5777c44ad0 Reformat using the new rules 2020-02-14 09:31:05 +01:00
Ondřej Surý
654927c871 Add separate .clang-format files for headers 2020-02-14 09:31:05 +01:00
Evan Hunt
e851ed0bb5 apply the modified style 2020-02-13 15:05:06 -08:00
Ondřej Surý
056e133c4c Use clang-tidy to add curly braces around one-line statements
The command used to reformat the files in this commit was:

./util/run-clang-tidy \
	-clang-tidy-binary clang-tidy-11
	-clang-apply-replacements-binary clang-apply-replacements-11 \
	-checks=-*,readability-braces-around-statements \
	-j 9 \
	-fix \
	-format \
	-style=file \
	-quiet
clang-format -i --style=format $(git ls-files '*.c' '*.h')
uncrustify -c .uncrustify.cfg --replace --no-backup $(git ls-files '*.c' '*.h')
clang-format -i --style=format $(git ls-files '*.c' '*.h')
2020-02-13 22:07:21 +01:00
Ondřej Surý
36c6105e4f Use coccinelle to add braces to nested single line statement
Both clang-tidy and uncrustify chokes on statement like this:

for (...)
	if (...)
		break;

This commit uses a very simple semantic patch (below) to add braces around such
statements.

Semantic patch used:

@@
statement S;
expression E;
@@

while (...)
- if (E) S
+ { if (E) { S } }

@@
statement S;
expression E;
@@

for (...;...;...)
- if (E) S
+ { if (E) { S } }

@@
statement S;
expression E;
@@

if (...)
- if (E) S
+ { if (E) { S } }
2020-02-13 21:58:55 +01:00
Ondřej Surý
df6c1f76ad Remove tkey_test (which is no-op anyway) 2020-02-12 15:04:17 +01:00
Ondřej Surý
11341c7688 Update the definition files for Windows 2020-02-12 15:04:17 +01:00
Ondřej Surý
f50b1e0685 Use clang-format to reformat the source files 2020-02-12 15:04:17 +01:00
Ondřej Surý
a5c87d9d18 Cleanup support for specifying PKCS#11 engine as part of the label
The code for specifying OpenSSL PKCS#11 engine as part of the label
(e.g. -l "pkcs11:token=..." instead of -E pkcs11 -l "token=...")
was non-functional.  This commit just cleans the related code.
2020-02-10 07:30:19 -08:00
Ondřej Surý
bc1d4c9cb4 Clear the pointer to destroyed object early using the semantic patch
Also disable the semantic patch as the code needs tweaks here and there because
some destroy functions might not destroy the object and return early if the
object is still in use.
2020-02-09 18:00:17 -08:00
Witold Kręcicki
d708370db4 Fix atomics usage for mutexatomics 2020-02-08 12:34:19 -08:00
Evan Hunt
6504e7da95 various style cleanups 2020-02-07 19:17:05 +01:00
Evan Hunt
58aa084edc add support for key algorithm mnemonics in dnssec-policy 2020-02-07 19:17:05 +01:00
Evan Hunt
9dc630016e rename 'zone-max-ttl' to 'max-zone-ttl' for consistency 2020-02-07 09:24:06 -08:00
Mark Andrews
e8bf82efc6 Silence unchecked return of dns_db_find()
190        dns_rdataset_init(&rdataset);
   	3. Condition r == 0, taking true branch.
   	4. Condition result, taking false branch.

	CID 1452691 (#1 of 1): Unchecked return value (CHECKED_RETURN)
	5. check_return: Calling dns_db_find without checking return
	value (as is done elsewhere 39 out of 45 times).

191        check_assertion(dns_db_find(db1, dns_rootname, v2,
192                                    dns_rdatatype_soa, 0, 0, NULL,
193                                    name, &rdataset, NULL));
2020-02-07 08:56:52 +00:00
Mark Andrews
98d5109e82 Fix indenting. 2020-02-07 08:56:52 +00:00
Matthijs Mekking
e6c5ecd698 Update kasp test with CDNSKEY checks
Add checks to the kasp system test to verify CDNSKEY publication.
This test is not entirely complete, because when there is a CDNSKEY
available but there should not be one for KEY N, it is hard to tell
whether the existing CDNSKEY actually belongs to KEY N or another
key.

The check works if we expect a CDNSKEY although we cannot guarantee
that the CDNSKEY is correct: The test verifies existence, not
correctness of the record.
2020-02-06 11:02:22 +01:00
Matthijs Mekking
a9a9aa7fd8 Add parentheses around return values 2020-02-06 10:17:22 +01:00
Matthijs Mekking
b378d0371f Fix kasp bug new KSK on restart [#1593]
When you do a restart or reconfig of named, or rndc loadkeys, this
triggers the key manager to run.  The key manager will check if new
keys need to be created. If there is an active key, and key rollover
is scheduled far enough away, no new key needs to be created.

However, there was a bug that when you just start to sign your zone,
it takes a while before the KSK becomes an active key. An active KSK
has its DS submitted or published, but before the key manager allows
that, the DNSKEY needs to be omnipresent. If you restart named
or rndc loadkeys in quick succession when you just started to sign
your zone, new keys will be created because the KSK is not yet
considered active.

Fix is to check for introducing as well as active keys. These keys
all have in common that their goal is to become omnipresent.
2020-02-06 10:17:22 +01:00
Mark Andrews
fccf65a585 'dctx' must be non NULL, remove test.
1549 cleanup:
1550        if (dctx->dbiter != NULL)
1551                dns_dbiterator_destroy(&dctx->dbiter);
1552        if (dctx->db != NULL)
1553                dns_db_detach(&dctx->db);

	CID 1452686 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking dctx suggests that it may
	be null, but it has already been dereferenced on all paths
	leading to the check.

1554        if (dctx != NULL)
1555                isc_mem_put(mctx, dctx, sizeof(*dctx));
2020-02-05 18:37:17 +11:00
Mark Andrews
0312e73e16 'closest' must be non NULL, remove test.
6412 cleanup:
6413        dns_rdataset_disassociate(&neg);
6414        dns_rdataset_disassociate(&negsig);

	CID 1452700 (#1 of 1): Dereference before null check (REVERSE_INULL)
	check_after_deref: Null-checking closest suggests that it
	may be null, but it has already been dereferenced on all
	paths leading to the check.

6415        if (closest != NULL)
6416                free_noqname(mctx, &closest);
2020-02-05 18:37:17 +11:00