Commit Graph
11374 Commits
Author SHA1 Message Date
Mark Andrews 310004d8ac Add locking to socket_test to silence tsan reports.
There where data races accessing completion.
2020-09-02 00:25:56 +00:00
Mark Andrews c9f7d7c05f remove unused variable sock
(cherry picked from commit b1c424ddf3)
2020-09-02 09:00:22 +10:00
Mark Andrews 8094b821b3 Lock access to 'eventcnt' in timer_test.
There was a data race accessing 'eventcnt'.
2020-09-01 22:15:23 +00:00
Mark Andrews 30013c3794 Use memory_order_acq_rel in isc_refcount_decrement.
While

if (isc_refcount_decrement() == 1) {	// memory_order_release
	isc_refcount_destroy();		// memory_order_acquire
	...
}

is theoretically the most efficent in practice, using
memory_order_acq_rel produces the same code on x86_64 and doesn't
trigger tsan data races (which use a idealistic model) if
isc_refcount_destroy() is not called immediately.  In fact
isc_refcount_destroy() could be removed if we didn't want
to check for the count being 0 when isc_refcount_destroy() is
called.

https://stackoverflow.com/questions/49112732/memory-order-in-shared-pointer-destructor
(cherry picked from commit 6278899a38)
2020-09-01 22:31:52 +10:00
Mark AndrewsandOndřej Surý f2335d1faa Refactor totext_loc
(cherry picked from commit 2ca4d35037)
2020-08-26 17:26:56 +02:00
Mark AndrewsandOndřej Surý 19b95a5f37 Correctly encode LOC records with non integer negative altitudes.
(cherry picked from commit 337cc878fa)
2020-08-26 17:26:56 +02:00
Mark AndrewsandOndřej Surý 8a499c1fc6 Check LOC's altitude field is properly parsed and encoded.
(cherry picked from commit 888dfd78c7)
2020-08-26 17:26:56 +02:00
Mark AndrewsandOndřej Surý b2d67a28ac Tighten LOC parsing to reject period and/or m as a value.
(cherry picked from commit 9225c67835)
2020-08-26 17:26:56 +02:00
Mark AndrewsandOndřej Surý 2a6d6a7896 Synchronize {to,from}text_loc formatting with 9.16 2020-08-26 17:26:41 +02:00
Mark AndrewsandOndřej Surý b114651445 Cast the original rcode to (dns_ttl_t) when setting extended rcode
Shifting (signed) integer left could trigger undefined behaviour when
the shifted value would overflow into the sign bit (e.g. 2048).

The issue was found when using AFL++ and UBSAN:

    message.c:2274:33: runtime error: left shift of 2048 by 20 places cannot be represented in type 'int'
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior message.c:2274:33 in

(cherry picked from commit a347641782)
2020-08-25 16:41:08 +02:00
Michal Nowak 966eb72f5b Fix warnings in when build with --enable-buffer-useinline
sockaddr.c:147:49: error: pointer targets in passing argument 2 of ‘isc__buffer_putmem’ differ in signedness
    rdata.c:1780:30: error: pointer targets in passing argument 2 of ‘isc__buffer_putmem’ differ in signedness

(cherry picked from commit dd425254a7)
2020-08-25 16:13:54 +02:00
Evan Hunt 15d57a425e Merge tag 'v9_11_22' into v9_11
BIND 9.11.22
2020-08-20 12:10:47 -07:00
Mark AndrewsandOndřej Surý 4236972de4 A6: return FORMERR in fromwire if bits are non zero.
oss_fuzz: Issue 24864: bind9:dns_rdata_fromwire_text_fuzzer: Overwrites-const-input in dns_rdata_fromwire_text_fuzzer

