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

Use sock->nchildren instead of mgr->nworkers when initializing NM

On Windows, we were limiting the number of listening children to just 1,
but we were then iterating on mgr->nworkers.  That lead to scheduling
more async_*listen() than actually allocated and out-of-bound read-write
operation on the heap.
This commit is contained in:
Ondřej Surý
2020-12-03 17:58:10 +01:00
committed by Ondřej Surý
parent ae35829faf
commit 87c5867202
6 changed files with 25 additions and 21 deletions

View File

@@ -468,14 +468,14 @@ isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
memset(sock->children, 0, children_size);
sock->result = ISC_R_DEFAULT;
sock->tid = isc_random_uniform(mgr->nworkers);
sock->tid = isc_random_uniform(sock->nchildren);
sock->fd = -1;
#if !HAVE_SO_REUSEPORT_LB && !defined(WIN32)
fd = isc__nm_tcpdns_lb_socket(sa_family);
#endif
for (size_t i = 0; i < mgr->nworkers; i++) {
for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_tcpdnslisten_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
@@ -512,7 +512,7 @@ isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
#endif
LOCK(&sock->lock);
while (sock->rchildren != mgr->nworkers) {
while (sock->rchildren != sock->nchildren) {
WAIT(&sock->cond, &sock->lock);
}
result = sock->result;
@@ -522,7 +522,7 @@ isc_nm_listentcpdns(isc_nm_t *mgr, isc_nmiface_t *iface,
INSIST(result != ISC_R_DEFAULT);
if (result == ISC_R_SUCCESS) {
REQUIRE(sock->rchildren == mgr->nworkers);
REQUIRE(sock->rchildren == sock->nchildren);
*sockp = sock;
} else {
atomic_store(&sock->active, false);
@@ -1420,7 +1420,7 @@ stop_tcpdns_parent(isc_nmsocket_t *sock) {
REQUIRE(VALID_NMSOCK(sock));
REQUIRE(sock->type == isc_nm_tcpdnslistener);
for (int i = 0; i < sock->nchildren; i++) {
for (size_t i = 0; i < sock->nchildren; i++) {
isc__netievent_tcpdnsstop_t *ievent = NULL;
isc_nmsocket_t *csock = &sock->children[i];
REQUIRE(VALID_NMSOCK(csock));