Commit graph

11014 commits

Author SHA1 Message Date
Ondřej Surý
99ba29bc52 Change isc_random() to be just PRNG, and add isc_nonce_buf() that uses CSPRNG
This commit reverts the previous change to use system provided
entropy, as (SYS_)getrandom is very slow on Linux because it is
a syscall.

The change introduced in this commit adds a new call isc_nonce_buf
that uses CSPRNG from cryptographic library provider to generate
secure data that can be and must be used for generating nonces.
Example usage would be DNS cookies.

The isc_random() API has been changed to use fast PRNG that is not
cryptographically secure, but runs entirely in user space.  Two
contestants have been considered xoroshiro family of the functions
by Villa&Blackman and PCG by O'Neill.  After a consideration the
xoshiro128starstar function has been used as uint32_t random number
provider because it is very fast and has good enough properties
for our usage pattern.

The other change introduced in the commit is the more extensive usage
of isc_random_uniform in places where the usage pattern was
isc_random() % n to prevent modulo bias.  For usage patterns where
only 16 or 8 bits are needed (DNS Message ID), the isc_random()
functions has been renamed to isc_random32(), and isc_random16() and
isc_random8() functions have been introduced by &-ing the
isc_random32() output with 0xffff and 0xff.  Please note that the
functions that uses stripped down bit count doesn't pass our
NIST SP 800-22 based random test.
2018-05-29 22:58:21 +02:00
Mark Andrews
cb5802e854 work around cppcheck false positive 2018-05-29 09:28:30 +10:00
Evan Hunt
3006ccb7f0 improve readability of radix code
- use RADIX_V4 and RADIX_V6 instead of 0 and 1 as array indices
- remove some unused macros
2018-05-28 18:45:41 -04:00
Tony Finch
4b442c309d Move serve-stale logging to its own category, so that its verbosity can be curtailed. 2018-05-25 22:00:51 -07:00
Evan Hunt
7fbffa6c44 remove #ifndef DNS_RBT_USEHASH from rbtdb.c
- this was a compile time option to disable the use of a hash table in
  the RBTDB. the code path without the hash table was buggy and
  untested, and unlikely to be needed by anyone anyway.
2018-05-25 09:12:17 -07:00
Evan Hunt
e324449349 remove the experimental authoritative ECS support from named
- mark the 'geoip-use-ecs' option obsolete; warn when it is used
  in named.conf
- prohibit 'ecs' ACL tags in named.conf; note that this is a fatal error
  since simply ignoring the tags could make ACLs behave unpredictably
- re-simplify the radix and iptable code
- clean up dns_acl_match(), dns_aclelement_match(), dns_acl_allowed()
  and dns_geoip_match() so they no longer take ecs options
- remove the ECS-specific unit and system test cases
- remove references to ECS from the ARM
2018-05-25 08:21:25 -07:00
Evan Hunt
9147a31b94 copyrights 2018-05-23 12:39:40 -04:00
Evan Hunt
1c1a02d244 fix broken win32 code in random.c 2018-05-22 16:32:21 -07:00
Ondřej Surý
7ee8a7e69f address win32 build issues
- Replace external -DOPENSSL/-DPKCS11CRYPTO with properly AC_DEFINEd
  HAVE_OPENSSL/HAVE_PKCS11
- Don't enforce the crypto provider from platform.h, just from dst_api.c
  and configure scripts
2018-05-22 16:32:21 -07:00
Ondřej Surý
c4a38bd127 Remove extra FATAL prefix from FATAL_ERROR call 2018-05-22 12:31:54 +02:00
Ondřej Surý
88631dad8f Provide better error message on failed RAND_bytes call 2018-05-22 12:12:25 +02:00
Tinderbox User
9536688b37 regenerate doc 2018-05-21 19:59:45 +00:00
Evan Hunt
df4df8e0d5 begin preparation for 9.13.0
- tidy up release notes, removing the existing "security fixes" and
  "bug fixes" sections
- add a section in the release notes to discuss the new version
  numbering
