Michal Nowak
7ceeaca0dc
Fix arguments with mismatched bound in lib/isc/sha2.c
...
GCC 11 produced the following warnings:
sha2.c:888:26: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=]
888 | isc_sha224_final(uint8_t digest[], isc_sha224_t *context) {
| ~~~~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:132:24: note: previously declared as ‘uint8_t[28]’ {aka ‘unsigned char[28]’}
132 | void isc_sha224_final (uint8_t[ISC_SHA224_DIGESTLENGTH], isc_sha224_t *);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sha2.c:1151:26: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=]
1151 | isc_sha256_final(uint8_t digest[], isc_sha256_t *context) {
| ~~~~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:139:24: note: previously declared as ‘uint8_t[32]’ {aka ‘unsigned char[32]’}
139 | void isc_sha256_final (uint8_t[ISC_SHA256_DIGESTLENGTH], isc_sha256_t *);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sha2.c:1514:31: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=]
1514 | void isc_sha512_final(uint8_t digest[], isc_sha512_t *context) {
| ~~~~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:153:24: note: previously declared as ‘uint8_t[64]’ {aka ‘unsigned char[64]’}
153 | void isc_sha512_final (uint8_t[ISC_SHA512_DIGESTLENGTH], isc_sha512_t *);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sha2.c:1567:26: error: argument 1 of type ‘uint8_t[]’ {aka ‘unsigned char[]’} with mismatched bound [-Werror=array-parameter=]
1567 | isc_sha384_final(uint8_t digest[], isc_sha384_t *context) {
| ~~~~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:146:24: note: previously declared as ‘uint8_t[48]’ {aka ‘unsigned char[48]’}
146 | void isc_sha384_final (uint8_t[ISC_SHA384_DIGESTLENGTH], isc_sha384_t *);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sha2.c:1604:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=]
1604 | isc_sha224_end(isc_sha224_t *context, char buffer[]) {
| ~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:133:39: note: previously declared as ‘char[57]’
133 | char *isc_sha224_end (isc_sha224_t *, char[ISC_SHA224_DIGESTSTRINGLENGTH]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sha2.c:1645:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=]
1645 | isc_sha256_end(isc_sha256_t *context, char buffer[]) {
| ~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:140:39: note: previously declared as ‘char[65]’
140 | char *isc_sha256_end (isc_sha256_t *, char[ISC_SHA256_DIGESTSTRINGLENGTH]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sha2.c:1686:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=]
1686 | isc_sha512_end(isc_sha512_t *context, char buffer[]) {
| ~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:154:39: note: previously declared as ‘char[129]’
154 | char *isc_sha512_end (isc_sha512_t *, char[ISC_SHA512_DIGESTSTRINGLENGTH]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sha2.c:1727:44: error: argument 2 of type ‘char[]’ with mismatched bound [-Werror=array-parameter=]
1727 | isc_sha384_end(isc_sha384_t *context, char buffer[]) {
| ~~~~~^~~~~~~~
In file included from sha2.c:58:
./include/isc/sha2.h:147:39: note: previously declared as ‘char[97]’
147 | char *isc_sha384_end (isc_sha384_t *, char[ISC_SHA384_DIGESTSTRINGLENGTH]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
2021-05-20 12:55:14 +02:00
Tinderbox User and Michał Kępień
177d66e39f
prep 9.11.27
2021-01-21 09:38:24 +01:00
Tinderbox User and Michał Kępień
363a2c3e5e
prep 9.11.26
2020-12-16 22:32:08 +01:00
Mark Andrews
7982767d4a
Ignore TSAN errors with getcounter and setcounter
...
WARNING: ThreadSanitizer: data race
Read of size 8 at 0x000000000001 by thread T1:
#0 getcounter lib/isc/stats.c:289:15
#1 isc_stats_update_if_greater lib/isc/stats.c:464:24
#2 client_accept bin/named/client.c:3599:2
#3 client_start bin/named/client.c:833:4
#4 dispatch lib/isc/task.c:1157:7
#5 run lib/isc/task.c:1331:2
Previous write of size 8 at 0x000000000001 by thread T2:
#0 setcounter lib/isc/stats.c:313:27
#1 isc_stats_update_if_greater lib/isc/stats.c:466:3
#2 client_accept bin/named/client.c:3599:2
#3 client_start bin/named/client.c:833:4
#4 dispatch lib/isc/task.c:1157:7
#5 run lib/isc/task.c:1331:2
2020-12-10 06:31:19 +00:00
Mark Andrews
5f6ab3512e
Silence TSAN warning on spins in isc_rwlock_lock
...
WARNING: ThreadSanitizer: data race
Write of size 4 at 0x000000000001 by thread T1:
#0 isc_rwlock_lock lib/isc/rwlock.c:720:2
#1 findnodeintree lib/dns/rbtdb.c:3060:2
#2 findnsec3node lib/dns/rbtdb.c:3164:10
#3 dns_db_findnsec3node lib/dns/db.c:528:10
#4 diff_apply lib/dns/diff.c:318:5
#5 dns_diff_applysilently lib/dns/diff.c:463:10
#6 signname bin/dnssec/./dnssec-signzone.c:1118:11
#7 sign bin/dnssec/./dnssec-signzone.c:1599:2
#8 dispatch lib/isc/task.c:1157:7
#9 run lib/isc/task.c:1331:2
Previous read of size 4 at 0x000000000001 by thread T2:
#0 isc_rwlock_lock lib/isc/rwlock.c:704:25
#1 addrdataset lib/dns/rbtdb.c:6853:2
#2 dns_db_addrdataset lib/dns/db.c:783:10
#3 diff_apply lib/dns/diff.c:370:14
#4 dns_diff_applysilently lib/dns/diff.c:463:10
#5 signname bin/dnssec/./dnssec-signzone.c:1118:11
#6 sign bin/dnssec/./dnssec-signzone.c:1599:2
#7 dispatch lib/isc/task.c:1157:7
#8 run lib/isc/task.c:1331:2
2020-12-10 06:31:19 +00:00
Mark Andrews
a241c69920
Lock read of refs when atomics are not available.
...
WARNING: ThreadSanitizer: data race
Read of size 4 at 0x000000000001 by thread T1 (mutexes: write M1):
#0 zone_iattach lib/dns/zone.c:5412:2
#1 soa_query lib/dns/zone.c:12725:2
#2 dispatch lib/isc/task.c:1157:7
#3 run lib/isc/task.c:1331:2
Previous write of size 4 at 0x000000000001 by thread T2 (mutexes: write M2):
#0 dns_zone_detach lib/dns/zone.c:5346:2
#1 ns_server_refreshcommand bin/named/./server.c:9880:3
#2 ns_control_docommand bin/named/control.c:247:12
#3 control_recvmessage bin/named/controlconf.c:469:13
#4 dispatch lib/isc/task.c:1157:7
#5 run lib/isc/task.c:1331:2
2020-12-10 06:31:19 +00:00
Mark Andrews
1caef804d5
Ignore thread sanitizer warnings in stats counters
...
set ISC_NO_SANITIZE_THREAD for incrementcounter and decrementcounter
WARNING: ThreadSanitizer: data race
Write of size 8 at 0x000000000001 by thread T1:
#0 decrementcounter lib/isc/stats.c:258:26
#1 isc_stats_decrement lib/isc/stats.c:350:2
#2 dec_stats lib/isc/unix/socket.c:934:3
#3 socketclose lib/isc/unix/socket.c:2270:3
#4 destroy lib/isc/unix/socket.c:2323:3
#5 isc__socket_detach lib/isc/unix/socket.c:3275:3
#6 isc_socket_detach lib/isc/unix/./../socket_api.c:128:3
#7 exit_check bin/named/client.c:593:4
#8 ns_client_next bin/named/client.c:947:8
#9 client_request bin/named/client.c
#10 dispatch lib/isc/task.c:1157:7
#11 run lib/isc/task.c:1331:2
Previous write of size 8 at 0x000000000001 by thread T2:
#0 incrementcounter lib/isc/stats.c:239:26
#1 isc_stats_increment lib/isc/stats.c:340:2
#2 inc_stats lib/isc/unix/socket.c:923:3
#3 internal_accept lib/isc/unix/socket.c:3741:4
#4 dispatch lib/isc/task.c:1157:7
#5 run lib/isc/task.c:1331:2
2020-12-10 06:31:19 +00:00
Mark Andrews
0e5a076cc1
Prevent inlining of code with thread sanitiser disabled
2020-12-10 06:31:19 +00:00
Mark Andrews
f3c402baed
Only lock access to epoll_ctl when using watcher thread
2020-12-10 02:34:36 +00:00
Petr Mensik and Mark Andrews
839350f5f6
Pass task_test also with threads disabled
...
Condition cv is declared only when threads are used. Use it only in that
case. Test compiles and passes without thread support also.
2020-12-01 23:06:19 +00:00
Michal Nowak
bbed152e5d
Fix typo in ISC_PLAFORM_HAVESYSUNH
...
(cherry picked from commit 8885f4a6f7 )
2020-11-26 15:09:36 +01:00
Michał Kępień
fa989e4236
Use proper cmocka macros for pointer checks
...
Make sure pointer checks in unit tests use cmocka assertion macros
dedicated for use with pointers instead of those dedicated for use with
integers or booleans.
(cherry picked from commit f440600126 )
2020-11-26 13:15:28 +01:00
Tinderbox User and Michał Kępień
66faf3215c
prep 9.11.25
2020-11-26 12:33:58 +01:00
Michał Kępień
7f13c427a9
Fix getrbp()
...
The following compiler warning is emitted for the BACKTRACE_X86STACK
part of lib/isc/backtrace.c:
backtrace.c: In function ‘getrbp’:
backtrace.c:139:1: warning: no return statement in function returning non-void [-Wreturn-type]
While getrbp() stores the value of the RBP register in the RAX register
and thus does attempt to return a value, this is not enough for an
optimizing compiler to always produce the expected result. With -O2,
the following machine code may be generated in isc_backtrace_gettrace():
0x00007ffff7b0ff7a <+10>: mov %rbp,%rax
0x00007ffff7b0ff7d <+13>: mov $0x17,%eax
0x00007ffff7b0ff82 <+18>: retq
The above is equivalent to:
sp = (void **)getrbp();
return (ISC_R_NOTFOUND);
and results in the backtrace never getting printed.
Fix by using an intermediate variable. With this change in place, the
machine code generated with -O2 becomes something like:
0x00007ffff7af5638 <+24>: mov $0x17,%eax
0x00007ffff7af563d <+29>: mov %rbp,%rdx
0x00007ffff7af5640 <+32>: test %rdx,%rdx
0x00007ffff7af5643 <+35>: je 0x7ffff7af56bd <isc_backtrace_gettrace+157>
...
0x00007ffff7af56bd <+157>: retq
(Note that this method of grabbing a stack trace is finicky anyway
because in order for RBP to be relied upon, -fno-omit-stack-frame must
be present among CFLAGS.)
(cherry picked from commit 923c443389 )
2020-10-30 09:42:24 +01:00
Michał Kępień
a51cde6ceb
Check for _Unwind_Backtrace() support
...
Some operating systems (e.g. Linux, FreeBSD) provide the
_Unwind_Backtrace() function in libgcc_s.so, which is automatically
linked into any binary using the functions provided by that library. On
OpenBSD, though, _Unwind_Backtrace() is provided by libc++abi.so, which
is not automatically linked into binaries produced by the stock system C
compiler.
Meanwhile, lib/isc/backtrace.c assumes that any GNU-compatible toolchain
allows _Unwind_Backtrace() to be used without any extra provisions in
the build system. This causes build failures on OpenBSD (and possibly
other systems).
Instead of making assumptions, actually check for _Unwind_Backtrace()
support in the toolchain if the backtrace() function is unavailable.
(cherry picked from commit 10d7055791 )
2020-10-30 09:42:24 +01:00
Tinderbox User and Michał Kępień
6995173371
prep 9.11.24
2020-10-22 09:22:48 +02:00
Witold Kręcicki and Michal Nowak
09a3431069
Fix 'error: ‘%s’ directive argument is null [-Werror=format-overflow=]' in assertions.c
...
(cherry picked from commit f4260dc0c5 )
2020-10-07 10:26:47 +02:00
Mark Andrews
21662afb3c
Add the ability to print out the list of test names (-l)
...
(cherry picked from commit a9c3374717 )
2020-10-01 23:03:05 +10:00
Mark Andrews
e310aaf4b7
Add the ability to select tests to run
...
task_test [-t <test_name>]
(cherry picked from commit 76837484e7 )
2020-10-01 23:03:01 +10:00
Ondřej Surý
98def35e72
Handle the errors from sysconf() call in isc_meminfo_totalphys()
...
isc_meminfo_totalphys() would return invalid memory size when sysconf()
call would fail, because ((size_t)-1 * -1) is very large number.
(cherry picked from commit 79ca724d46 )
2020-09-21 10:59:36 +02:00
Ondřej Surý
fe738c7432
Exclude isc_mem_isovermem from ThreadSanitizer
...
The .is_overmem member of isc_mem_t structure is intentionally accessed
unlocked as 100% accuracy isn't necessary here.
Without the attribute, following TSAN warning would show up:
WARNING: ThreadSanitizer: data race
Write of size 1 at 0x000000000001 by thread T1 (mutexes: write M1, write M2):
#0 isc___mem_put lib/isc/mem.c:1119:19
#1 isc__mem_put lib/isc/mem.c:2439:2
#2 dns_rdataslab_fromrdataset lib/dns/rdataslab.c:327:2
#3 addrdataset lib/dns/rbtdb.c:6761:11
#4 dns_db_addrdataset lib/dns/db.c:719:10
#5 cache_name lib/dns/resolver.c:6538:13
#6 cache_message lib/dns/resolver.c:6628:14
#7 resquery_response lib/dns/resolver.c:7883:13
#8 dispatch lib/isc/task.c:1152:7
#9 run lib/isc/task.c:1344:2
Previous read of size 1 at 0x000000000001 by thread T2 (mutexes: write M3):
#0 isc_mem_isovermem lib/isc/mem.c:1553:15
#1 addrdataset lib/dns/rbtdb.c:6866:25
#2 dns_db_addrdataset lib/dns/db.c:719:10
#3 addoptout lib/dns/ncache.c:281:10
#4 dns_ncache_add lib/dns/ncache.c:101:10
#5 ncache_adderesult lib/dns/resolver.c:6668:12
#6 ncache_message lib/dns/resolver.c:6845:11
#7 rctx_ncache lib/dns/resolver.c:9174:11
#8 resquery_response lib/dns/resolver.c:7894:2
#9 dispatch lib/isc/task.c:1152:7
#10 run lib/isc/task.c:1344:2
Location is heap block of size 328 at 0x000000000020 allocated by thread T3:
#0 malloc <null>
#1 default_memalloc lib/isc/mem.c:713:8
#2 mem_create lib/isc/mem.c:763:8
#3 isc_mem_create lib/isc/mem.c:2425:2
#4 configure_view bin/named/server.c:4494:4
#5 load_configuration bin/named/server.c:9062:3
#6 run_server bin/named/server.c:9771:2
#7 dispatch lib/isc/task.c:1152:7
#8 run lib/isc/task.c:1344:2
[...]
SUMMARY: ThreadSanitizer: data race lib/isc/mem.c:1119:19 in isc___mem_put
(cherry picked from commit 0110d1ab17 )
2020-09-17 17:39:03 +02:00
Tinderbox User and Michał Kępień
e7b0d5de15
prep 9.11.23
2020-09-16 23:00:15 +02:00
Evan Hunt
400171aee8
update all copyright headers to eliminate the typo
2020-09-14 17:00:40 -07:00
Mark Andrews
87e8497b6a
Silence REVERSE_INULL warning (CID 306652)
...
(cherry picked from commit 584dbffab1 )
2020-09-10 07:57:20 +10:00
Mark Andrews
1d0c1e62b4
Silence Coverity missing lock warning.
...
Lock access to 'done' during initialisation in manytasks().
2020-09-09 21:02:51 +00:00
Mark Andrews
1f7a4f9ab2
Turn off TSAN for isc_log_wouldlog
2020-09-08 17:41:33 +10:00
Mark Andrews
d6c727d669
ISC_QUEUE_POP is not tsan safe. Suppress warnings
...
ret->link.next is tested to see if it is NULL unlocked
to avoid obtaining taillock when it is not nexessary then
retested once the taillock is obtained.
2020-09-08 17:41:33 +10:00
Mark Andrews
72cbe648c4
Test if linked while holding the queue lock
...
WARNING: ThreadSanitizer: data race
Read of size 8 at 0x000000000001 by thread T1:
#0 client_shutdown bin/named/client.c:849:6
#1 dispatch lib/isc/task.c:1157:7
#2 run lib/isc/task.c:1331:2
Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M1, write M2):
#0 client_shutdown bin/named/client.c:850:3
#1 dispatch lib/isc/task.c:1157:7
#2 run lib/isc/task.c:1331:2
2020-09-08 09:25:43 +10:00
Mark Andrews
fb8a3c9ab2
Remove optimisation on obtaining a headlock as it triggers a tsan.
...
WARNING: ThreadSanitizer: data race (pid=15898)
Write of size 8 at 0x7b6400011818 by thread T9 (mutexes: write M1597):
#0 get_client /builds/isc-projects/bind9/bin/named/client.c:3876:3 (named+0x4db171)
#1 ns_client_replace /builds/isc-projects/bind9/bin/named/client.c:3710:12 (named+0x4d737b)
#2 query_recurse /builds/isc-projects/bind9/bin/named/query.c:4325:13 (named+0x4ff469)
#3 query_find /builds/isc-projects/bind9/bin/named/query.c (named+0x4fb949)
#4 ns_query_start /builds/isc-projects/bind9/bin/named/query.c:9675:8 (named+0x4f37cb)
#5 client_request /builds/isc-projects/bind9/bin/named/client.c:3112:3 (named+0x4de9ef)
#6 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
#7 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d799)
Previous read of size 8 at 0x7b6400011818 by thread T2:
#0 exit_check /builds/isc-projects/bind9/bin/named/client.c:698:5 (named+0x4d5d22)
#1 ns_client_detach /builds/isc-projects/bind9/bin/named/client.c:3687:8 (named+0x4d7762)
#2 query_find /builds/isc-projects/bind9/bin/named/query.c (named+0x4f9021)
#3 query_resume /builds/isc-projects/bind9/bin/named/query.c:4164:12 (named+0x509b68)
#4 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
#5 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d799)
2020-09-08 09:25:43 +10:00
Mark Andrews
15ae4585d2
counter->used was read without the lock being held.
...
WARNING: ThreadSanitizer: data race (pid=11785)
Write of size 4 at 0x7b180001ba10 by thread T12 (mutexes: write M835834548863482336):
#0 isc_counter_increment /builds/isc-projects/bind9/lib/isc/counter.c:70:15 (libisc.so.1107+0x1dcb6)
#1 fctx_try /builds/isc-projects/bind9/lib/dns/resolver.c:3851:11 (libdns.so.1110+0x17e312)
#2 resume_dslookup /builds/isc-projects/bind9/lib/dns/resolver.c:7505:3 (libdns.so.1110+0x18ccf0)
#3 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x507f5)
#4 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d749)
Previous read of size 4 at 0x7b180001ba10 by thread T7:
#0 isc_counter_used /builds/isc-projects/bind9/lib/isc/counter.c:82:19 (libisc.so.1107+0x1dd5f)
#1 fctx_try /builds/isc-projects/bind9/lib/dns/resolver.c:3798:6 (libdns.so.1110+0x17e0d1)
#2 fctx_start /builds/isc-projects/bind9/lib/dns/resolver.c:4219:4 (libdns.so.1110+0x178833)
#3 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x507f5)
#4 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d749)
2020-09-08 09:25:43 +10:00
Mark Andrews
cf4a9d9ab8
It appears that you can't change what you are polling for while connecting.
...
WARNING: ThreadSanitizer: data race (pid=6465)
Read of size 8 at 0x7ba000002040 by thread T14:
#0 epoll_ctl <null> (named+0x44ccd2)
#1 watch_fd /builds/isc-projects/bind9/lib/isc/unix/socket.c:975:8 (libisc.so.1107+0x6bd90)
#2 wakeup_socket /builds/isc-projects/bind9/lib/isc/unix/socket.c:1164:11 (libisc.so.1107+0x7057d)
#3 process_ctlfd /builds/isc-projects/bind9/lib/isc/unix/socket.c:4258:3 (libisc.so.1107+0x6c308)
#4 process_fds /builds/isc-projects/bind9/lib/isc/unix/socket.c:4162:10 (libisc.so.1107+0x6bf74)
#5 watcher /builds/isc-projects/bind9/lib/isc/unix/socket.c:4401:10 (libisc.so.1107+0x64348)
Previous write of size 8 at 0x7ba000002040 by thread T9 (mutexes: write M81481868977181736):
#0 connect <null> (named+0x44b7e0)
#1 isc__socket_connect /builds/isc-projects/bind9/lib/isc/unix/socket.c:5902:7 (libisc.so.1107+0x67a79)
#2 isc_socket_connect /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:169:11 (libisc.so.1107+0x6aa4b)
#3 resquery_send /builds/isc-projects/bind9/lib/dns/resolver.c:2573:13 (libdns.so.1110+0x18570b)
#4 fctx_query /builds/isc-projects/bind9/lib/dns/resolver.c:1903:12 (libdns.so.1110+0x1815a3)
#5 fctx_try /builds/isc-projects/bind9/lib/dns/resolver.c:3863:11 (libdns.so.1110+0x17e3a9)
#6 fctx_start /builds/isc-projects/bind9/lib/dns/resolver.c:4219:4 (libdns.so.1110+0x178833)
#7 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x507f5)
#8 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d749)
Location is file descriptor 516 created by thread T9 at:
#0 connect <null> (named+0x44b7e0)
#1 isc__socket_connect /builds/isc-projects/bind9/lib/isc/unix/socket.c:5902:7 (libisc.so.1107+0x67a79)
#2 isc_socket_connect /builds/isc-projects/bind9/lib/isc/unix/./../socket_api.c:169:11 (libisc.so.1107+0x6aa4b)
#3 resquery_send /builds/isc-projects/bind9/lib/dns/resolver.c:2573:13 (libdns.so.1110+0x18570b)
#4 fctx_query /builds/isc-projects/bind9/lib/dns/resolver.c:1903:12 (libdns.so.1110+0x1815a3)
#5 fctx_try /builds/isc-projects/bind9/lib/dns/resolver.c:3863:11 (libdns.so.1110+0x17e3a9)
#6 fctx_start /builds/isc-projects/bind9/lib/dns/resolver.c:4219:4 (libdns.so.1110+0x178833)
#7 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x507f5)
#8 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d749)
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
52a715b122
isc_mutex_init_errcheck prototype should not be under ISC_MUTEX_PROFILE
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
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
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
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
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 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
Tinderbox User
7427b1f31c
prep 9.11.22
2020-08-06 10:05:20 +00:00
Ondřej Surý and Michał 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
Petr Menšík and Mark 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 User and Michał 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