2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-28 21:17:54 +00:00

1503 Commits

Author SHA1 Message Date
Matthijs Mekking
8c0db909ee Warn if key lengths are out of range/predefined 2020-02-07 09:30:26 -08:00
Mark Andrews
891f24fa57 'dispatch' must be non NULL, remove test.
10067 cleanup:

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

10068        if (dispatch != NULL)
10069                isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
2020-02-05 18:37:17 +11:00
Mark Andrews
8456b5627d 'dctx' must be non NULL, remove test.
11030 cleanup:

	CID 1452705 (#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.

11031        if (dctx != NULL)
11032                dumpcontext_destroy(dctx);
11033        return (result);
2020-02-05 18:37:17 +11:00
Mark Andrews
b6c3a2f172 remove dead cleanup code.
13836        if (zone != NULL)
13837                dns_zone_detach(&zone);

     	null: At condition dz != NULL, the value of dz must be NULL.
     	dead_error_condition: The condition dz != NULL cannot be true.

13838        if (dz != NULL) {

	CID 1453456 (#1 of 1): Logically dead code (DEADCODE)
	dead_error_begin: Execution cannot reach this statement:
	dns_zone_detach(&dz->zone);.

13839                dns_zone_detach(&dz->zone);
13840                isc_mem_put(named_g_mctx, dz, sizeof(*dz));
13841        }
2020-02-05 18:37:17 +11:00
Ondřej Surý
c73e5866c4 Refactor the isc_buffer_allocate() usage using the semantic patch
The isc_buffer_allocate() function now cannot fail with ISC_R_MEMORY.
This commit removes all the checks on the return code using the semantic
patch from previous commit, as isc_buffer_allocate() now returns void.
2020-02-03 08:29:00 +01:00
Evan Hunt
b984a4b647 disable adding keys to keytable; only DS trust anchors can now be added
the internal keytable structure has not yet been changed, but
insertion of DS anchors is the only method now available.

NOTE: the keytable unit test is currently failing because of tests
that expect individual keynode objects to contain single DST key
objects.
2020-01-14 09:24:22 -08:00
Evan Hunt
7fdf40770f remove all code that uses non-DS trust anchors
as initial-key and static-key trust anchors will now be stored as a
DS rrset, code referencing keynodes storing DNSKEY trust anchors will
no longer be reached.
2020-01-14 09:24:13 -08:00
Evan Hunt
80a5c9f5c8 associate socket stats counters with netmgr socket objects
- the socket stat counters have been moved from socket.h to stats.h.
- isc_nm_t now attaches to the same stats counter group as
  isc_socketmgr_t, so that both managers can increment the same
  set of statistics
- isc__nmsocket_init() now takes an interface as a paramter so that
  the address family can be determined when initializing the socket.
- based on the address family and socket type, a group of statistics
  counters will be associated with the socket - for example, UDP4Active
  with IPv4 UDP sockets and TCP6Active with IPv6 TCP sockets.  note
  that no counters are currently associated with TCPDNS sockets; those
  stats will be handled by the underlying TCP socket.
- the counters are not actually used by netmgr sockets yet; counter
  increment and decrement calls will be added in a later commit.
2020-01-13 14:05:02 -08:00
Tony Finch
5b600c2cd8 Fix line spacing in rndc secroots
Before this change, there was a missing blank line between the
negative trust anchors for one view, and the heading line for the next
view. This is because dns_ntatable_totext() omits the last newline.
There is an example of the incorrect output below; the fixed output
has a blank line before "Start view auth".

secure roots as of 21-Oct-2019 12:03:23.500:

 Start view rec
   Secure roots:

./RSASHA256/20326 ; managed

   Negative trust anchors:

example.com: expiry 21-Oct-2019 13:03:15.000
 Start view auth
   Secure roots:

./RSASHA256/20326 ; managed

   Negative trust anchors:

example.com: expiry 21-Oct-2019 13:03:07.000
2020-01-13 05:48:09 +00:00
Matthijs Mekking
eddac8575d Minor fixes in trust anchor code
This commit makes some minor changes to the trust anchor code:

1. Replace the undescriptive n1, n2 and n3 identifiers with slightly
   better rdata1, rdata2, and rdata3.
2. Fix an occurrence where in the error log message a static number
   32 was printed, rather than the rdata3 length.
3. Add a default case to the switch statement checking DS digest
   algorithms to catch unknown algorithms.
2019-12-06 07:12:24 +00:00
Matthijs Mekking
8c37d3d320 Rename 'dnssec-keys' to 'trust-anchors' 2019-12-05 12:19:17 +01:00
Ondřej Surý
a4ffb64073 Refactor the dns_geoip API to use ISC_THREAD_LOCAL
Previously, the dns_geoip API used isc_thread_key API for TLS, which is
fairly complicated and requires initialization of memory contexts, etc.
This part of code was refactored to use a ISC_THREAD_LOCAL pointer which
greatly simplifies the whole code related to storing TLS variables, and
creating the local memory context was moved to named and stored in the
named_g_geoip global context.
2019-12-04 14:17:19 +01:00
Ondřej Surý
4a3d589403 Refactor the dns_dt API to use ISC_THREAD_LOCAL
Previously, the dns_dt API used isc_thread_key API for TLS, which is
fairly complicated and requires initialization of memory contexts, etc.
This part of code was refactored to use a ISC_THREAD_LOCAL pointer which
greatly simplifies the whole code related to storing TLS variables.
2019-12-03 16:27:30 +01:00
Michał Kępień
670afbe84a Fix GeoIP2 memory leak upon reconfiguration
Loaded GeoIP2 databases are only released when named is shut down, but
not during server reconfiguration.  This causes memory to be leaked
every time "rndc reconfig" or "rndc reload" is used, as long as any
GeoIP2 database is in use.  Fix by releasing any loaded GeoIP2 databases
before reloading them.  Do not call dns_geoip_shutdown() until server
shutdown as that function releases the memory context used for caching
GeoIP2 lookup results.
2019-12-02 15:15:06 +01:00
Ondřej Surý
edd97cddc1 Refactor dns_name_dup() usage using the semantic patch 2019-11-29 14:00:37 +01:00
Ondřej Surý
952d7fde63 Request exclusive access when crashing via fatal()
When loading the configuration fails, there might be already other tasks
running and calling OpenSSL library functions.  The OpenSSL on_exit
handler is called when exiting the main process and there's a timing
race between the on_exit function that destroys OpenSSL allocated
resources (threads, locks, ...) and other tasks accessing the very same
resources leading to a crash in the system threading library. Therefore,
the fatal() function needs to request exlusive access to the task
manager to finish the already running tasks and exit only when no other
tasks are running.
2019-11-26 12:47:01 +01:00
Evan Hunt
199bd6b623 netmgr: make TCP timeouts configurable
- restore support for tcp-initial-timeout, tcp-idle-timeout,
  tcp-keepalive-timeout and tcp-advertised-timeout configuration
  options, which were ineffective previously.
2019-11-22 16:46:31 -08:00
Ondřej Surý
e95af30b23 Make lib/ns Thread Sanitizer clean 2019-11-17 17:42:41 -08:00
Evan Hunt
edafbf1c0f fix root key sentinel code to send the correct key ID for DS trust anchors 2019-11-15 15:47:57 -08:00
Evan Hunt
a8f89e9a9f use DS-style trust anchor to verify 5011 key refresh query
note: this also needs further refactoring.

- when initializing RFC 5011 for a name, we populate the managed-keys
  zone with KEYDATA records derived from the initial-key trust anchors.

  however, with initial-ds trust anchors, there is no key. but the
  managed-keys zone still must have a KEYDATA record for the name,
  otherwise zone_refreshkeys() won't refresh that key. so, for
  initial-ds trust anchors, we now add an empty KEYDATA record and set
  the key refresh timer so that the real keys will be looked up as soon
  as possible.

- when a key refresh query is done, we verify it against the
  trust anchor; this is done in two ways, one with the DS RRset
  set up during configuration if present, or with the keys linked
  from each keynode in the list if not.  because there are two different
  verification methods, the loop structure is overly complex and should
  be simplified.

- the keyfetch_done() and sync_keyzone() functions are both too long
  and should be broken into smaller functions.
2019-11-15 15:47:56 -08:00
Evan Hunt
854af5a353 allow DS trust anchors to be set in keytable
note: this is a frankensteinian kluge which needs further refactoring.

the keytable started as an RBT where the node->data points to a list of
dns_keynode structures, each of which points to a single dst_key.
later it was modified so that the list could instead point to a single
"null" keynode structure, which does not reference a key; this means
a trust anchor has been configured but the RFC 5011 refresh failed.

in this branch it is further updated to allow the first keynode in
the list to point to an rdatalist of DS-style trust anchors.  these will
be used by the validator to populate 'val->dsset' when validating a zone
key.

a DS style trust anchor can be updated as a result of RFC 5011
processing to contain DST keys instead; this results in the DS list
being freed.  the reverse is not possible; attempting to add a DS-style
trust anchor if a key-style trust anchor is already in place results
in an error.

later, this should be refactored to use rdatalists for both DS-style
and key-style trust anchors, but we're keeping the existing code for
old-style trust anchors for now.
2019-11-15 15:47:56 -08:00
Evan Hunt
feba480527 read DS trust anchors in named.conf
(but they aren't used for anything yet)
2019-11-15 15:47:17 -08:00
Evan Hunt
3fede8a7e9 add "static-ds" and "initial-ds" keywords to config parser 2019-11-15 15:47:17 -08:00
Samuel Thibault
d10fbdec84 hurd: Fix build
Move PATH_MAX, NAME_MAX, IOV_MAX default definitions to the common
<isc/platform.h>.
2019-11-10 20:14:17 +00:00
Evan Hunt
53f0b6c34d convert ns_client and related objects to use netmgr
- ns__client_request() is now called by netmgr with an isc_nmhandle_t
  parameter. The handle can then be permanently associated with an
  ns_client object.
- The task manager is paused so that isc_task events that may be
  triggred during client processing will not fire until after the netmgr is
  finished with it. Before any asynchronous event, the client MUST
  call isc_nmhandle_ref(client->handle), to prevent the client from
  being reset and reused while waiting for an event to process. When
  the asynchronous event is complete, isc_nmhandle_unref(client->handle)
  must be called to ensure the handle can be reused later.
- reference counting of client objects is now handled in the nmhandle
  object.  when the handle references drop to zero, the client's "reset"
  callback is used to free temporary resources and reiniialize it,
  whereupon the handle (and associated client) is placed in the
  "inactive handles" queue.  when the sysstem is shutdown and the
  handles are cleaned up, the client's "put" callback is called to free
  all remaining resources.
- because client allocation is no longer handled in the same way,
  the '-T clienttest' option has now been removed and is no longer
  used by any system tests.
- the unit tests require wrapping the isc_nmhandle_unref() function;
  when LD_WRAP is supported, that is used. otherwise we link a
  libwrap.so interposer library and use that.
2019-11-07 11:55:37 -08:00
Matthijs Mekking
5f464d15a0 dnssec-policy inheritance from options/view
'dnssec-policy' can now also be set on the options and view level and
a zone that does not set 'dnssec-policy' explicitly will inherit it
from the view or options level.

This requires a new keyword to be introduced: 'none'.  If set to
'none' the zone will not be DNSSEC maintained, in other words it will
stay unsigned.  You can use this to break the inheritance.  Of course
you can also break the inheritance by referring to a different
policy.

The keywords 'default' and 'none' are not allowed when configuring
your own dnssec-policy statement.

Add appropriate tests for checking the configuration (checkconf)
and add tests to the kasp system test to verify the inheritance
works.

Edit the kasp system test such that it can deal with unsigned zones
and views (so setting a TSIG on the query).
2019-11-06 22:36:21 +01:00
Matthijs Mekking
c125b721ef Adjust signing code to use kasp
Update the signing code in lib/dns/zone.c and lib/dns/update.c to
use kasp logic if a dnssec-policy is enabled.

This means zones with dnssec-policy should no longer follow
'update-check-ksk' and 'dnssec-dnskey-kskonly' logic, instead the
KASP keys configured dictate which RRset gets signed with what key.

Also use the next rekey event from the key manager rather than
setting it to one hour.

Mark the zone dynamic, as otherwise a zone with dnssec-policy is
not eligble for automatic DNSSEC maintenance.
2019-11-06 22:36:21 +01:00
Matthijs Mekking
2924b19a9d Parse dnssec-policy config into kasp
Add code that actually stores the configuration into the kasp
structure and attach it to the appropriate zone.
2019-11-06 22:31:45 +01:00
Matthijs Mekking
b7c5bfb203 Extend ttlval to accept ISO 8601 durations
The ttlval configuration types are replaced by duration configuration
types. The duration is an ISO 8601 duration that is going to be used
for DNSSEC key timings such as key lifetimes, signature resign
intervals and refresh periods, etc. But it is also still allowed to
use the BIND ttlval ways of configuring intervals (number plus
optional unit).

A duration is stored as an array of 7 different time parts.
A duration can either be expressed in weeks, or in a combination of
the other datetime indicators.

Add several unit tests to ensure the correct value is parsed given
different string values.
2019-11-06 22:31:44 +01:00
Diego Fronza
66fe8627de Added TCP high-water statistics variable
This variable will report the maximum number of simultaneous tcp clients
that BIND has served while running.

It can be verified by running rndc status, then inspect "tcp high-water:
count", or by generating statistics file, rndc stats, then inspect the
line with "TCP connection high-water" text.

The tcp-highwater variable is atomically updated based on an existing
tcp-quota system handled in ns/client.c.
2019-11-06 09:18:27 +01:00
Ondřej Surý
6decd14592 named: remove named_g_defaultdnstap global variable
The named_g_defaultdnstap was never used as the dnstap requires
explicit configuration of the output file.

Related scan-build report:

./server.c:3476:14: warning: Value stored to 'dpath' during its initialization is never read
        const char *dpath = named_g_defaultdnstap;
                    ^~~~~   ~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
2019-11-04 16:15:22 +01:00
Ondřej Surý
6bf364aec8 named: Add INSIST() after bindkeysfile configuration load to silence scan-build FP 2019-11-04 16:15:22 +01:00
Tony Finch
b612e38af1 Do not flush the cache for rndc validation status
And add a note to the man page that `rndc validation` flushes the
cache when the validation state is changed. (It is necessary to flush
the cache when turning on validation, to avoid continuing to use
cryptographically invalid data. It is probably wise to flush the cache
when turning off validation to recover from lameness problems.)
2019-10-31 13:31:41 -05:00
Tony Finch
bebeadc8e6 Include all views in output of rndc validation status
The implementation of `rndc validation status` iterates over all the
views to print their validation status. It takes care to print newlines
in between, but it also used put a nul byte at the end of the first view
which truncated the output.

After this change, the nul byte is added at the end so that it prints
the validation status in all views. The `_bind` view is skipped
because its validation status is irrelevant.
2019-10-31 11:28:00 -05:00
Ondřej Surý
fa7475b77a Fix the constification of the dns_name_t * result variable for dns_tsig_identity() 2019-10-03 09:04:26 +02:00
Ondřej Surý
476277a6e6 bin/named/server.c: Fix couple of DbC conditions reported by Cppcheck 2019-10-03 09:04:26 +02:00
Mark Andrews
b59fe46e76 address or suppress cppcheck warnings 2019-09-12 17:59:28 +10:00
Ondřej Surý
4957255d13 Use the semantic patch to change the usage isc_mem_create() to new API 2019-09-12 09:26:09 +02:00
Ondřej Surý
50e109d659 isc_event_allocate() cannot fail, remove the fail handling blocks
isc_event_allocate() calls isc_mem_get() to allocate the event structure.  As
isc_mem_get() cannot fail softly (e.g. it never returns NULL), the
isc_event_allocate() cannot return NULL, hence we remove the (ret == NULL)
handling blocks using the semantic patch from the previous commit.
2019-08-30 08:55:34 +02:00
Evan Hunt
c48979e6c5 simplify dns_rbtnodechain_init() by removing unnecessary 'mctx' parameter 2019-08-29 10:03:36 -07:00
Evan Hunt
efa5f7ed54 remove remaining DLV-related configuration checks 2019-08-09 09:22:05 -07:00
Evan Hunt
a1871e7f1d further cleanup
- removed some dead code
- dns_zone_setdbtype is now void as it could no longer return
  anything but ISC_R_SUCCESS; calls to it no longer check for a result
- controlkeylist_fromconfig() is also now void
- fixed a whitespace error
2019-07-23 15:32:36 -04:00
Ondřej Surý
9bdc24a9fd Use coccinelle to cleanup the failure handling blocks from isc_mem_strdup 2019-07-23 15:32:36 -04:00
Ondřej Surý
ae83801e2b Remove blocks checking whether isc_mem_get() failed using the coccinelle 2019-07-23 15:32:35 -04:00
Ondřej Surý
a912f31398 Add new default siphash24 cookie algorithm, but keep AES as legacy
This commit changes the BIND cookie algorithms to match
draft-sury-toorop-dnsop-server-cookies-00.  Namely, it changes the Client Cookie
algorithm to use SipHash 2-4, adds the new Server Cookie algorithm using SipHash
2-4, and changes the default for the Server Cookie algorithm to be siphash24.

Add siphash24 cookie algorithm, and make it keep legacy aes as
2019-07-21 15:16:28 -04:00
Witold Kręcicki
afa81ee4e4 Remove all cookie algorithms but AES, which was used as a default, for legacy purposes. 2019-07-21 10:08:14 -04:00
Thomas Jach
9ba3e3f1b5 convert geoip to geoip2 in win32utils/Configure 2019-07-04 08:58:26 -07:00
Evan Hunt
787f2a7e03 remove all support for legacy GeoIP 2019-07-04 08:56:45 -07:00
Evan Hunt
81fcde5953 fix broken windows build
The MSVS C compiler requires every struct to have at least one member.
The dns_geoip_databases_t structure had one set of members for
HAVE_GEOIP and a different set for HAVE_GEOIP2, and none when neither
API is in use.

This commit silences the compiler error by moving the declaration of
dns_geoip_databases_t to types.h as an opaque reference, and commenting
out the contents of geoip.h when neither version of GeoIP is enabled.
2019-07-03 12:17:27 -04:00
Evan Hunt
6e0b93e5a0 implement searching of geoip2 database
- revise mapping of search terms to database types to match the
  GeoIP2 schemas.
- open GeoIP2 databases when starting up; close when shutting down.
- clarify the logged error message when an unknown database type
  is configured.
- add new geoip ACL subtypes to support searching for continent in
  country databases.
- map geoip ACL subtypes to specific MMDB database queries.
- perform MMDB lookups based on subtype, saving state between
  queries so repeated lookups for the same address aren't necessary.
2019-06-27 14:59:03 -07:00