(cherry picked from commit 8452404bd7)
(cherry picked from commit d8a57d32b1)
2020-08-18 11:36:06 +02:00
Mark AndrewsandOndřej Surý 80bc4fc1ea RRSIG: reject records with empty SIG section
(cherry picked from commit f6d7b8c20d)
(cherry picked from commit 6b1675a62c)
2020-08-18 11:33:32 +02:00
Mark Andrews 9d4feae236 X25: Check that record is all ASCII digits
(cherry picked from commit 7e49689746)
2020-08-14 00:27:24 +10:00
Mark Andrews 73602718f9 WKS: reject records with zero octets at the end of the bitmap
(cherry picked from commit 9d446142d8)
2020-08-14 00:26:42 +10:00
Mark Andrews 6cabbdae97 TLSA: fix fromwire length checks
(cherry picked from commit 3429c35f52)
2020-08-14 00:25:41 +10:00
Mark Andrews 0bc76daaf0 SIG: reject records with a zero length signature
(cherry picked from commit 9b93e5d684)
2020-08-14 00:25:08 +10:00
Mark Andrews f266bb2f61 NXT: fix fromwire bitmap checks
(cherry picked from commit 73dd849655)
2020-08-14 00:25:04 +10:00
Mark Andrews 712d3a50df NSEC3PARAM: check that saltlen is consistent with the rdata length
(cherry picked from commit 7dc8e720ff)
2020-08-14 00:24:25 +10:00
Mark Andrews 26f036cccc NSEC3: reject records with a zero length hash field
(cherry picked from commit 031ee9e279)
2020-08-14 00:23:47 +10:00
Mark Andrews 73341adc34 IPSECKEY: require non-zero length public keys
(cherry picked from commit d7f7014803)
2020-08-14 00:23:07 +10:00
Mark Andrews 1ca878708f CERT: reject records with a empty certificate field
(cherry picked from commit a238f37239)
2020-08-14 00:22:04 +10:00
Mark Andrews 74ee0ed911 Get rid of type 'RESERVED0'.
(cherry picked from commit 3c492b3ef1)
2020-08-14 00:21:23 +10:00
Mark Andrews af4dd77a44 base32_decode*() could incorrectly decode a input.
base32_decode_char() added a extra zero octet to the output
if the fifth character was a pad character.  The length
of octets to copy to the output was set to 3 instead of 2.

(cherry picked from commit 6c7e50c267)
2020-08-14 00:16:45 +10:00
Mark Andrews a3c2ad2ee5 Address use after free between view, resolver and nta.
Hold a weak reference to the view so that it can't go away while
nta is performing its lookups.  Cancel nta timers once all external
references to the view have gone to prevent them triggering new work.

(cherry picked from commit 0b2555e8cf)
2020-08-11 14:52:15 +10:00
Mark Andrews 3783de2ed0 Don't use isc_thread_key_* when threads are disabled. 2020-08-11 01:19:02 +00:00
Mark Andrews f155ff75e4 Check isc_mutex_init() return values 2020-08-11 01:19:02 +00:00
Mark Andrews 389c121597 Silence 'may be used uninitialized'
(cherry picked from commit 8a4dd25562)
2020-08-08 17:25:20 +10:00
Tinderbox User 7427b1f31c prep 9.11.22 2020-08-06 10:05:20 +00:00
Ondřej SurýandMichał Kępień 8d807cc216 Fix crash in pk11_numbits() when native-pkcs11 is used
When pk11_numbits() is passed a user provided input that contains all
zeroes (via crafted DNS message), it would crash with assertion
failure.  Fix that by properly handling such input.
2020-08-05 15:51:50 +02:00
Mark AndrewsandMichał Kępień 6ed167ad0a Always keep a copy of the message
this allows it to be available even when dns_message_parse()
returns a error.
2020-08-05 13:01:12 +02:00
Diego FronzaandEvan Hunt 33ae88f08d Fix rpz wildcard name matching
Whenever an exact match is found by dns_rbt_findnode(),
the highest level node in the chain will not be put into
chain->levels[] array, but instead the chain->end
pointer will be adjusted to point to that node.

Suppose we have the following entries in a rpz zone:
example.com     CNAME rpz-passthru.
*.example.com   CNAME rpz-passthru.

A query for www.example.com would result in the
following chain object returned by dns_rbt_findnode():

chain->level_count = 2
chain->level_matches = 2
chain->levels[0] = .
chain->levels[1] = example.com
chain->levels[2] = NULL
chain->end = www

Since exact matches only care for testing rpz set bits,
we need to test for rpz wild bits through iterating the nodechain, and
that includes testing the rpz wild bits in the highest level node found.

In the case of an exact match, chain->levels[chain->level_matches]
will be NULL, to address that we must use chain->end as the start point,
then iterate over the remaining levels in the chain.
2020-07-27 13:20:41 -07:00
Mark Andrews b424dfaada Check walking the hip rendezvous servers.
Also fixes extraneous white space at end of record when
there are no rendezvous servers.

(cherry picked from commit 78db46d746)
2020-07-24 15:43:54 +10:00
Petr MenšíkandMark Andrews 72e4be21f1 Remove few lines in unix socket handling
Reuse the same checks two times, make difference minimal.

(cherry picked from commit 72d81c4768)
2020-07-24 13:59:17 +10:00
Tinderbox UserandMichał Kępień 8345bf5f0e prep 9.11.21 2020-07-15 23:24:25 +02:00
Mark Andrews 4f25e8ee92 Mark 'addr' as unused if HAVE_IF_NAMETOINDEX is not defined
Also 'zone' should be initialised to zero.

