2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

fix a TSAN bug in "rndc fetchlimit"

fctx counters could be accessed without locking when
"rndc fetchlimit" is called; while this is probably harmless
in production, it triggered TSAN reports in system tests.
This commit is contained in:
Evan Hunt
2023-06-28 14:52:53 -07:00
parent bbc64c14e3
commit 5ba73c785e

View File

@@ -11175,11 +11175,19 @@ dns_resolver_dumpquota(dns_resolver_t *res, isc_buffer_t **buf) {
result = isc_hashmap_iter_next(it)) result = isc_hashmap_iter_next(it))
{ {
fctxcount_t *counter = NULL; fctxcount_t *counter = NULL;
isc_hashmap_iter_current(it, (void **)&counter); uint_fast32_t count, dropped, allowed;
char nb[DNS_NAME_FORMATSIZE], char nb[DNS_NAME_FORMATSIZE];
text[DNS_NAME_FORMATSIZE + BUFSIZ]; char text[DNS_NAME_FORMATSIZE + BUFSIZ];
if (counter->count < spill) { isc_hashmap_iter_current(it, (void **)&counter);
LOCK(&counter->lock);
count = counter->count;
dropped = counter->dropped;
allowed = counter->allowed;
UNLOCK(&counter->lock);
if (count < spill) {
continue; continue;
} }
@@ -11187,8 +11195,7 @@ dns_resolver_dumpquota(dns_resolver_t *res, isc_buffer_t **buf) {
snprintf(text, sizeof(text), snprintf(text, sizeof(text),
"\n- %s: %" PRIuFAST32 " active (allowed %" PRIuFAST32 "\n- %s: %" PRIuFAST32 " active (allowed %" PRIuFAST32
" spilled %" PRIuFAST32 ")", " spilled %" PRIuFAST32 ")",
nb, counter->count, counter->allowed, nb, count, allowed, dropped);
counter->dropped);
result = isc_buffer_reserve(*buf, strlen(text)); result = isc_buffer_reserve(*buf, strlen(text));
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {