12002 Commits
Author SHA1 Message Date
Ondřej SurýandOndřej Surý a377780049 Stop requiring same memory ordering in win32 atomic_compare_exchange functions 2020-02-13 15:16:06 +01:00
Tinderbox User d271d444aa prep v9.14.11 2020-02-12 20:07:41 +00:00
Ondřej Surý 3c8a441a0e Convert all atomic operations in isc_rwlock to release-acquire memory ordering
The memory ordering in the rwlock was all wrong, I am copying excerpts
from the https://en.cppreference.com/w/c/atomic/memory_order#Relaxed_ordering
for the convenience of the reader:

  Relaxed ordering

  Atomic operations tagged memory_order_relaxed are not synchronization
  operations; they do not impose an order among concurrent memory
  accesses. They only guarantee atomicity and modification order
  consistency.

  Release-Acquire ordering

  If an atomic store in thread A is tagged memory_order_release and an
  atomic load in thread B from the same variable is tagged
  memory_order_acquire, all memory writes (non-atomic and relaxed atomic)
  that happened-before the atomic store from the point of view of thread
  A, become visible side-effects in thread B. That is, once the atomic
  load is completed, thread B is guaranteed to see everything thread A
  wrote to memory.

  The synchronization is established only between the threads releasing
  and acquiring the same atomic variable. Other threads can see different
  order of memory accesses than either or both of the synchronized
  threads.

Which basically means that we had no or weak synchronization between
threads using the same variables in the rwlock structure.  There should
not be a significant performance drop because the critical sections were
already protected by:

  while(1) {
    if (relaxed_atomic_operation) {
      break;
    }
    LOCK(lock);
    if (!relaxed_atomic_operation) {
      WAIT(sem, lock);
    }
    UNLOCK(lock)l
  }

I would add one more thing to "Don't do your own crypto, folks.":

  - Also don't do your own locking, folks.
2020-02-11 11:50:04 +01:00
Ondřej SurýandOndřej Surý 1da0994ea4 Make isc_rwlock.c thread-safe
The ThreadSanitizer found several possible data races in our rwlock
implementation.  This commit changes all the unprotected variables to atomic and
also changes the explicit memory ordering (atomic_<foo>_explicit(..., <order>)
functions to use our convenience macros (atomic_<foo>_<order>).
2020-02-11 11:49:01 +01:00
Ondřej SurýandMichał Kępień 95130a379c 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.

(cherry picked from commit a5c87d9d18)
2020-02-11 10:32:11 +01:00
Ondřej Surý bffdf9c58d Fix comparison between type uint16_t and wider type size_t in a loop
Found by LGTM.com (see below for description), and while it should not
happen as EDNS OPT RDLEN is uint16_t, the fix is easy.  A little bit
of cleanup is included too.

> In a loop condition, comparison of a value of a narrow type with a value
> of a wide type may result in unexpected behavior if the wider value is
> sufficiently large (or small). This is because the narrower value may
> overflow. This can lead to an infinite loop.

(cherry picked from commit a9bd6f6ea6)
2020-02-10 02:42:50 -08:00
Ondřej Surý 3828d4e3e9 Clean the ENTER/EXIT/NOTICE debugging from production code
(cherry picked from commit 5b448996e5)
2020-02-08 11:37:42 -08:00
Ondřej Surý 5391187fd4 Refactor parts of isc_httpd and isc_httpd for better readability and safety
(cherry picked from commit 9643a62dd5)
2020-02-08 11:37:42 -08:00
Mark AndrewsandOndřej Surý f5be6c8877 add ISC_MAGIC and reference counting to httpd and httpdmgr
(cherry picked from commit 7c3f419d66)
2020-02-08 11:37:42 -08:00
Mark Andrews 76df419b27 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));

(cherry picked from commit e8bf82efc6)
2020-02-07 21:43:26 +11:00
Mark Andrews a6f09283cd Fix indenting.
(cherry picked from commit 98d5109e82)
2020-02-07 21:43:26 +11:00
Michal Nowak 8a47de5110 Windows: Prevent tools from clashing with named in system tests
In system tests on Windows tool's local port can sometimes clash with
'named'. On Unix the system is poked for the minimal local port,
otherwise is set to 32768 as a sane minimum. For Windows we don't
poke but set a hardcoded limit; this change aligns the limit with
Unix and changes it to 32768.

(cherry picked from commit ed7fe5fae3b22d136f0a5a92ea3b67536b10a5ce)
2020-02-05 11:07:18 +00:00
Matthijs Mekking 6799f2208f more_frags: check for basic blocks != NULL 2020-02-05 09:08:35 +01:00
Matthijs Mekking 076585e611 Fix build
Restore cleanup: label in dns_client_startrequest because it still has one
goto for it.
2020-02-05 09:08:35 +01:00
Matthijs Mekking 6b9f9a0b52 Add a note on memory allocation
isc__memalloc_t must deal with memory allocation failure
and must never return NULL.

