Commit 882d79b2 authored by Mark Andrews's avatar Mark Andrews

r/w of rbtdb->current_version requires that rbtdb->lock be held

(cherry picked from commit cd2469d3)
parent 020fc086
Pipeline #26951 passed with stages
in 31 minutes and 31 seconds
......@@ -7157,8 +7157,11 @@ subtractrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
* Update the zone's secure status. If version is non-NULL
* this is deferred until closeversion() is called.
*/
if (result == ISC_R_SUCCESS && version == NULL && !IS_CACHE(rbtdb))
if (result == ISC_R_SUCCESS && version == NULL && !IS_CACHE(rbtdb)) {
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
iszonesecure(db, rbtdb->current_version, rbtdb->origin_node);
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
}
return (result);
}
......@@ -7214,8 +7217,11 @@ deleterdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version,
* Update the zone's secure status. If version is non-NULL
* this is deferred until closeversion() is called.
*/
if (result == ISC_R_SUCCESS && version == NULL && !IS_CACHE(rbtdb))
if (result == ISC_R_SUCCESS && version == NULL && !IS_CACHE(rbtdb)) {
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write);
iszonesecure(db, rbtdb->current_version, rbtdb->origin_node);
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
}
return (result);
}
......@@ -7697,14 +7703,14 @@ endload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) {
rbtdb->attributes &= ~RBTDB_ATTR_LOADING;
rbtdb->attributes |= RBTDB_ATTR_LOADED;
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
/*
* If there's a KEY rdataset at the zone origin containing a
* zone key, we consider the zone secure.
*/
if (! IS_CACHE(rbtdb) && rbtdb->origin_node != NULL)
if (! IS_CACHE(rbtdb) && rbtdb->origin_node != NULL) {
iszonesecure(db, rbtdb->current_version, rbtdb->origin_node);
}
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_write);
callbacks->add = NULL;
callbacks->add_private = NULL;
......@@ -7970,9 +7976,9 @@ issecure(dns_db_t *db) {
REQUIRE(VALID_RBTDB(rbtdb));
RWLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
secure = (rbtdb->current_version->secure == dns_db_secure);
RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
return (secure);
}
......@@ -7986,9 +7992,9 @@ isdnssec(dns_db_t *db) {
REQUIRE(VALID_RBTDB(rbtdb));
RWLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
dnssec = (rbtdb->current_version->secure != dns_db_insecure);
RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
return (dnssec);
}
......@@ -8086,10 +8092,10 @@ getnsec3parameters(dns_db_t *db, dns_dbversion_t *version, dns_hash_t *hash,
REQUIRE(VALID_RBTDB(rbtdb));
INSIST(rbtversion == NULL || rbtversion->rbtdb == rbtdb);
RWLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
if (rbtversion == NULL)
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
if (rbtversion == NULL) {
rbtversion = rbtdb->current_version;
}
if (rbtversion->havensec3) {
if (hash != NULL)
......@@ -8107,7 +8113,7 @@ getnsec3parameters(dns_db_t *db, dns_dbversion_t *version, dns_hash_t *hash,
*flags = rbtversion->flags;
result = ISC_R_SUCCESS;
}
RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_read);
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
return (result);
}
......@@ -8125,16 +8131,21 @@ getsize(dns_db_t *db, dns_dbversion_t *version, uint64_t *records,
REQUIRE(VALID_RBTDB(rbtdb));
INSIST(rbtversion == NULL || rbtversion->rbtdb == rbtdb);
if (rbtversion == NULL)
RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_read);
if (rbtversion == NULL) {
rbtversion = rbtdb->current_version;
}
RWLOCK(&rbtversion->rwlock, isc_rwlocktype_read);
if (records != NULL)
if (records != NULL) {
*records = rbtversion->records;
}
if (bytes != NULL)
if (bytes != NULL) {
*bytes = rbtversion->bytes;
}
RWUNLOCK(&rbtversion->rwlock, isc_rwlocktype_read);
RBTDB_UNLOCK(&rbtdb->lock, isc_rwlocktype_read);
return (result);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment