Commit Graph
11394 Commits
Author SHA1 Message Date
Mark Andrews 05cb799274 Take complete ownership or *keyp before calling tsigkey_free. 2020-09-08 09:25:43 +10:00
Mark Andrews 8b80f40993 Take complete ownership of *aclp before calling destroy. 2020-09-08 09:25:43 +10:00
Mark Andrews bf0bac4068 isc_refcount_current should be memory_order_acquire 2020-09-08 09:25:43 +10:00
Mark Andrews fffcfe8acc To read locknum we need to obtain the lock identified by locknum
this is a catch 22.  make dns_rbtnode_t:locknum independent
2020-09-08 09:25:43 +10:00
Mark Andrews deb3bf845b Address tsan error in view:destroy() 2020-09-08 09:25:43 +10:00
Mark Andrews e17a750221 move resolver->spillat* under renamed spill_lock 2020-09-08 09:25:43 +10:00
Mark Andrews 52a715b122 isc_mutex_init_errcheck prototype should not be under ISC_MUTEX_PROFILE 2020-09-08 09:25:43 +10:00
Mark Andrews 054dc48a1f Only read dns_master_indent and dns_master_indentstr in named
The old code was not thread safe w.r.t. to the use of these variable.
We now only set them at the start of execution and copy them to
the message structure so they can be safely updated.  This is the
minimal change to make them thread safe.
2020-09-08 09:25:43 +10:00
Mark Andrews 1f7ccaba1b Prevent loads_pending going to zero while kicking the loads. 2020-09-08 09:25:43 +10:00
Mark Andrews 16e7e27328 Address data races between socket bitfields
* address data race between sock->pending_recv and sock->connected
* address data race between sock->bound and sock->pending_recv

==================
WARNING: ThreadSanitizer: data race (pid=1985)
  Read of size 2 at 0x7b54000c07c0 by thread T6:
    #0 isc__socket_sendto /builds/isc-projects/bind9/lib/isc/unix/socket.c:5291:2 (libisc.so.1107+0x65a00)
    #1 isc__socket_send /builds/isc-projects/bind9/lib/isc/unix/socket.c:5270:10 (libisc.so.1107+0x65944)
    #2 isc_socket_send /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:329:10 (libisc.so.1107+0x6b3c9)
    #3 sendstream /builds/isc-projects/bind9/bin/named/xfrout.c:1548:3 (named+0x555038)
    #4 ns_xfr_start /builds/isc-projects/bind9/bin/named/xfrout.c:1132:2 (named+0x553147)
    #5 ns_query_start /builds/isc-projects/bind9/bin/named/query.c:9572:4 (named+0x4f3329)
    #6 client_request /builds/isc-projects/bind9/bin/named/client.c:3115:3 (named+0x4de6af)
    #7 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
    #8 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d799)

  Previous write of size 2 at 0x7b54000c07c0 by thread T14 (mutexes: write M57, write M855819529908651432):
    #0 dispatch_recv /builds/isc-projects/bind9/lib/isc/unix/socket.c:3353:21 (libisc.so.1107+0x6c601)
    #1 process_fd /builds/isc-projects/bind9/lib/isc/unix/socket.c:4048:5 (libisc.so.1107+0x6c1be)
    #2 process_fds /builds/isc-projects/bind9/lib/isc/unix/socket.c:4161:3 (libisc.so.1107+0x6bfc0)
    #3 watcher /builds/isc-projects/bind9/lib/isc/unix/socket.c:4407:10 (libisc.so.1107+0x64398)
2020-09-08 09:25:43 +10:00
Mark Andrews bcfbc17384 Lock access to ctx->blocked as it is updated by multiple threads 2020-09-08 09:25:43 +10:00
Mark Andrews ca0c1e5b4b Update 'init_count' atomically to silence tsan errors. 2020-09-02 09:35:43 +00:00
Mark Andrews d8fa989c29 Lock access to flags in dns__zone_loadpending
==================
WARNING: ThreadSanitizer: data race (pid=1938)
  Read of size 4 at 0x7b7800000dd4 by main thread:
    #0 dns__zone_loadpending /builds/isc-projects/bind9/lib/dns/zone.c:2308:10 (libdns.so.1110+0x1da342)
    #1 asyncload_zone /builds/isc-projects/bind9/lib/dns/tests/zt_test.c:204:9 (zt_test+0x4b8303)
    #2 <null> <null> (libcmocka.so.0+0x50d8)
    #3 __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 0x7b7800000dd4 by thread T16 (mutexes: write M2181):
    #0 zone_asyncload /builds/isc-projects/bind9/lib/dns/zone.c:2237:3 (libdns.so.1110+0x1da08d)
    #1 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
    #2 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 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