2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

33814 Commits

Author SHA1 Message Date
Ondřej Surý
4f2ca15201 Add CHANGES note for GL #2396 2021-02-25 16:21:43 +01:00
Ondřej Surý
a0181056a8 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.
2021-02-25 16:21:10 +01:00
Ondřej Surý
bea333f7c9 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.
2021-02-25 16:21:10 +01:00
Ondřej Surý
cbbecfcc82 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]
2021-02-25 16:21:10 +01:00
Matthijs Mekking
6dbdffd7b8 Merge branch '2503-stale-answer-client-timeout-crash' into 'main'
Resolve "New stale-answer-client-timeout crashes BIND 9.16 and 9.17"

Closes #2503

See merge request isc-projects/bind9!4714
2021-02-25 11:03:13 +00:00
Matthijs Mekking
a404eaaffd Add CHANGES and release notes for GL #2503 2021-02-25 11:32:53 +01:00
Matthijs Mekking
f8b7b597e9 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.
2021-02-25 11:32:17 +01:00
Matthijs Mekking
9e061faaae 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.
2021-02-25 11:32:17 +01:00
Matthijs Mekking
e53af87f2c Merge branch '2498-nsec3-dynamic-update-dnssec-policy' into 'main'
Resolve "Regression in BIND 9.16.10, DNSSEC fails due to improper NSEC3 creation witihin named"

Closes #2498

