Commit Graph

32871 Commits

Author SHA1 Message Date
Michal Nowak
588dae8e2b Add CHANGES entry for GL #2357
(cherry picked from commit d98f72de25)
2021-03-04 13:16:26 +01:00
Ondřej Surý
2f48007d18 Merge branch '2298-multiple-definition-of-librpz_dnsrpzd_path-v9_16' into 'v9_16'
Resolve "multiple definition of `librpz_dnsrpzd_path'"

See merge request isc-projects/bind9!4764
2021-03-04 11:00:12 +00:00
Mark Andrews
a33d603cff Add CHANGES for [GL #2298]
(cherry picked from commit e12cf5eb57)
2021-03-04 11:28:49 +01:00
Mark Andrews
985566fea5 Fixed librpz_dnsrpzd_path being a duplicate symbol
librpz_dnsrpzd_path should have been declared extern in dns/librpz.h

(cherry picked from commit 8f016dd57a)
2021-03-04 11:28:49 +01:00
Ondřej Surý
6f975dc810 Merge branch '2551-char-is-unsigned-on-arm64-v9_16' into 'v9_16'
Use int type to store result from isc_commandline_parse()

See merge request isc-projects/bind9!4767
2021-03-04 10:24:56 +00:00
Ondřej Surý
7a8193efba Use int type to store result from isc_commandline_parse()
The C standard actually doesn't define char as signed or unsigned, and
it could be either according to underlying architecture.  It turns out
that while it's usually signed type, it isn't on arm64 where it's
unsigned.

isc_commandline_parse() return int, just use that instead of the char.

(cherry picked from commit 8153729d3a)
2021-03-04 11:21:26 +01:00
Evan Hunt
31cbf73bd4 Merge branch '2505-journal-compatibility-v9_16' into 'v9_16'
allow dns_journal_rollforward() to read old journal files

See merge request isc-projects/bind9!4763
2021-03-04 04:13:21 +00:00
Evan Hunt
c7d5329ae0 CHANGES, release note
(cherry picked from commit 82b82bb821)
2021-03-03 19:21:19 -08:00
Evan Hunt
bda028e0ee create 'journal' system test
tests that version 1 journal files containing version 1 transaction
headers are rolled forward correctly on server startup, then updated
into version 2 journals. also checks journal file consistency and
'max-journal-size' behavior.

(cherry picked from commit a0aefa1de6)
2021-03-03 19:21:16 -08:00
Evan Hunt
9f1f5abe0e print journal index data and test for consistency
'named-journalprint -x' now prints the journal's index table and
the offset of each transaction in the journal, so that index consistency
can be confirmed.

(cherry picked from commit a4972324a6)
2021-03-03 19:19:50 -08:00
Mark Andrews
5aea511e1b extend named-journalprint to be able to force the journal version
named-journalprint can now upgrade or downgrade a journal file
in place; the '-u' option upgrades and the '-d' option downgrades.

(cherry picked from commit fb2d0e2897)
2021-03-03 19:19:50 -08:00
Evan Hunt
47a274e9f1 allow dns_journal_rollforward() to read old journal files
when the 'max-ixfr-ratio' option was added, journal transaction
headers were revised to include a count of RR's in each transaction.
this made it impossible to read old journal files after an upgrade.

this branch restores the ability to read version 1 transaction
headers. when rolling forward, printing journal contents, if
the wrong transaction header format is found, we can switch.

when dns_journal_rollforward() detects a version 1 transaction
header, it returns DNS_R_RECOVERABLE.  this triggers zone_postload()
to force a rewrite of the journal file in the new format, and
also to schedule a dump of the zone database with minimal delay.
journal repair is done by dns_journal_compact(), which rewrites
the entire journal, ignoring 'max-journal-size'. journal size is
corrected later.

newly created journal files now have "BIND LOG V9.2" in their headers
instead of "BIND LOG V9". files with the new version string cannot be
read using the old transaction header format. note that this means
newly created journal files will be rejected by older versions of named.

named-journalprint now takes a "-x" option, causing it to print
transaction header information before each delta, including its
format version.

(cherry picked from commit ee19966326)
2021-03-03 19:19:50 -08:00
Matthijs Mekking
079294bd28 Merge branch '2443-cid-316608-memory-corruptions-overrun-v9_16' into 'v9_16'
Address theoretical buffer overrun in recent change

See merge request isc-projects/bind9!4761
2021-03-03 10:34:26 +00:00
Mark Andrews
7a703244ed Address theoretical buffer overrun in recent change
The strlcat() call was wrong.

    *** CID 316608:  Memory - corruptions  (OVERRUN)
    /lib/dns/resolver.c: 5017 in fctx_create()
    5011     	 * Make fctx->info point to a copy of a formatted string
    5012     	 * "name/type".
    5013     	 */
    5014     	dns_name_format(name, buf, sizeof(buf));
    5015     	dns_rdatatype_format(type, typebuf, sizeof(typebuf));
    5016     	p = strlcat(buf, "/", sizeof(buf));
    >>>     CID 316608:  Memory - corruptions  (OVERRUN)
    >>>     Calling "strlcat" with "buf + p" and "1036UL" is suspicious because "buf" points into a buffer of 1036 bytes and the function call may access "(char *)(buf + p) + 1035UL". [Note: The source code implementation of the function has been overridden by a builtin model.]
    5017     	strlcat(buf + p, typebuf, sizeof(buf));
    5018     	fctx->info = isc_mem_strdup(mctx, buf);
    5019
    5020     	FCTXTRACE("create");
    5021     	dns_name_init(&fctx->name, NULL);
    5022     	dns_name_dup(name, mctx, &fctx->name);

(cherry picked from commit 59bf6e71e2)
2021-03-03 10:55:38 +01:00
Ondřej Surý
2cc4e15788 Merge branch 'ondrej/call-isc__initialize-shutdown-from-DllMain-v9_16' into 'v9_16'
Call isc__initialize()/isc__shutdown() from win32 DllMain

See merge request isc-projects/bind9!4760
2021-03-02 08:23:26 +00:00
Ondřej Surý
59d92c8af8 Call isc__initialize()/isc__shutdown() from win32 DllMain
Call the libisc isc__initialize() constructor and isc__shutdown()
destructor from DllMain instead of having duplicate code between
those and DllMain() code.

(cherry picked from commit a50f5d0cf5)
2021-03-02 08:50:29 +01:00
Ondřej Surý
5ab6d1b30e Merge branch '2396-add-thread-trampoline-for-thread-accounting-v9_16' into 'v9_16'
Resolve "BIND 9.16 unit tests failing reliably on x86_64 NUMA machines"

See merge request isc-projects/bind9!4756
2021-02-26 20:39:25 +00:00
Ondřej Surý
ccc76ded78 Add CHANGES note for GL #2396
(cherry picked from commit 4f2ca15201)
2021-02-26 21:19:33 +01:00
Ondřej Surý
86298fd112 Make linker include library ctor/dtor in statically linked libisc
Under normal situation, the linker throws out all symbols from
compilation unit when no symbols are used in the final binary, which is
the case for lib/isc/lib.c.  This commit adds empty function to lib.c
that's being called from different CU (mem.c in this case) and that
makes the linker to include all the symbols including the normally
unreferenced isc__initialize() and isc__shutdown() in the final binary.
2021-02-26 21:19:33 +01:00
Ondřej Surý
f92b77ff0d Change the isc_thread_self() return type to uintptr_t
The pthread_self(), thrd_current() or GetCurrentThreadId() could
actually be a pointer, so we should rather convert the value into
uintptr_t instead of unsigned long.

(cherry picked from commit a0181056a8)
2021-02-26 21:14:17 +01:00
Ondřej Surý
0e90858d99 Use globally assigned thread_id in the isc_hp API
Convert the isc_hp API to use the globally available isc_tid_v instead
of locally defined tid_v.  This should solve most of the problems on
machines with many number of cores / CPUs.

(cherry picked from commit bea333f7c9)
2021-02-26 21:14:17 +01:00
Ondřej Surý
45c55b1e7e Add isc_trampoline API to have simple accounting around threads
The current isc_hp API uses internal tid_v variable that gets
incremented for each new thread using hazard pointers.  This tid_v
variable is then used as a index to global shared table with hazard
pointers state.  Since the tid_v is only incremented and never
decremented the table could overflow very quickly if we create set of
threads for short period of time, they finish the work and cease to
exist.  Then we create identical set of threads and so on and so on.
This is not a problem for a normal `named` operation as the set of
threads is stable, but the problematic place are the unit tests where we
test network manager or other APIs (task, timer) that create threads.

This commits adds a thin wrapper around any function called from
isc_thread_create() that adds unique-but-reusable small digit thread id
that can be used as index to f.e. hazard pointer tables.  The trampoline
wrapper ensures that the thread ids will be reused, so the highest
thread_id number doesn't grow indefinitely when threads are created and
destroyed and then created again.  This fixes the hazard pointer table
overflow on machines with many cores. [GL #2396]

(cherry picked from commit cbbecfcc82)
2021-02-26 21:14:17 +01:00
Evan Hunt
1fbdc8b45a Merge branch 'ondrej/improve-mempool-AddressSanitizer-integration-v9_16' into 'v9_16'
Improve allocation-deallocation tracking with AddressSanitizer (v9.16)

See merge request isc-projects/bind9!4750
2021-02-26 18:53:00 +00:00
Ondřej Surý
0bd834856e Enforce disabling internal memory allocator for AddressSanitizer
Disable the internal memory allocator when AddressSanitizer is in use.
The basic blocks in the internal memory allocator prevents
AddressSanitizer from properly tracking the allocations and
deallocations, so we need to ensure it has been disabled for any build
that has AddressSanitizer enabled.
2021-02-26 10:13:56 -08:00
Ondřej Surý
1cd14c4dec Add mempool get/put tracking with AddressSanitizer
When AddressSanitizer is in use, disable the internal mempool
implementation and redirect the isc_mempool_get to isc_mem_get
(and similarly for isc_mempool_put). This is the method recommended
by the AddressSanitizer authors for tracking allocations and
deallocations instead of custom poison/unpoison code (see
https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning).
2021-02-26 10:13:17 -08:00
Ondřej Surý
4649bc04d7 Merge branch '2433-cherry-pick-fixes' into 'v9_16'
Pull fixes TLS and initialization fixes

See merge request isc-projects/bind9!4755
2021-02-26 17:08:15 +00:00
Ondřej Surý
2011efa99d Disable safe-guard assertion in DLL_THREAD_ATTACH/DLL_THREAD_DETACH
The BIND 9 libraries on Windows define DllMain() optional entry point
into a dynamic-link library (DLL).  When the system starts or terminates
a process or thread, it calls the entry-point function for each loaded
DLL using the first thread of the process.

When the DLL is being loaded into the virtual address space of the
current process as a result of the process starting up, we make a call
to DisableThreadLibraryCalls() which should disable the
DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for the specified
dynamic-link library (DLL).

This seems not be the case because we never check the return value of
the DisableThreadLibraryCalls() call, and it could in fact fail.  The
DisableThreadLibraryCalls() function fails if the DLL specified by
hModule has active static thread local storage, or if hModule is an
invalid module handle.

In this commit, we remove the safe-guard assertion put in place for the
DLL_THREAD_ATTACH and DLL_THREAD_DETACH events and we just ignore them.
BIND 9 doesn't create/destroy enough threads for it actually to make any
difference, and in fact we do use static thread local storage in the
code.
2021-02-26 17:18:06 +01:00
Ondřej Surý
2f0f531ee8 Use library constructor/destructor to initialize OpenSSL
Instead of calling isc_tls_initialize()/isc_tls_destroy() explicitly use
gcc/clang attributes on POSIX and DLLMain on Windows to initialize and
shutdown OpenSSL library.

This resolves the issue when isc_nm_create() / isc_nm_destroy() was
called multiple times and it would call OpenSSL library destructors from
isc_nm_destroy().

At the same time, since we now have introduced the ctor/dtor for libisc,
this commit moves the isc_mem API initialization (the list of the
contexts) and changes the isc_mem_checkdestroyed() to schedule the
checking of memory context on library unload instead of executing the
code immediately.
2021-02-26 17:18:06 +01:00
Ondřej Surý
59d51cdeb6 Disable calling DllMain() on thread creation/destruction
Disables the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for
the specified dynamic-link library (DLL).  This can reduce the size of
the working set for some applications.
2021-02-26 17:07:15 +01:00
Ondřej Surý
6883d4bd08 Fix the invalid condition variable
Although harmless, the memmove() in tlsdns and tcpdns was guarded by a
current message length variable that was always bigger than 0 instead of
correct current buffer length remainder variable.
2021-02-26 17:07:09 +01:00
Ondřej Surý
6da91bf16c Move most of the OpenSSL initialization to isc_tls
Since we now require both libcrypto and libssl to be initialized for
netmgr, we move all the OpenSSL initialization code except the engine
initialization to isc_tls API.

The isc_tls_initialize() and isc_tls_destroy() has been made idempotent,
so they could be called multiple time.  However when isc_tls_destroy()
has been called, the isc_tls_initialize() could not be called again.
2021-02-26 17:07:01 +01:00
Ondřej Surý
19fb228782 Merge branch '2335-tlsdns-refactoring-v9_16' into 'v9_16'
Resolve "TLSDNS refactoring"

See merge request isc-projects/bind9!4754
2021-02-26 16:03:41 +00:00
Evan Hunt
e9abe76117 Add CHANGES note for #2335
(cherry picked from commit f472390bc2)
2021-02-26 16:14:50 +01:00
Ondřej Surý
effe3ee595 Refactor TLSDNS module to work with libuv/ssl directly
* Following the example set in 634bdfb16d, the tlsdns netmgr
  module now uses libuv and SSL primitives directly, rather than
  opening a TLS socket which opens a TCP socket, as the previous
  model was difficult to debug.  Closes #2335.

* Remove the netmgr tls layer (we will have to re-add it for DoH)

* Add isc_tls API to wrap the OpenSSL SSL_CTX object into libisc
  library; move the OpenSSL initialization/deinitialization from dstapi
  needed for OpenSSL 1.0.x to the isc_tls_{initialize,destroy}()

* Add couple of new shims needed for OpenSSL 1.0.x

* When LibreSSL is used, require at least version 2.7.0 that
  has the best OpenSSL 1.1.x compatibility and auto init/deinit

* Enforce OpenSSL 1.1.x usage on Windows

(cherry picked from commit e493e04c0f)
2021-02-26 16:14:50 +01:00
Matthijs Mekking
7537430847 Merge branch '2503-stale-answer-client-timeout-crash-v9_16' into 'v9_16'
Resolve "New stale-answer-client-timeout crashes BIND 9.16 and 9.17"

See merge request isc-projects/bind9!4747
2021-02-25 11:48:18 +00:00
Matthijs Mekking
bcadb31f44 Add CHANGES and release notes for GL #2503
(cherry picked from commit a404eaaffd)
2021-02-25 12:07:43 +01:00
Matthijs Mekking
acc95d4e1d Don't servfail on staleonly lookups
When a staleonly lookup doesn't find a satisfying answer, it should
not try to respond to the client.

This is not true when the initial lookup is staleonly (that is when
'stale-answer-client-timeout' is set to 0), because no resolver fetch
has been created at this point. In this case continue with the lookup
normally.

(cherry picked from commit f8b7b597e9)
2021-02-25 12:07:34 +01:00
Matthijs Mekking
84deb57bc3 Don't allow recursion on staleonly lookups
Fix a crash that can happen in the following scenario:

A client request is received. There is no data for it in the cache,
(not even stale data). A resolver fetch is created as part of
recursion.

Some time later, the fetch still hasn't completed, and
stale-answer-client-timeout is triggered. A staleonly lookup is
started. It will also find no data in the cache.

So 'query_lookup()' will call 'query_gotanswer()' with ISC_R_NOTFOUND,
so this will call 'query_notfound()' and this will start recursion.

We will eventually end up in 'ns_query_recurse()' and that requires
the client query fetch to be NULL:

    REQUIRE(client->query.fetch == NULL);

If the previously started fetch is still running this assertion
fails.

The crash is easily prevented by not requiring recursion for
staleonly lookups.

Also remove a redundant setting of the staleonly flag at the end of
'query_lookup_staleonly()' before destroying the query context.

Add a system test to catch this case.

(cherry picked from commit 9e061faaae)
2021-02-25 12:07:27 +01:00
Matthijs Mekking
c4c8f78b0a Merge branch '2498-nsec3-dynamic-update-dnssec-policy-v9_16' into 'v9_16'
Resolve "Regression in BIND 9.16.10, DNSSEC fails due to improper NSEC3 creation witihin named"

See merge request isc-projects/bind9!4746
2021-02-25 11:02:00 +00:00
Matthijs Mekking
8475d0bd61 Add changes and notes for [#2498]
(cherry picked from commit 89c47b3b42)
2021-02-25 10:56:46 +01:00
Matthijs Mekking
d51df34995 Fix dnssec-policy NSEC3 on dynamic zones
When applying dnssec-policy on a dynamic zone (e.g. that allows Dynamic
Updates), the NSEC3 parameters were put on the queue, but they were
not being processed (until a reload of the zone or reconfiguration).

Process the NSEC3PARAM queue on zone postload when handling a
dynamic zone.

(cherry picked from commit 4b176c850b)
2021-02-25 10:56:00 +01:00
Matthijs Mekking
ddfb9ea8c1 Add tests for NSEC3 on dynamic zones
GitLab issue #2498 is a bug report on NSEC3 with dynamic zones. Tests
for it in the nsec3 system test directory were missing.

(cherry picked from commit 0c0f10b53f)
2021-02-25 10:55:51 +01:00
Michal Nowak
a88846c664 Merge branch '2446-query-c-5430-16-runtime-error-v9_16' into 'v9_16'
[v9_16] Initialize checknames field in dns_view_create()

See merge request isc-projects/bind9!4735
2021-02-23 16:48:35 +00:00
Michal Nowak
b36690e750 Initialize checknames field in dns_view_create()
The 'checknames' field wasn't initialized in dns_view_create(), but it
should otherwise AddressSanitizer identifies the following runtime error
in query_test.c.

    runtime error: load of value 190, which is not a valid value for type '_Bool'

(cherry picked from commit 0c6fa16477)
2021-02-23 16:45:36 +01:00
Michal Nowak
da2a647ee1 Merge branch 'mnowak/alpine-3.13-fix-PLATFORMS' into 'v9_16'
Update Alpine Linux version in PLATFORMS file

See merge request isc-projects/bind9!4734
2021-02-23 15:19:55 +00:00
Michal Nowak
57112addf5 Update Alpine Linux version in PLATFORMS file
Commit 76cfefe3fc updated PLATFORMS.md
file, but failed to update the plain-text PLATFORMS file.
2021-02-23 16:11:13 +01:00
Michal Nowak
6b75d201c4 Merge branch 'mnowak/alpine-3.13-v9_16' into 'v9_16'
[v9_16] Add Alpine Linux 3.13

See merge request isc-projects/bind9!4732
2021-02-23 14:53:37 +00:00
Michal Nowak
76cfefe3fc Add Alpine Linux 3.13
(cherry picked from commit 909c85f7a9)
2021-02-23 15:46:42 +01:00
Michal Nowak
cc2db3a4a3 Merge branch 'mnowak/pairwise-pict-keep-stderr-v9_16' into 'v9_16'
[v9_16] Do not remove stderr from pict output

See merge request isc-projects/bind9!4730
2021-02-23 14:32:31 +00:00
Michal Nowak
2038d087bf Do not remove stderr from pict output
Removing stderr from the pict tool serves no purpose and drops valuable
information, we might use when debugging failed pairwise CI job, such
as:

    Input Error: A parameter names must be unique

(cherry picked from commit 079debaa10)
2021-02-23 15:26:19 +01:00