Commit Graph
11381 Commits
Author SHA1 Message Date
Mark Andrews d45f53c2cd Address data race over 'done' in zt_test
==================
WARNING: ThreadSanitizer: data race (pid=697)
  Read of size 1 at 0x7ffcf51dd2b7 by main thread:
    #0 asyncload_zone /builds/isc-projects/bind9/lib/dns/tests/zt_test.c:206:2 (zt_test+0x4b835f)
    #1 <null> <null> (libcmocka.so.0+0x50d8)
    #2 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Previous write of size 1 at 0x7ffcf51dd2b7 by thread T15:
    #0 load_done /builds/isc-projects/bind9/lib/dns/tests/zt_test.c:89:8 (zt_test+0x4b8d99)
    #1 zone_asyncload /builds/isc-projects/bind9/lib/dns/zone.c:2243:3 (libdns.so.1110+0x1da0f6)
    #2 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
    #3 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d799)
2020-09-02 09:35:43 +00:00
Mark Andrews 5cc2806cea Add locking to address tsan errors.
Address data races with 'a', 'b', 'c', 'd', 'e', 'counter', 'done',
'nevents', 'nsdevents', 'all_done', and 'eventcnt'.

Add isc_mutex_init/isc_mutex_destroy.
2020-09-02 08:43:42 +00:00
Mark Andrews 9b66341971 Lock access when updating/reading manager->epoll_events[fd]
WARNING: ThreadSanitizer: data race (pid=110)
  Write of size 4 at 0x7ba400014050 by main thread (mutexes: write M1100, write M75):
    #0 socket_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:3012:34 (libisc.so.1105+0x6085c)
    #1 isc__socket_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:3044:10 (libisc.so.1105+0x60583)
    #2 isc_socket_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:105:11 (libisc.so.1105+0x6a4a0)
    #3 open_socket /builds/isc-projects/bind9/lib/dns/dispatch.c:1708:12 (libdns.so.1110+0x7491c)
    #4 get_udpsocket /builds/isc-projects/bind9/lib/dns/dispatch.c:2904:13 (libdns.so.1110+0x745ec)
    #5 dispatch_createudp /builds/isc-projects/bind9/lib/dns/dispatch.c:2994:12 (libdns.so.1110+0x6e159)
    #6 dns_dispatch_getudp_dup /builds/isc-projects/bind9/lib/dns/dispatch.c:2823:11 (libdns.so.1110+0x6d8f2)
    #7 dns_dispatch_getudp /builds/isc-projects/bind9/lib/dns/dispatch.c:2849:10 (libdns.so.1110+0x6e99e)
    #8 make_dispatchset /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:81:11 (dispatch_test+0x4ba8fc)
    #9 dispatchset_create /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:115:11 (dispatch_test+0x4b9f99)
    #10 <null> <null> (libcmocka.so.0+0x50d8)
    #11 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Previous write of size 4 at 0x7ba400014050 by thread T14:
    #0 unwatch_fd /builds/isc-projects/bind9/lib/isc/unix/socket.c (libisc.so.1105+0x6b913)
    #1 wakeup_socket /builds/isc-projects/bind9/lib/isc/unix/socket.c:1128:9 (libisc.so.1105+0x701fc)
    #2 process_ctlfd /builds/isc-projects/bind9/lib/isc/unix/socket.c:4253:3 (libisc.so.1105+0x6c048)
    #3 process_fds /builds/isc-projects/bind9/lib/isc/unix/socket.c:4157:10 (libisc.so.1105+0x6bcb4)
    #4 watcher /builds/isc-projects/bind9/lib/isc/unix/socket.c:4396:10 (libisc.so.1105+0x64188)

  Location is heap block of size 16385 at 0x7ba400014000 allocated by main thread:
    #0 malloc <null> (dispatch_test+0x42b7c4)
    #1 internal_memalloc /builds/isc-projects/bind9/lib/isc/mem.c:887:8 (libisc.so.1105+0x37e38)
    #2 mem_get /builds/isc-projects/bind9/lib/isc/mem.c:792:8 (libisc.so.1105+0x32c2c)
    #3 isc___mem_get /builds/isc-projects/bind9/lib/isc/mem.c:1310:9 (libisc.so.1105+0x325d7)
    #4 isc__mem_get /builds/isc-projects/bind9/lib/isc/mem.c:3012:11 (libisc.so.1105+0x34f80)
    #5 isc__socketmgr_create2 /builds/isc-projects/bind9/lib/isc/unix/socket.c:4704:26 (libisc.so.1105+0x6379a)
    #6 isc__socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:4652:10 (libisc.so.1105+0x635f2)
    #7 isc_socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:74:11 (libisc.so.1105+0x6a2c7)
    #8 create_managers /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:120:2 (dispatch_test+0x4bb28a)
    #9 dns_test_begin /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:192:3 (dispatch_test+0x4bb182)
    #10 _setup /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:53:11 (dispatch_test+0x4b9ff8)
    #11 <null> <null> (libcmocka.so.0+0x51e2)
    #12 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Mutex M1100 (0x7b5000000230) created at:
    #0 pthread_mutex_init <null> (dispatch_test+0x42e60d)
    #1 isc__mutex_init /builds/isc-projects/bind9/lib/isc/pthreads/mutex.c:287:8 (libisc.so.1105+0x72377)
    #2 dns_dispatchmgr_create /builds/isc-projects/bind9/lib/dns/dispatch.c:1778:11 (libdns.so.1110+0x6a055)
    #3 make_dispatchset /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:75:11 (dispatch_test+0x4ba883)
    #4 dispatchset_create /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:115:11 (dispatch_test+0x4b9f99)
    #5 <null> <null> (libcmocka.so.0+0x50d8)
    #6 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Mutex M75 (0x7bb800000320) created at:
    #0 pthread_mutex_init <null> (dispatch_test+0x42e60d)
    #1 isc__mutex_init /builds/isc-projects/bind9/lib/isc/pthreads/mutex.c:287:8 (libisc.so.1105+0x72377)
    #2 isc__socketmgr_create2 /builds/isc-projects/bind9/lib/isc/unix/socket.c:4729:12 (libisc.so.1105+0x63914)
    #3 isc__socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:4652:10 (libisc.so.1105+0x635f2)
    #4 isc_socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:74:11 (libisc.so.1105+0x6a2c7)
    #5 create_managers /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:120:2 (dispatch_test+0x4bb28a)
    #6 dns_test_begin /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:192:3 (dispatch_test+0x4bb182)
    #7 _setup /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:53:11 (dispatch_test+0x4b9ff8)
    #8 <null> <null> (libcmocka.so.0+0x51e2)
    #9 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Thread T14 'isc-socket' (tid=150, running) created by main thread at:
    #0 pthread_create <null> (dispatch_test+0x42d08b)
    #1 isc_thread_create /builds/isc-projects/bind9/lib/isc/pthreads/thread.c:60:8 (libisc.so.1105+0x724e8)
    #2 isc__socketmgr_create2 /builds/isc-projects/bind9/lib/isc/unix/socket.c:4788:6 (libisc.so.1105+0x63cc6)
    #3 isc__socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:4652:10 (libisc.so.1105+0x635f2)
    #4 isc_socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:74:11 (libisc.so.1105+0x6a2c7)
    #5 create_managers /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:120:2 (dispatch_test+0x4bb28a)
    #6 dns_test_begin /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:192:3 (dispatch_test+0x4bb182)
    #7 _setup /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:53:11 (dispatch_test+0x4b9ff8)
    #8 <null> <null> (libcmocka.so.0+0x51e2)
    #9 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

