[v9_9] address two more possible acache asserts

3555.	[bug]		Address theoretical race conditions in acache.c
			(change #3553 was incomplete). [RT #33252]
(cherry picked from commit ff5ac6d421)
This commit is contained in:
Evan Hunt
2013-04-25 18:03:28 -07:00
parent 268f738ff2
commit 62ebf6bbef
4 changed files with 28 additions and 9 deletions
+3
View File
@@ -1,3 +1,6 @@
3555. [bug] Address theoretical race conditions in acache.c
(change #3553 was incomplete). [RT #33252]
3553. [bug] Address suspected double free in acache. [RT #33252]
3552. [bug] Wrong getopt option string for 'nsupdate -r'.
+17 -5
View File
@@ -868,7 +868,11 @@ acache_incremental_cleaning_action(isc_task_t *task, isc_event_t *event) {
if (entry != NULL) {
/*
* If we are still in the overmem
* state, keep cleaning.
* state, keep cleaning. In case we
* exit from the loop immediately after
* this, reset next to the head entry
* as we'll expect it will be never
* NULL.
*/
isc_log_write(dns_lctx,
DNS_LOGCATEGORY_DATABASE,
@@ -877,6 +881,7 @@ acache_incremental_cleaning_action(isc_task_t *task, isc_event_t *event) {
"acache cleaner: "
"still overmem, "
"reset and try again");
next = entry;
continue;
}
}
@@ -895,7 +900,7 @@ acache_incremental_cleaning_action(isc_task_t *task, isc_event_t *event) {
* be the starting point in the next clean-up, and reschedule another
* batch. If it fails, just try to continue anyway.
*/
INSIST(next != NULL && next != cleaner->current_entry);
INSIST(next != NULL);
dns_acache_detachentry(&cleaner->current_entry);
dns_acache_attachentry(next, &cleaner->current_entry);
@@ -1656,12 +1661,17 @@ dns_acache_setentry(dns_acache_t *acache, dns_acacheentry_t *entry,
return (result);
}
void
isc_boolean_t
dns_acache_cancelentry(dns_acacheentry_t *entry) {
dns_acache_t *acache = entry->acache;
dns_acache_t *acache;
isc_boolean_t callback_active;
REQUIRE(DNS_ACACHEENTRY_VALID(entry));
INSIST(DNS_ACACHE_VALID(acache));
acache = entry->acache;
callback_active = ISC_TF(entry->cbarg != NULL);
INSIST(DNS_ACACHE_VALID(entry->acache));
LOCK(&acache->lock);
ACACHE_LOCK(&acache->entrylocks[entry->locknum], isc_rwlocktype_write);
@@ -1681,6 +1691,8 @@ dns_acache_cancelentry(dns_acacheentry_t *entry) {
ACACHE_UNLOCK(&acache->entrylocks[entry->locknum],
isc_rwlocktype_write);
UNLOCK(&acache->lock);
return (callback_active);
}
void
+4 -1
View File
@@ -387,7 +387,7 @@ dns_acache_setentry(dns_acache_t *acache, dns_acacheentry_t *entry,
* ISC_R_NOTFOUND
*/
void
isc_boolean_t
dns_acache_cancelentry(dns_acacheentry_t *entry);
/*
* Cancel the use of the cache entry 'entry'. This function is supposed to
@@ -398,6 +398,9 @@ dns_acache_cancelentry(dns_acacheentry_t *entry);
*
* Requires:
* 'entry' is a valid additional cache entry.
*
* Returns:
* ISC_TRUE if the entry was active when canceled
*/
void
+4 -3
View File
@@ -8958,9 +8958,10 @@ acache_cancelentry(isc_mem_t *mctx, dns_acacheentry_t *entry,
cbarg = *cbargp;
dns_acache_cancelentry(entry);
dns_db_detachnode(cbarg->db, &cbarg->node);
dns_db_detach(&cbarg->db);
if (dns_acache_cancelentry(entry)) {
dns_db_detachnode(cbarg->db, &cbarg->node);
dns_db_detach(&cbarg->db);
}
isc_mem_put(mctx, cbarg, sizeof(acache_cbarg_t));