4213. [bug] Don't reuse a cache across multiple classes.

[RT #40205]

(cherry picked from commit dd1bcab25c)
This commit is contained in:
Mark Andrews
2015-09-17 14:53:45 +10:00
parent fd82172e14
commit 4cbbeae1aa
3 changed files with 30 additions and 7 deletions
+3
View File
@@ -1,3 +1,6 @@
4213. [bug] Don't reuse a cache across multiple classes.
[RT #40205]
4210. [cleanup] Silence use after free false positive. [RT #40743]
4208. [bug] Address null pointer dereferences on out of memory.
+10 -4
View File
@@ -188,6 +188,7 @@ struct ns_cache {
dns_view_t *primaryview;
isc_boolean_t needflush;
isc_boolean_t adbsizeadjusted;
dns_rdataclass_t rdclass;
ISC_LINK(ns_cache_t) link;
};
@@ -1388,13 +1389,16 @@ setquerystats(dns_zone_t *zone, isc_mem_t *mctx, dns_zonestat_level_t level) {
}
static ns_cache_t *
cachelist_find(ns_cachelist_t *cachelist, const char *cachename) {
cachelist_find(ns_cachelist_t *cachelist, const char *cachename,
dns_rdataclass_t rdclass)
{
ns_cache_t *nsc;
for (nsc = ISC_LIST_HEAD(*cachelist);
nsc != NULL;
nsc = ISC_LIST_NEXT(nsc, link)) {
if (strcmp(dns_cache_getname(nsc->cache), cachename) == 0)
if (nsc->rdclass == rdclass &&
strcmp(dns_cache_getname(nsc->cache), cachename) == 0)
return (nsc);
}
@@ -1405,7 +1409,8 @@ static isc_boolean_t
cache_reusable(dns_view_t *originview, dns_view_t *view,
isc_boolean_t new_zero_no_soattl)
{
if (originview->checknames != view->checknames ||
if (originview->rdclass != view->rdclass ||
originview->checknames != view->checknames ||
dns_resolver_getzeronosoattl(originview->resolver) !=
new_zero_no_soattl ||
originview->acceptexpired != view->acceptexpired ||
@@ -2595,7 +2600,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
else
cachename = view->name;
cache = NULL;
nsc = cachelist_find(cachelist, cachename);
nsc = cachelist_find(cachelist, cachename, view->rdclass);
if (nsc != NULL) {
if (!cache_sharable(nsc->primaryview, view, zero_no_soattl,
cleaning_interval, max_cache_size)) {
@@ -2677,6 +2682,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
nsc->primaryview = view;
nsc->needflush = ISC_FALSE;
nsc->adbsizeadjusted = ISC_FALSE;
nsc->rdclass = view->rdclass;
ISC_LINK_INIT(nsc, link);
ISC_LIST_APPEND(*cachelist, nsc, link);
}
+17 -3
View File
@@ -35,6 +35,7 @@ options {
except-from { "goodcname.example.net";
"gooddname.example.net"; };
allow-query {!10.53.0.8; any; };
attach-cache "globalcache";
};
server 10.42.23.3/32 {
@@ -49,8 +50,21 @@ server fd92:7065:b8e:ffff::1000 {
transfer-source-v6 fd92:7065:b8e:ffff::1001;
};
zone "." {
type hint;
file "root.hint";
/*
* Must be first view so that there is a CH cache with name
* "globalcache" before the recursive "default"/IN view is configured.
*/
view "class" chaos {
match-clients { none; };
};
/*
* Must be second view so that so that we can check we don't attach to the
* "globalcache"/CH cache.
*/
view "default" {
zone "." {
type hint;
file "root.hint";
};
};