- update version, CHANGES, api, and mapapi files
2018-05-21 11:50:38 -07:00
Michał Kępień
46bb4dd124 Detect recursion loops during query processing
Interrupt query processing when query_recurse() attempts to ask the same
name servers for the same QNAME/QTYPE tuple for two times in a row as
this indicates that query processing may be stuck for an indeterminate
period of time, e.g. due to interactions between features able to
restart query_lookup().
2018-05-21 09:50:10 -07:00
Michał Kępień
391fac1fc8 Prevent check_stale_header() from leaking rdataset headers
check_stale_header() fails to update the pointer to the previous header
while processing rdataset headers eligible for serve-stale, thus
enabling rdataset headers to be leaked (i.e. disassociated from a node
and left on the relevant TTL heap) while iterating through a node.  This
can lead to several different assertion failures.  Add the missing
pointer update.
2018-05-21 09:50:10 -07:00
Mark Andrews
6bff1768cf ISC_SOCKEVENTATTR_TRUNC was not be set 2018-05-18 15:34:48 +10:00
Mukund Sivaraman
975afc508d Fix ARM about min-update-interval default for RPZ zones
Also, use variable names consistent with catz for rpz configuration functions
2018-05-17 19:02:51 -07:00
Mark Andrews
074f247926 remove dstrandom_test 2018-05-17 16:10:24 +10:00
Tony Finch
174cd00290 Fix request-nsid log level to match documentation.
Since change 3741 (commit 1d761cb4) they have been logged at
debug(3) by mistake.
2018-05-16 20:20:05 +01:00
Ondřej Surý
2b8fab6828 Remove genrandom command and all usage of specific random files throughout the system test suite 2018-05-16 09:54:35 +02:00
Ondřej Surý
3a4f820d62 Replace all random functions with isc_random, isc_random_buf and isc_random_uniform API.
The three functions has been modeled after the arc4random family of
functions, and they will always return random bytes.

The isc_random family of functions internally use these CSPRNG (if available):

1. getrandom() libc call (might be available on Linux and Solaris)
2. SYS_getrandom syscall (might be available on Linux, detected at runtime)
3. arc4random(), arc4random_buf() and arc4random_uniform() (available on BSDs and Mac OS X)
4. crypto library function:
4a. RAND_bytes in case OpenSSL
4b. pkcs_C_GenerateRandom() in case PKCS#11 library
2018-05-16 09:54:35 +02:00
Mukund Sivaraman
31bd3147d1 Don't validate non-pending glue when adding to the additional section 2018-05-16 08:15:36 +02:00
Michał Kępień
6ddbca6f2b isc_buffer_*(): if source can be NULL, only call memmove() when length is non-zero
Certain isc_buffer_*() functions might call memmove() with the second
argument (source) set to NULL and the third argument (length) set to 0.
While harmless, it triggers an ubsan warning:

    runtime error: null pointer passed as argument 2, which is declared to never be null

Modify all memmove() call sites in lib/isc/include/isc/buffer.h and
lib/isc/buffer.c which may potentially use NULL as the second argument
(source) so that memmove() is only called if the third argument (length)
is non-zero.
2018-05-15 09:11:34 +02:00
Michał Kępień
9bc6ba0be9 dns_rdataslab_merge(): use dns_rdata_compare() instead of compare_rdata()
compare_rdata() was meant to be used as a qsort() callback.  Meanwhile,
dns_rdataslab_merge() calls compare_rdata() for a pair of dns_rdata_t
structures rather than a pair of struct xrdata structures, which is
harmless, but triggers an ubsan warning:

    rdataslab.c:84:33: runtime error: member access within address <address> with insufficient space for an object of type 'const struct xrdata'

Use dns_rdata_compare() instead of compare_rdata() to prevent the
warning from being triggered.
2018-05-15 09:11:34 +02:00
Michał Kępień
f98e145c5b Extend the list of headers included by lib/dns/tests/sigs_test.c 2018-05-14 09:18:00 +02:00
Mark Andrews
2420320b96 return untested if not built with OPENSSL or PKCS11CRYPTO 2018-05-14 02:21:48 -04:00
Ondřej Surý
23c1f7e506 Enforce usage of OpenSSL or PKCS#11 library in platform.h header 2018-05-13 19:18:56 -07:00
Ondřej Surý
55a10b7acd Remove $Id markers, Principal Author and Reviewed tags from the full source tree 2018-05-11 13:17:46 +02:00
Mark Andrews
6aae115d15 silence cppcheck portability warning 2018-05-11 08:12:17 +02:00
Mukund Sivaraman
3adcc033f6 Don't keep around debuglist structs when done 2018-05-11 11:17:14 +10:00
Mukund Sivaraman
b9886abd86 Reduce number of buckets in tracklines debuglink table
With 1044 res contexts, each with 65536 debuglink structs of 16 bytes
each, the debuglink table itself was consuming 1GB+ of memory.
2018-05-11 11:17:14 +10:00
Mark Andrews
92e540df1e Silence clang static analyzer warnings; Consolidate multiple instances of splitting of batchline in dig into a single function. 2018-05-11 10:54:21 +10:00
Michał Kępień
172d0c401e Address GCC 8 -Wformat-truncation warnings 2018-05-10 10:35:01 +02:00
Michał Kępień
0ee14aa594 Use a while loop instead of a for loop in dns__zone_updatesigs()
Replace the outer for loop with a while loop to emphasize it keeps
processing the first element of diff->tuples, which changes on each
iteration due to tuples being removed from diff->tuples by
move_matching_tuples().
2018-05-10 09:43:38 +02:00
Michał Kępień
15afdf94ef Remove redundant assertions
The ENSURE assertion at the end of dns_diff_appendminimal() is not
needed because it is placed right after code which resets *tuplep to
NULL if it is not NULL already.