(cherry picked from commit e7662c4c63)
2020-07-14 10:55:17 +10:00
Mark Andrews a4c16515de Assert tsigout is non-NULL
(cherry picked from commit 827746e89b)
2020-07-13 13:10:19 +10:00
Mark Andrews d953381d75 check returns from inet_pton()
(cherry picked from commit 9499adeb5e)
2020-07-13 11:45:09 +10:00
Mark Andrews 040eb8f07f Check that handle is non-NULL before dereferencing it 2020-07-13 10:16:47 +10:00
Michał Kępień 25818ac81f Fix locking for LMDB 0.9.26
When "rndc reconfig" is run, named first configures a fresh set of views
and then tears down the old views.  Consider what happens for a single
view with LMDB enabled; "envA" is the pointer to the LMDB environment
used by the original/old version of the view, "envB" is the pointer to
the same LMDB environment used by the new version of that view:

 1. mdb_env_open(envA) is called when the view is first created.
 2. "rndc reconfig" is called.
 3. mdb_env_open(envB) is called for the new instance of the view.
 4. mdb_env_close(envA) is called for the old instance of the view.

This seems to have worked so far.  However, an upstream change [1] in
LMDB which will be part of its 0.9.26 release prevents the above
sequence of calls from working as intended because the locktable mutexes
will now get destroyed by the mdb_env_close() call in step 4 above,
causing any subsequent mdb_txn_begin() calls to fail (because all of the
above steps are happening within a single named process).

Preventing the above scenario from happening would require either
redesigning the way we use LMDB in BIND, which is not something we can
easily backport, or redesigning the way BIND carries out its
reconfiguration process, which would be an even more severe change.

To work around the problem, set MDB_NOLOCK when calling mdb_env_open()
to stop LMDB from controlling concurrent access to the database and do
the necessary locking in named instead.  Reuse the view->new_zone_lock
mutex for this purpose to prevent the need for modifying struct dns_view
(which would necessitate library API version bumps).  Drop use of
MDB_NOTLS as it is made redundant by MDB_NOLOCK: MDB_NOTLS only affects
where LMDB reader locktable slots are stored while MDB_NOLOCK prevents
the reader locktable from being used altogether.

[1] https://git.openldap.org/openldap/openldap/-/commit/2fd44e325195ae81664eb5dc36e7d265927c5ebc

(cherry picked from commit 53120279b5)
2020-07-10 11:31:43 +02:00
Mark Andrews 902c1292c9 Adjust range limit of unknown meta types
(cherry picked from commit 092a159dcd)
2020-07-08 13:42:03 +10:00
Witold KręcickiandOndřej Surý e73702e821 rbtdb: cleanup_dead_nodes should ignore alive nodes on the deadlist
(cherry picked from commit c8f2d55acf)
2020-07-01 15:37:01 +02:00
Evan Hunt 8d52602daf append "0" to IPv6 addresses ending in "::" when printing YAML
such addresses broke some YAML parsers.

(cherry picked from commit a8baf79e33)
2020-06-25 19:35:31 -07:00
Mark Andrews 145b7f0b26 The validator could fail when select_signing_key/get_dst_key failed
to select the signing key because the algorithm was not supported
and the loop was prematurely aborted.

(cherry picked from commit d475f3aeed)
2020-06-25 22:46:41 +10:00
Mark Andrews a878e8d4bc Address potential thread issues:
Assign and then check node for NULL to address another thread
changing radix->head in the meantime.

Move 'node != NULL' check into while loop test to silence cppcheck
false positive.

Fix pointer != NULL style.

(cherry picked from commit 51f08d2095)
2020-06-25 21:18:45 +10:00
Mark AndrewsandOndřej Surý 915d94643f Address race between zone_maintenance and dns_zone_setview_helper
There was a possible NULL dereference due to data race between accessing
zone->view and zone->view->adb.

(cherry picked from commit 67c8f7329d)
2020-06-22 12:28:41 +02:00
Tinderbox UserandMichał Kępień fc8107adca prep 9.11.20 2020-06-18 10:37:47 +02:00
Mark AndrewsandMichał Kępień 90a7416d15 Remove INSIST from from new_reference
RBTDB node can now appear on the deadnodes lists following the changes
to decrement_reference in 4db29f1f7d to
defer checking of node->down when the tree write lock is not held.  The
node should be unlinked instead.

(cherry picked from commit 569cc155b8680d8ed12db1fabbe20947db24a0f9)
2020-06-18 10:37:16 +02:00
Mark Andrews dcf3941f17 Fix #define of activeemptynode for rbtdb64 2020-06-12 11:41:06 +10:00