SUMMARY: ThreadSanitizer: data race /builds/isc-projects/bind9/lib/isc/unix/socket.c:3012:34 in socket_create
2020-09-02 03:07:03 +00:00
Mark Andrews d9a2cccc97 Lock on msg == SELECT_POKE_CLOSE as it triggers a tsan error
WARNING: ThreadSanitizer: data race (pid=1941)
  Write of size 4 at 0x7ba40000f050 by main thread (mutexes: write M1100, write M75):
    #0 socket_create /builds/isc-projects/bind9/1126G:3009:29 (libisc.so.1105+0x60822)
    #1 isc__socket_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:3043:10 (libisc.so.1105+0x60583)
    #2 isc_socket_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:105:11 (libisc.so.1105+0x6a4a0)
    #3 open_socket /builds/isc-projects/bind9/lib/dns/dispatch.c:1708:12 (libdns.so.1110+0x7491c)
    #4 get_udpsocket /builds/isc-projects/bind9/lib/dns/dispatch.c:2904:13 (libdns.so.1110+0x745ec)
    #5 dispatch_createudp /builds/isc-projects/bind9/lib/dns/dispatch.c:2994:12 (libdns.so.1110+0x6e159)
    #6 dns_dispatch_getudp_dup /builds/isc-projects/bind9/lib/dns/dispatch.c:2823:11 (libdns.so.1110+0x6d8f2)
    #7 dns_dispatch_getudp /builds/isc-projects/bind9/lib/dns/dispatch.c:2849:10 (libdns.so.1110+0x6e99e)
    #8 make_dispatchset /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:81:11 (dispatch_test+0x4ba8fc)
    #9 dispatchset_create /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:115:11 (dispatch_test+0x4b9f99)
    #10 <null> <null> (libcmocka.so.0+0x50d8)
    #11 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Previous write of size 4 at 0x7ba40000f050 by thread T14:
    #0 wakeup_socket /builds/isc-projects/bind9/lib/isc/unix/socket.c:1126:24 (libisc.so.1105+0x70181)
    #1 process_ctlfd /builds/isc-projects/bind9/lib/isc/unix/socket.c:4252:3 (libisc.so.1105+0x6c048)
    #2 process_fds /builds/isc-projects/bind9/lib/isc/unix/socket.c:4156:10 (libisc.so.1105+0x6bcb4)
    #3 watcher /builds/isc-projects/bind9/lib/isc/unix/socket.c:4395:10 (libisc.so.1105+0x64188)

  Location is heap block of size 16385 at 0x7ba40000f000 allocated by main thread:
    #0 malloc <null> (dispatch_test+0x42b7c4)
    #1 internal_memalloc /builds/isc-projects/bind9/lib/isc/mem.c:887:8 (libisc.so.1105+0x37e38)
    #2 mem_get /builds/isc-projects/bind9/lib/isc/mem.c:792:8 (libisc.so.1105+0x32c2c)
    #3 isc___mem_get /builds/isc-projects/bind9/lib/isc/mem.c:1310:9 (libisc.so.1105+0x325d7)
    #4 isc__mem_get /builds/isc-projects/bind9/lib/isc/mem.c:3012:11 (libisc.so.1105+0x34f80)
    #5 isc__socketmgr_create2 /builds/isc-projects/bind9/lib/isc/unix/socket.c:4697:21 (libisc.so.1105+0x6374f)
    #6 isc__socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:4651:10 (libisc.so.1105+0x635f2)
    #7 isc_socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:74:11 (libisc.so.1105+0x6a2c7)
    #8 create_managers /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:120:2 (dispatch_test+0x4bb28a)
    #9 dns_test_begin /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:192:3 (dispatch_test+0x4bb182)
    #10 _setup /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:53:11 (dispatch_test+0x4b9ff8)
    #11 <null> <null> (libcmocka.so.0+0x51e2)
    #12 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Mutex M1100 (0x7b5000000230) created at:
    #0 pthread_mutex_init <null> (dispatch_test+0x42e60d)
    #1 isc__mutex_init /builds/isc-projects/bind9/lib/isc/pthreads/mutex.c:287:8 (libisc.so.1105+0x72317)
    #2 dns_dispatchmgr_create /builds/isc-projects/bind9/lib/dns/dispatch.c:1778:11 (libdns.so.1110+0x6a055)
    #3 make_dispatchset /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:75:11 (dispatch_test+0x4ba883)
    #4 dispatchset_create /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:115:11 (dispatch_test+0x4b9f99)
    #5 <null> <null> (libcmocka.so.0+0x50d8)
    #6 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Mutex M75 (0x7bb800000320) created at:
    #0 pthread_mutex_init <null> (dispatch_test+0x42e60d)
    #1 isc__mutex_init /builds/isc-projects/bind9/lib/isc/pthreads/mutex.c:287:8 (libisc.so.1105+0x72317)
    #2 isc__socketmgr_create2 /builds/isc-projects/bind9/lib/isc/unix/socket.c:4728:12 (libisc.so.1105+0x63914)
    #3 isc__socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:4651:10 (libisc.so.1105+0x635f2)
    #4 isc_socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:74:11 (libisc.so.1105+0x6a2c7)
    #5 create_managers /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:120:2 (dispatch_test+0x4bb28a)
    #6 dns_test_begin /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:192:3 (dispatch_test+0x4bb182)
    #7 _setup /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:53:11 (dispatch_test+0x4b9ff8)
    #8 <null> <null> (libcmocka.so.0+0x51e2)
    #9 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Thread T14 'isc-socket' (tid=1969, running) created by main thread at:
    #0 pthread_create <null> (dispatch_test+0x42d08b)
    #1 isc_thread_create /builds/isc-projects/bind9/lib/isc/pthreads/thread.c:60:8 (libisc.so.1105+0x72488)
    #2 isc__socketmgr_create2 /builds/isc-projects/bind9/lib/isc/unix/socket.c:4787:6 (libisc.so.1105+0x63cc6)
    #3 isc__socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/socket.c:4651:10 (libisc.so.1105+0x635f2)
    #4 isc_socketmgr_create /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:74:11 (libisc.so.1105+0x6a2c7)
    #5 create_managers /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:120:2 (dispatch_test+0x4bb28a)
    #6 dns_test_begin /builds/isc-projects/bind9/lib/dns/tests/dnstest.c:192:3 (dispatch_test+0x4bb182)
    #7 _setup /builds/isc-projects/bind9/lib/dns/tests/dispatch_test.c:53:11 (dispatch_test+0x4b9ff8)
    #8 <null> <null> (libcmocka.so.0+0x51e2)
    #9 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