The INSIST assertion in move_matching_tuples() checks the same pointer
again.
2018-05-10 09:43:38 +02:00
Michał Kępień
1bd5f61c60 Look for the next matching tuple in a separate function
Extract the portion of the do-while loop responsible for finding the
next tuple with the same name and type into a separate function to
improve code clarity.
2018-05-10 09:43:38 +02:00
Michał Kępień
31cdf770a4 Extract the do-while loop in dns__zone_updatesigs() into a separate function
The do-while loop in dns__zone_updatesigs() is hard to follow due to
heavy nesting and the 'tuple' variable also being used in the outer for
loop.  Add a comment to explain the purpose of the do-while loop.
Extract it into a separate function to decrease indentation and prevent
using 'tuple' in two different loops.
2018-05-10 09:43:38 +02:00
Michał Kępień
8b9d2c27b4 Define basic test cases for dns__zone_updatesigs()
Add some basic test cases ensuring dns__zone_updatesigs() behaves as
expected.
2018-05-09 13:32:11 +02:00
Michał Kępień
1f10186476 Add a framework for dns__zone_updatesigs() unit tests
Add a new ATF test, sigs_test, containing everything required to start
defining test cases for dns__zone_updatesigs().  The framework is
written in a way which ensures that changes to zone database applied by
any dns__zone_updatesigs() invocation are preserved between subsequent
checks.
2018-05-09 13:32:09 +02:00
Michał Kępień
d7143986b1 Move find_zone_keys() to lib/dns/zone_p.h
Rename find_zone_keys() to dns__zone_findkeys() and move it to
lib/dns/zone_p.h, so that it can be used in unit tests.  Add a comment
describing the purpose of this function.
2018-05-09 13:21:02 +02:00
Michał Kępień
b1947cee82 Move update_sigs() to lib/dns/zone_p.h
Rename update_sigs() to dns__zone_updatesigs() and move it to
lib/dns/zone_p.h, so that it can be unit tested.  Add a comment
describing the purpose of this function.
2018-05-09 13:21:02 +02:00
Michał Kępień
ace465a9f9 Move zonediff_t to lib/dns/zone_p.h
Rename zonediff_t to dns__zonediff_t and move it to lib/dns/zone_p.h, so
that unit tests can be written for functions taking pointers to
structures of this type as arguments.
2018-05-09 13:21:02 +02:00
Michał Kępień
c1bc3be806 Add lib/dns/zone_p.h
Add a new private header file, lib/dns/zone_p.h, which will hold type
definitions and function prototypes not meant to be exported by libdns,
but required by zone-related unit tests.
2018-05-09 13:21:02 +02:00
Michał Kępień
3c22af0d35 Add a helper function to facilitate preparing dns_diff_t structures
Implement dns_test_difffromchanges(), a function which enables preparing
a dns_diff_t structure from a mostly-textual representation of zone
database changes to be applied.  This will improve readability of test
case definitions by allowing contents of a dns_diff_t structure, passed
e.g. to update_sigs(), to be represented in a human-friendly manner.
2018-05-09 13:21:01 +02:00
Michał Kępień
2980cbd55f Rename dns_test_rdata_fromstring() to dns_test_rdatafromstring()
Remove the underscore from "rdata_fromstring" so that all helper
functions for libdns tests use a common naming covention.
2018-05-09 13:14:24 +02:00
Michał Kępień
bfbeef3609 Rework dns_test_makezone()
The dns_test_makezone() helper function always assigns the created zone
to some view, which is not always necessary and complicates cleanup of
non-managed zones as they are required not to be assigned to any view.

Rework dns_test_makezone() in order to make it easier to use in unit
tests operating on non-managed zones.  Use dns_name_fromstring() instead
of dns_name_fromtext() to simplify code.  Do not use the CHECK() macro
and add comments to make code flow simpler to follow.  Use
dns_test_makeview() instead of dns_view_create().

Adjust existing unit tests using this function so that they still pass.
2018-05-08 12:26:53 +02:00
Mark Andrews
7f2863196f check that order is non NULL before calling strtok_r 2018-05-03 11:08:59 -04:00
Mark Andrews
22fab3199f simplify mask construction 2018-05-03 10:56:32 -04:00
Ondřej Surý
61da2bf028 Remove support for OpenSSL < 1.0.0 2018-05-03 15:55:39 +02:00
Ondřej Surý
8d648e7a8a Use standard OPENSSL_NO_ENGINE instead of custom USE_ENGINE define 2018-05-03 15:32:43 +02:00