See merge request isc-projects/bind9!4739
2021-02-25 09:49:29 +00:00
Matthijs Mekking
89c47b3b42 Add changes and notes for [#2498] 2021-02-25 17:21:17 +11:00
Matthijs Mekking
4b176c850b 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.
2021-02-25 17:21:17 +11:00
Matthijs Mekking
0c0f10b53f 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.
2021-02-25 17:21:17 +11:00
Mark Andrews
95cf93081c Merge branch '2507-cid-320483-api-usage-errors-lock' into 'main'
Resolve "CID 320483:  API usage errors  (LOCK)"

Closes #2507

See merge request isc-projects/bind9!4721
2021-02-25 05:54:20 +00:00
Mark Andrews
3ac53daa06 Address unbalanced lock/unlock
Also address race between reading and testing mpctx->allocated
and incrementing mpctx->allocated.
2021-02-25 13:08:07 +11:00
Ondřej Surý
965848a11a Merge branch '2519-disable-assertion-in-DLL_THREAD_ATTACH-DLL_THREAD_DETACH' into 'main'
Disable safe-guard assertion in DLL_THREAD_ATTACH/DLL_THREAD_DETACH

Closes #2519

See merge request isc-projects/bind9!4738
2021-02-24 08:03:16 +00:00
Ondřej Surý
c5887c4312 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-24 08:31:42 +01:00
Mark Andrews
de00c105bb Merge branch 'marka-placeholder' into 'main'
add placeholder

See merge request isc-projects/bind9!4737
2021-02-23 22:53:34 +00:00
Mark Andrews
57c70624d9 add placeholder 2021-02-24 09:49:27 +11:00
Michal Nowak
6a21522579 Merge branch '2446-query-c-5430-16-runtime-error' into 'main'
Initialize checknames field in dns_view_create()

Closes #2446

See merge request isc-projects/bind9!4706
2021-02-23 15:43:50 +00:00
Michal Nowak
0c6fa16477
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'
2021-02-23 16:08:13 +01:00
Michal Nowak
40b6db58a1
Revert "Initialize checknames field in query_test.c"
This reverts commit c75484c4dff04698c183b456a6cc85f951264e75.
2021-02-23 16:08:13 +01:00
Michal Nowak
efe11d4383
Initialize checknames field in query_test.c
'checknames' field of struct dns_view is not initialized by
dns_view_create(). ASAN identified this as runtime error:

    runtime error: load of value 190, which is not a valid value for type '_Bool'
2021-02-23 16:08:13 +01:00
Michal Nowak
63c7300f97 Merge branch 'mnowak/alpine-3.13' into 'main'
Add Alpine Linux 3.13

See merge request isc-projects/bind9!4724
2021-02-23 14:45:19 +00:00
Michal Nowak
909c85f7a9
Add Alpine Linux 3.13 2021-02-23 15:33:59 +01:00
Michal Nowak
ed13fb7ad2 Merge branch 'mnowak/pairwise-pict-keep-stderr' into 'main'
Do not remove stderr from pict output

See merge request isc-projects/bind9!4727
2021-02-23 14:25:38 +00:00
Michal Nowak
079debaa10
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
2021-02-23 15:23:58 +01:00
Mark Andrews
076bb4f989 Merge branch '2508-cid-320481-null-pointer-dereferences-reverse_inull' into 'main'
Resolve "CID 320481:  Null pointer dereferences  (REVERSE_INULL)"

Closes #2508

See merge request isc-projects/bind9!4722
2021-02-23 13:04:38 +00:00
Mark Andrews
658c950d7b Silence CID 320481: Null pointer dereferences
*** CID 320481:  Null pointer dereferences  (REVERSE_INULL)
    /bin/tests/wire_test.c: 261 in main()
    255     			process_message(input);
    256     		}
    257     	} else {
    258     		process_message(input);
    259     	}
    260
       CID 320481:  Null pointer dereferences  (REVERSE_INULL)
       Null-checking "input" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    261     	if (input != NULL) {
    262     		isc_buffer_free(&input);
    263     	}
    264
    265     	if (printmemstats) {
    266     		isc_mem_stats(mctx, stdout);
2021-02-23 12:45:45 +00:00
Mark Andrews
3e9fba94e3 Merge branch '2493-cid-281450-dereference-before-null-check-reverse_inull' into 'main'
Resolve "CID 281450: Dereference before null check (REVERSE_INULL)"

Closes #2493

See merge request isc-projects/bind9!4684
2021-02-23 12:40:56 +00:00
Mark Andrews
5fb168fab3 Silence CID 281450: Dereference before null check
remove redundant 'inst != NULL' test

    162cleanup:

    CID 281450 (#1 of 1): Dereference before null check (REVERSE_INULL)
    check_after_deref: Null-checking inst suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    163        if (result != ISC_R_SUCCESS && inst != NULL) {
    164                plugin_destroy((void **)&inst);
    165        }
2021-02-23 11:58:40 +00:00
Mark Andrews
441aadab6c Merge branch '2492-304936-dereference-before-null-check' into 'main'
Resolve "CID 304936: Dereference before null check"

Closes #2492

See merge request isc-projects/bind9!4683
2021-02-23 11:57:29 +00:00
Mark Andrews
c4906be2d4 Silence CID 304936 Dereference before null check
Removed redundant 'listener != NULL' check.

    1191cleanup:

    CID 304936 (#1 of 1): Dereference before null check (REVERSE_INULL)
    check_after_deref: Null-checking listener suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
    1192        if (listener != NULL) {
    1193                isc_refcount_decrement(&listener->refs);
    1194                listener->exiting = true;
    1195                free_listener(listener);
    1196        }
2021-02-23 11:39:00 +00:00
Matthijs Mekking
5cadcff801 Merge branch '2408-dnssec-policy-purge-keys' into 'main'
Resolve "kasp: Purge deleted keys"

Closes #2408

See merge request isc-projects/bind9!4665
2021-02-23 09:37:56 +00:00
Matthijs Mekking
5a99a124fb Add changes and notes for [#2408] 2021-02-23 09:17:24 +01:00
Matthijs Mekking
5be26898c0 Minor kasp test fixes
Two minor fixes in the kasp system test:

1. A wrong comment in ns3/setup.sh (we are subtracting 2 hours, not
   adding them).
2. 'get_keyids' used bad parameters "$1" "$2" when 'check_numkeys'
   failed. Also, 'check_numkeys' can use $DIR, $ZONE, and $NUMKEYS
   directly, no need to pass them.
2021-02-23 09:16:48 +01:00
Matthijs Mekking
6333ff15f0 Test purge-keys option
Add some more zones to the kasp system test to test the 'purge-keys'
option. Three zones test that the predecessor key files are removed
after the purge keys interval, one test checks that the key files
are retained if 'purge-keys' is disabled. For that, we change the
times to 90 days in the past (the default value for 'purge-keys').
2021-02-23 09:16:48 +01:00
Matthijs Mekking
8c526cb67f Purge keys implementation
On each keymgr run, we now also check if key files can be removed.
The 'purge-keys' interval determines how long keys should be retained
after they have become completely hidden.

Key files should not be removed if it has a state that is set to
something else then HIDDEN, if purge-keys is 0 (disabled), if
the key goal is set to OMNIPRESENT, or if the key is unused (a key is
unused if no timing metadata set, and no states are set or if set,
they are set to HIDDEN).

If the last changed timing metadata plus the purge-keys interval is
in the past, the key files may be removed.

Add a dst_key_t variable 'purge' to signal that the key file should
not be written to file again.
2021-02-23 09:16:48 +01:00
Matthijs Mekking
313de3a7e2 Add purge-keys config option
Add a new option 'purge-keys' to 'dnssec-policy' that will purge key
files for deleted keys. The option determines how long key files
should be retained prior to removing the corresponding files from
disk.

If set to 0, the option is disabled and 'named' will not remove key
files from disk.
2021-02-23 09:16:48 +01:00
Mark Andrews
d4cb312555 Merge branch '2509-cid-281489-resource-leaks-resource_leak' into 'main'
Resolve "CID 281489:  Resource leaks  (RESOURCE_LEAK)"

Closes #2509

See merge request isc-projects/bind9!4723
2021-02-22 22:39:23 +00:00
Mark Andrews
003dd8cc70 Address theoretical resource leak in dns_dt_open()
dns_dt_open() is not currently called with mode dns_dtmode_unix.

    *** CID 281489:  Resource leaks  (RESOURCE_LEAK)
    /lib/dns/dnstap.c: 983 in dns_dt_open()
    977
    978     		if (!dnstap_file(handle->reader)) {
    979     			CHECK(DNS_R_BADDNSTAP);
    980     		}
    981     		break;
    982     	case dns_dtmode_unix:
       CID 281489:  Resource leaks  (RESOURCE_LEAK)
       Variable "handle" going out of scope leaks the storage it points to.
    983     		return (ISC_R_NOTIMPLEMENTED);
    984     	default:
    985     		INSIST(0);
    986     		ISC_UNREACHABLE();
    987     	}
    988
2021-02-22 12:22:31 +11:00
Ondřej Surý
bb124d6056 Merge branch 'ondrej/add-tls_p.h-to-Makefile.am' into 'main'
Include lib/isc/tls_p.h in release tarballs

See merge request isc-projects/bind9!4716
2021-02-19 12:30:50 +00:00
Ondřej Surý
f53e7ed12c Include lib/isc/tls_p.h in release tarballs
The addition of lib/isc/tls_p.h to the source tree was not accounted for
in the relevant variable in lib/isc/Makefile.am and thus the former file
is not being included in release tarballs prepared using "make dist".
Fix by tweaking the libisc_la_SOURCES list in lib/isc/Makefile.am
accordingly.
2021-02-19 13:25:18 +01:00
Michał Kępień
5d473f92ed Merge branch '2504-do-not-require-libtool-in-PATH-at-build-time' into 'main'
Do not require libtool in PATH at build time

Closes #2504

See merge request isc-projects/bind9!4715
2021-02-19 12:09:48 +00:00
Michał Kępień
c8bddd2e64 Add CHANGES entry 2021-02-19 11:52:56 +01:00
Michał Kępień
b630c698f9 Do not require libtool in PATH at build time
The build-time requirement for libtool was introduced inadvertently:

 1. Commit 1628f5865acb2d472ce4adf71fc78ac99094fa1c added a check to
    configure.ac which claims to test whether the libtool script is
    available.  There are two problems with that check:

      - it is effectively a no-op as the AC_PROG_LIBTOOL() macro always
        sets the LIBTOOL variable [1],

      - this check was intended to be performed before autoreconf is
        run, not when ./configure is run; the libtool script is supposed
        to be dynamically generated by ./configure on the build host and
        thus there is no need for a standalone libtool script to be
        installed system-wide on every host attempting to build BIND 9
        e.g. from a tarball produced by "make dist".

 2. Commit a7982d14dddb864420deb49e735f782022d1fa07 was based on the
    incorrect assumption that the AC_PROG_LIBTOOL() macro looks for the
    libtool binary in PATH and sets the LIBTOOL variable accordingly,
    which is what other AC_PROG_*() macros do.  Meanwhile, the
    AC_PROG_LIBTOOL() macro only initializes libtool for use with
    Automake.  It is not necessary for a standalone libtool script to be
    available in PATH on the build host when ./configure is run.

Do not look for libtool in PATH at build time as it prevents hosts
without a libtool script available system-wide from building BIND 9 from
source tarballs prepared using "make dist".  Note that libtool m4
macros, utilities, etc. still need to be present on a given host if
autoreconf is to be run on it.

[1] https://git.savannah.gnu.org/cgit/libtool.git/tree/m4/libtool.m4?h=v2.4.6#n89
2021-02-19 11:52:56 +01:00
Mark Andrews
0b8d2bfb4c Merge branch '2499-a-loc-record-with-a-invalid-direction-field-triggers-an-insist' into 'main'
Resolve "A LOC record with a invalid direction field triggers an INSIST"

Closes #2499

See merge request isc-projects/bind9!4704
2021-02-18 22:37:41 +00:00
Mark Andrews
3d340ecfd2 Add release note for [GL #2499] 2021-02-19 09:18:08 +11:00
Mark Andrews
6f47e0956c Add CHANGES for [GL #2499] 2021-02-19 09:18:06 +11:00
Mark Andrews
009358d77d Correctly detect when get_direction failed 2021-02-19 09:17:32 +11:00
Mark Andrews
07902d9f9d Test a LOC record with an invalid direction field 2021-02-19 09:17:32 +11:00