SUMMARY: ThreadSanitizer: data race /builds/isc-projects/bind9/lib/isc/unix/socket.c:3009:29 in socket_create
2020-09-02 03:07:03 +00:00
Mark Andrews 54e35ae174 Destroy the mutex 2020-09-02 03:07:03 +00:00
Mark Andrews 338aea8447 Lock 'responses' before reading it
WARNING: ThreadSanitizer: data race
  Read of size 4 at 0x000000000001 by main thread:
    #0 dispatch_getnext lib/dns/tests/dispatch_test.c:327
    #1 <null> <null>
    #2 __libc_start_main ../csu/libc-start.c:308

  Previous write of size 4 at 0x000000000001 by thread T1 (mutexes: write M1):
    #0 response lib/dns/tests/dispatch_test.c:234
    #1 dispatch lib/isc/task.c:1157
    #2 run lib/isc/task.c:1331
    #3 <null> <null>

  Location is global 'responses' of size 4 at 0x000000000001

  Mutex M1 (0x000000000009) created at:
    #0 pthread_mutex_init <null>
    #1 isc__mutex_init lib/isc/pthreads/mutex.c:287
    #2 dispatch_getnext lib/dns/tests/dispatch_test.c:273
    #3 <null> <null>
    #4 __libc_start_main ../csu/libc-start.c:308

  Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create lib/isc/pthreads/thread.c:60
    #2 isc__taskmgr_create lib/isc/task.c:1468
    #3 isc_taskmgr_create lib/isc/task.c:2109
    #4 create_managers lib/dns/tests/dnstest.c:118
    #5 dns_test_begin lib/dns/tests/dnstest.c:192
    #6 _setup lib/dns/tests/dispatch_test.c:53
    #7 <null> <null>
    #8 __libc_start_main ../csu/libc-start.c:308

SUMMARY: ThreadSanitizer: data race lib/dns/tests/dispatch_test.c:327 in dispatch_getnext
2020-09-02 03:07:03 +00:00
Mark Andrews a7da8f84ca isc_ratelimiter needs to hold a reference to its task
to prevent the task subsystem shutting down before the
ratelimiter is freed.

(cherry picked from commit b8e4b6d303)
2020-09-02 11:47:37 +10:00
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