(cherry picked from commit b8be29fee6)
2020-02-05 09:08:35 +01:00
Ondřej SurýandMatthijs Mekking 49edf175fe Suppress cppcheck false positive nullPointerArithmeticRedundantCheck
(cherry picked from commit c00def343f)
2020-02-05 09:08:35 +01:00
Ondřej SurýandMatthijs Mekking 5f4ca46d50 Change pk11_mem_get() so it cannot soft-fail
(cherry picked from commit 05ae2e48ab)
2020-02-05 09:08:35 +01:00
Ondřej SurýandMatthijs Mekking 1b9a7a17d9 Make the DbC checks to be consistent and cppcheck clean
(cherry picked from commit 478e4ac201)
2020-02-05 09:08:35 +01:00
Mark AndrewsandMatthijs Mekking da02ff9d08 isc_mem_get cannot fail
(cherry picked from commit bb65e57297)
2020-02-05 09:08:35 +01:00
Mark AndrewsandMatthijs Mekking c2ce468734 delay assignment until after REQUIRE
(cherry picked from commit d6de520bd1)
2020-02-05 09:08:35 +01:00
Mark AndrewsandMatthijs Mekking e515ac325e skip if first is NULL
(cherry picked from commit 704b9ee9d0)
2020-02-05 09:08:35 +01:00
Mark AndrewsandMatthijs Mekking 71a55892eb delay assignment until after REQUIRE
(cherry picked from commit c65c06301c)
2020-02-05 09:08:35 +01:00
Mark AndrewsandMatthijs Mekking 8251141baa remove brackets
(cherry picked from commit 7b948c7335)
2020-02-05 09:08:35 +01:00
Mark AndrewsandMatthijs Mekking 123371e1e7 simplify ISC_LIKELY/ISC_UNLIKELY for CPPCHECK
(cherry picked from commit 6c2e138d7a)
2020-02-05 09:08:35 +01:00
Mark AndrewsandMatthijs Mekking 30492c2d40 simplify RUNTIME_CHECK for cppcheck
(cherry picked from commit 668a972d1e)
2020-02-05 09:08:35 +01:00
Evan Hunt 68eb6c1bb9 Correctly handle catalog zone entries containing slashes
- Add quotes before and after zone name when generating "addzone"
  input so avoid "unexpected token" errors.
- Use a hex digest for zone filenames when the zone or view name
  contains a slash.
- Test with a domain name containing a slash.
- Incidentally added 'catzhash.py' to contrib/scripts to generate
  hash labels for catalog zones, as it was needed to write the test.

(cherry picked from commit dba0163dac)
2020-02-03 19:19:45 -08:00
Mark Andrews e79a87566d use anonomous constants
(cherry picked from commit 02c2fc5ad3)
2020-01-31 00:15:16 +11:00
Mark Andrews 5432e365d5 use enum
(cherry picked from commit 7c0d9dac9f)
2020-01-31 00:15:16 +11:00
Mark Andrews 3a87b02b1a style
(cherry picked from commit 279f6b01de)
2020-01-31 00:15:16 +11:00
Mark Andrews c2a2e1f454 return the correct error code for the type being checked
(cherry picked from commit a09c464a20)
2020-01-31 00:15:16 +11:00
Mark Andrews 735dfc1ab8 check that a CDNSKEY deletion record is accepted
(cherry picked from commit f91b3a69ce)
2020-01-31 00:15:16 +11:00
Mark Andrews 103cd665e1 handle CDS deletion record in consistancy checks
(cherry picked from commit 0adb4b25d3)
2020-01-31 00:15:15 +11:00
Tinderbox UserandEvan Hunt 0ec9ae77a8 prep 9.14.10
Update the API files.
- lib/dns:
  - struct resolver has added elements, this is an interface change
    and thus LIBINTERFACE is incremented, and LIBREVISION is reset.
  - Since this also means an interface change since the last public
    release, also reset LIBAGE.
- lib/isccfg:
  - The library source code changed, so increment LIBREVISION.
- lib/ns:
  - The library source code changed, so increment LIBREVISION.

Update other files:
- No changes needed to the README, this is a small bugfix release.
2020-01-27 11:06:04 -08:00
Tony FinchandMark Andrews bee4599f90 Send NOFITY messages after deleting private-type records.
The `rndc signing -clear` command cleans up the private-type records
that keep track of zone signing activity, but before this change it
did not tell the secondary servers that the zone has changed.

(cherry picked from commit f3f7b7df5d)
2020-01-24 00:02:44 +11:00
Diego FronzaandEvan Hunt 150b98d185 Fixed crash when querying for non existing domain in chaos class
Function dns_view_findzonecut in view.c wasn't correctly handling
classes other than IN (chaos, hesiod, etc) whenever the name being
looked up wasn't in cache or in any of the configured zone views' database.

That resulted in a NULL fname being used in resolver.c:4900, which
in turn was triggering abort.

(cherry picked from commit 85555f29d7)
2020-01-22 12:25:33 -08:00
Mark Andrews 2db5a2539a dnssec: do not publish CDS records when -Psync is in the future
This is a bug I encountered when trying to schedule an algorithm
rollover. My plan, for a zone whose maximum TTL is 48h, was to sign
with the new algorithm and schedule a change of CDS records for more
than 48 hours in the future, roughly like this:

    $ dnssec-keygen -a 13 -fk -Psync now+50h $zone
    $ dnssec-keygen -a 13 $zone
    $ dnssec-settime -Dsync now+50h $zone_ksk_old

However the algorithm 13 CDS was published immediately, which could
have made the zone bogus.

To reveal the bug using the `smartsign` test, this change just adds a
KSK with all its times in the future, so it should not affect the
existing checks at all. But the final check (that there are no CDS or
CDSNSKEY records after -Dsync) fails with the old `syncpublish()`
logic, because the future key's sync records appear early. With the
new `syncpublish()` logic the future key does not affect the test, as
expected, and it now passes.

(cherry picked from commit 4227b7969b)
2020-01-21 23:04:16 +00:00
Tony FinchandMark Andrews 5c2573c1ad Omit spurious newlines when reporting DNSKEY changes
These caused blank lines to appear in the logs.

(cherry picked from commit 3b1bd3f48b)
2020-01-21 16:28:24 +11:00
Mark AndrewsandOndřej Surý 2ec9d87b20 exercise dns_rdata_checknames
(cherry picked from commit b3c1b2a869)
2020-01-14 08:07:38 +00:00
Mark AndrewsandOndřej Surý ff4b0af279 exercise dns_rdata_additionaldata
(cherry picked from commit 649a34d628)
2020-01-14 08:07:38 +00:00
Mark AndrewsandOndřej Surý aa0ea40182 call dns_rdata_towire on valid output from dns_rdata_fromtext and dns_rdata_fromwire
(cherry picked from commit 5e74550740)
2020-01-14 08:07:38 +00:00
Mark AndrewsandOndřej Surý 067b9f8d31 Add is_leaf and send_to_prune_tree.
Add is_leaf and send_to_prune_tree to make the logic easier
to understand in cleanup_dead_nodes and decrement_reference.

(cherry picked from commit c6efc0e50f)
2020-01-14 08:36:02 +01:00
Mark AndrewsandOndřej Surý d7593feb46 Testing node->down requires the tree lock to be held.
In decrement_reference only test node->down if the tree lock
is held.  As node->down is not always tested in
decrement_reference we need to test that it is non NULL in
cleanup_dead_nodes prior to removing the node from the rbt
tree.  Additionally it is not always possible to aquire the
node lock and reactivate a node when adding parent nodes.
Reactivate such nodes in cleanup_dead_nodes if required.

(cherry picked from commit 176b23b6cd)
2020-01-14 08:36:02 +01:00
Michał Kępień 814da1c808 Properly detect MMDB lookup failures
Only comparing the value of the integer passed as the last argument to
MMDB_lookup_sockaddr() against MMDB_SUCCESS is not enough to ensure that
an MMDB lookup was successful - the 'found_entry' field of the
MMDB_lookup_result_s structure returned by that function also needs to
be true or else the remaining contents of that structure should be
ignored as the lookup failed.  Extend the relevant logical condition in
get_entry_for() to ensure the latter does not return incorrect MMDB
entries for IP addresses which do not belong to any subnet defined in a
given GeoIP2 database.

(cherry picked from commit ec8334fb74)
2020-01-13 14:36:58 +01:00
Michał Kępień 11ff0537e1 Bind to random port numbers in unit tests
Some unit tests need various managers to be created before they are run.
The interface manager spawned during libns tests listens on a fixed port
number, which causes intermittent issues when multiple tests using an
interface manager are run concurrently.  Make the interface manager
listen on a randomized port number to greatly reduce the risk of
multiple unit tests using the same port concurrently.

(cherry picked from commit ea7bddb4ca)
2020-01-09 10:44:28 +01:00
Mark Andrews ebc43d8d66 remove duplicate #includes
(cherry picked from commit 848c1c8b8b)
2019-12-23 08:20:35 +11:00
Mark Andrews 171f2ab8d6 revert d10fbdec for lib/dns/gen.c as it is a build platform executable
(cherry picked from commit 7278f2529a)
2019-12-23 08:20:35 +11:00
Mark Andrews 7f04f2f252 Refactor loop body as copy_non_dnssec_records.
(cherry picked from commit d26e125438)
2019-12-20 22:05:24 +11:00
Ondřej SurýandMark Andrews 364f232da8 Add failure handling when iterators don't end with ISC_R_NOMORE
(cherry picked from commit bff83b9480)
2019-12-20 22:02:32 +11:00
Ondřej SurýandMark Andrews a2cf6090b2 Refactor receive_secure_db to make the variables and code flow around the iterator more local
(cherry picked from commit 6012479419)
2019-12-20 22:02:32 +11:00
Mark Andrews 37567e0106 Call dns_dbiterator_destroy earlier to prevent potential deadlock.
(cherry picked from commit 9d8f9cc8f2)
2019-12-20 22:02:32 +11:00