|
|
900526 |
diff -up bind-9.9.4/bin/named/config.c.CVE-2014-8500 bind-9.9.4/bin/named/config.c
|
|
|
900526 |
--- bind-9.9.4/bin/named/config.c.CVE-2014-8500 2013-09-05 07:09:08.000000000 +0200
|
|
|
900526 |
+++ bind-9.9.4/bin/named/config.c 2014-12-10 14:56:24.959552559 +0100
|
|
|
900526 |
@@ -160,6 +160,8 @@ options {\n\
|
|
|
900526 |
dnssec-accept-expired no;\n\
|
|
|
900526 |
clients-per-query 10;\n\
|
|
|
900526 |
max-clients-per-query 100;\n\
|
|
|
900526 |
+ max-recursion-depth 7;\n\
|
|
|
900526 |
+ max-recursion-queries 50;\n\
|
|
|
900526 |
zero-no-soa-ttl-cache no;\n\
|
|
|
900526 |
nsec3-test-zone no;\n\
|
|
|
900526 |
allow-new-zones no;\n\
|
|
|
900526 |
diff -up bind-9.9.4/bin/named/query.c.CVE-2014-8500 bind-9.9.4/bin/named/query.c
|
|
|
900526 |
--- bind-9.9.4/bin/named/query.c.CVE-2014-8500 2014-12-10 14:56:24.945552543 +0100
|
|
|
900526 |
+++ bind-9.9.4/bin/named/query.c 2014-12-10 14:56:24.960552560 +0100
|
|
|
900526 |
@@ -3872,12 +3872,11 @@ query_recurse(ns_client_t *client, dns_r
|
|
|
900526 |
peeraddr = &client->peeraddr;
|
|
|
900526 |
else
|
|
|
900526 |
peeraddr = NULL;
|
|
|
900526 |
- result = dns_resolver_createfetch2(client->view->resolver,
|
|
|
900526 |
+ result = dns_resolver_createfetch3(client->view->resolver,
|
|
|
900526 |
qname, qtype, qdomain, nameservers,
|
|
|
900526 |
NULL, peeraddr, client->message->id,
|
|
|
900526 |
- client->query.fetchoptions,
|
|
|
900526 |
- client->task,
|
|
|
900526 |
- query_resume, client,
|
|
|
900526 |
+ client->query.fetchoptions, 0, NULL,
|
|
|
900526 |
+ client->task, query_resume, client,
|
|
|
900526 |
rdataset, sigrdataset,
|
|
|
900526 |
&client->query.fetch);
|
|
|
900526 |
|
|
|
900526 |
diff -up bind-9.9.4/bin/named/server.c.CVE-2014-8500 bind-9.9.4/bin/named/server.c
|
|
|
900526 |
--- bind-9.9.4/bin/named/server.c.CVE-2014-8500 2014-12-10 14:56:24.913552507 +0100
|
|
|
900526 |
+++ bind-9.9.4/bin/named/server.c 2014-12-10 14:56:24.961552561 +0100
|
|
|
900526 |
@@ -3205,6 +3205,16 @@ configure_view(dns_view_t *view, cfg_obj
|
|
|
900526 |
cfg_obj_asuint32(obj),
|
|
|
900526 |
max_clients_per_query);
|
|
|
900526 |
|
|
|
900526 |
+ obj = NULL;
|
|
|
900526 |
+ result = ns_config_get(maps, "max-recursion-depth", &obj);
|
|
|
900526 |
+ INSIST(result == ISC_R_SUCCESS);
|
|
|
900526 |
+ dns_resolver_setmaxdepth(view->resolver, cfg_obj_asuint32(obj));
|
|
|
900526 |
+
|
|
|
900526 |
+ obj = NULL;
|
|
|
900526 |
+ result = ns_config_get(maps, "max-recursion-queries", &obj);
|
|
|
900526 |
+ INSIST(result == ISC_R_SUCCESS);
|
|
|
900526 |
+ dns_resolver_setmaxqueries(view->resolver, cfg_obj_asuint32(obj));
|
|
|
900526 |
+
|
|
|
900526 |
#ifdef ALLOW_FILTER_AAAA_ON_V4
|
|
|
900526 |
obj = NULL;
|
|
|
900526 |
result = ns_config_get(maps, "filter-aaaa-on-v4", &obj);
|
|
|
900526 |
diff -up bind-9.9.4/doc/arm/Bv9ARM-book.xml.CVE-2014-8500 bind-9.9.4/doc/arm/Bv9ARM-book.xml
|
|
|
900526 |
--- bind-9.9.4/doc/arm/Bv9ARM-book.xml.CVE-2014-8500 2014-12-10 14:56:24.957552556 +0100
|
|
|
900526 |
+++ bind-9.9.4/doc/arm/Bv9ARM-book.xml 2014-12-10 15:00:53.108931629 +0100
|
|
|
900526 |
@@ -4874,6 +4874,8 @@ badresp:1,adberr:0,findfail:0,valfail:0]
|
|
|
900526 |
<optional> max-acache-size <replaceable>size_spec</replaceable> ; </optional>
|
|
|
900526 |
<optional> clients-per-query <replaceable>number</replaceable> ; </optional>
|
|
|
900526 |
<optional> max-clients-per-query <replaceable>number</replaceable> ; </optional>
|
|
|
900526 |
+ <optional> max-recursion-depth <replaceable>number</replaceable> ; </optional>
|
|
|
900526 |
+ <optional> max-recursion-queries <replaceable>number</replaceable> ; </optional>
|
|
|
900526 |
<optional> masterfile-format (<constant>text</constant>|<constant>raw</constant>) ; </optional>
|
|
|
900526 |
<optional> empty-server <replaceable>name</replaceable> ; </optional>
|
|
|
900526 |
<optional> empty-contact <replaceable>name</replaceable> ; </optional>
|
|
|
900526 |
@@ -8623,6 +8625,35 @@ avoid-v6-udp-ports { 40000; range 50000
|
|
|
900526 |
</para>
|
|
|
900526 |
</listitem>
|
|
|
900526 |
</varlistentry>
|
|
|
900526 |
+
|
|
|
900526 |
+ <varlistentry id="max-recursion-depth">
|
|
|
900526 |
+ <term><command>max-recursion-depth</command></term>
|
|
|
900526 |
+ <listitem>
|
|
|
900526 |
+ <para>
|
|
|
900526 |
+ Sets the maximum number of levels of recursion
|
|
|
900526 |
+ that are permitted at any one time while servicing
|
|
|
900526 |
+ a recursive query. Resolving a name may require
|
|
|
900526 |
+ looking up a name server address, which in turn
|
|
|
900526 |
+ requires resolving another name, etc; if the number
|
|
|
900526 |
+ of indirections exceeds this value, the recursive
|
|
|
900526 |
+ query is terminated and returns SERVFAIL. The
|
|
|
900526 |
+ default is 7.
|
|
|
900526 |
+ </para>
|
|
|
900526 |
+ </listitem>
|
|
|
900526 |
+ </varlistentry>
|
|
|
900526 |
+
|
|
|
900526 |
+ <varlistentry id="max-recursion-queries">
|
|
|
900526 |
+ <term><command>max-recursion-queries</command></term>
|
|
|
900526 |
+ <listitem>
|
|
|
900526 |
+ <para>
|
|
|
900526 |
+ Sets the maximum number of iterative queries that
|
|
|
900526 |
+ may be sent while servicing a recursive query.
|
|
|
900526 |
+ If more queries are sent, the recursive query
|
|
|
900526 |
+ is terminated and returns SERVFAIL. The default
|
|
|
900526 |
+ is 50.
|
|
|
900526 |
+ </para>
|
|
|
900526 |
+ </listitem>
|
|
|
900526 |
+ </varlistentry>
|
|
|
900526 |
|
|
|
900526 |
<varlistentry>
|
|
|
900526 |
<term><command>notify-delay</command></term>
|
|
|
900526 |
diff -up bind-9.9.4/doc/misc/options.CVE-2014-8500 bind-9.9.4/doc/misc/options
|
|
|
900526 |
--- bind-9.9.4/doc/misc/options.CVE-2014-8500 2013-09-05 07:09:08.000000000 +0200
|
|
|
900526 |
+++ bind-9.9.4/doc/misc/options 2014-12-10 14:56:24.964552564 +0100
|
|
|
900526 |
@@ -162,6 +162,8 @@ options {
|
|
|
900526 |
max-ixfr-log-size <size>; // obsolete
|
|
|
900526 |
max-journal-size <size_no_default>;
|
|
|
900526 |
max-ncache-ttl <integer>;
|
|
|
900526 |
+ max-recursion-depth <integer>;
|
|
|
900526 |
+ max-recursion-queries <integer>;
|
|
|
900526 |
max-refresh-time <integer>;
|
|
|
900526 |
max-retry-time <integer>;
|
|
|
900526 |
max-rsa-exponent-size <integer>;
|
|
|
900526 |
@@ -385,6 +387,8 @@ view <string> <optional_class> {
|
|
|
900526 |
max-ixfr-log-size <size>; // obsolete
|
|
|
900526 |
max-journal-size <size_no_default>;
|
|
|
900526 |
max-ncache-ttl <integer>;
|
|
|
900526 |
+ max-recursion-depth <integer>;
|
|
|
900526 |
+ max-recursion-queries <integer>;
|
|
|
900526 |
max-refresh-time <integer>;
|
|
|
900526 |
max-retry-time <integer>;
|
|
|
900526 |
max-transfer-idle-in <integer>;
|
|
|
900526 |
diff -up bind-9.9.4/lib/dns/adb.c.CVE-2014-8500 bind-9.9.4/lib/dns/adb.c
|
|
|
900526 |
--- bind-9.9.4/lib/dns/adb.c.CVE-2014-8500 2013-09-05 07:09:08.000000000 +0200
|
|
|
900526 |
+++ bind-9.9.4/lib/dns/adb.c 2014-12-10 14:56:24.965552566 +0100
|
|
|
900526 |
@@ -201,6 +201,7 @@ struct dns_adbfetch {
|
|
|
900526 |
unsigned int magic;
|
|
|
900526 |
dns_fetch_t *fetch;
|
|
|
900526 |
dns_rdataset_t rdataset;
|
|
|
900526 |
+ unsigned int depth;
|
|
|
900526 |
};
|
|
|
900526 |
|
|
|
900526 |
/*%
|
|
|
900526 |
@@ -300,8 +301,7 @@ static inline isc_boolean_t dec_entry_re
|
|
|
900526 |
static inline void violate_locking_hierarchy(isc_mutex_t *, isc_mutex_t *);
|
|
|
900526 |
static isc_boolean_t clean_namehooks(dns_adb_t *, dns_adbnamehooklist_t *);
|
|
|
900526 |
static void clean_target(dns_adb_t *, dns_name_t *);
|
|
|
900526 |
-static void clean_finds_at_name(dns_adbname_t *, isc_eventtype_t,
|
|
|
900526 |
- unsigned int);
|
|
|
900526 |
+static void clean_finds_at_name(dns_adbname_t *, isc_eventtype_t, unsigned int);
|
|
|
900526 |
static isc_boolean_t check_expire_namehooks(dns_adbname_t *, isc_stdtime_t);
|
|
|
900526 |
static isc_boolean_t check_expire_entry(dns_adb_t *, dns_adbentry_t **,
|
|
|
900526 |
isc_stdtime_t);
|
|
|
900526 |
@@ -309,6 +309,7 @@ static void cancel_fetches_at_name(dns_a
|
|
|
900526 |
static isc_result_t dbfind_name(dns_adbname_t *, isc_stdtime_t,
|
|
|
900526 |
dns_rdatatype_t);
|
|
|
900526 |
static isc_result_t fetch_name(dns_adbname_t *, isc_boolean_t,
|
|
|
900526 |
+ unsigned int, isc_counter_t *qc,
|
|
|
900526 |
dns_rdatatype_t);
|
|
|
900526 |
static inline void check_exit(dns_adb_t *);
|
|
|
900526 |
static void destroy(dns_adb_t *);
|
|
|
900526 |
@@ -2770,6 +2771,19 @@ dns_adb_createfind(dns_adb_t *adb, isc_t
|
|
|
900526 |
isc_stdtime_t now, dns_name_t *target,
|
|
|
900526 |
in_port_t port, dns_adbfind_t **findp)
|
|
|
900526 |
{
|
|
|
900526 |
+ return (dns_adb_createfind2(adb, task, action, arg, name,
|
|
|
900526 |
+ qname, qtype, options, now,
|
|
|
900526 |
+ target, port, 0, NULL, findp));
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+dns_adb_createfind2(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|
|
900526 |
+ void *arg, dns_name_t *name, dns_name_t *qname,
|
|
|
900526 |
+ dns_rdatatype_t qtype, unsigned int options,
|
|
|
900526 |
+ isc_stdtime_t now, dns_name_t *target,
|
|
|
900526 |
+ in_port_t port, unsigned int depth, isc_counter_t *qc,
|
|
|
900526 |
+ dns_adbfind_t **findp)
|
|
|
900526 |
+{
|
|
|
900526 |
dns_adbfind_t *find;
|
|
|
900526 |
dns_adbname_t *adbname;
|
|
|
900526 |
int bucket;
|
|
|
900526 |
@@ -3000,7 +3014,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_t
|
|
|
900526 |
* Start V4.
|
|
|
900526 |
*/
|
|
|
900526 |
if (WANT_INET(wanted_fetches) &&
|
|
|
900526 |
- fetch_name(adbname, start_at_zone,
|
|
|
900526 |
+ fetch_name(adbname, start_at_zone, depth, qc,
|
|
|
900526 |
dns_rdatatype_a) == ISC_R_SUCCESS) {
|
|
|
900526 |
DP(DEF_LEVEL,
|
|
|
900526 |
"dns_adb_createfind: started A fetch for name %p",
|
|
|
900526 |
@@ -3011,7 +3025,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_t
|
|
|
900526 |
* Start V6.
|
|
|
900526 |
*/
|
|
|
900526 |
if (WANT_INET6(wanted_fetches) &&
|
|
|
900526 |
- fetch_name(adbname, start_at_zone,
|
|
|
900526 |
+ fetch_name(adbname, start_at_zone, depth, qc,
|
|
|
900526 |
dns_rdatatype_aaaa) == ISC_R_SUCCESS) {
|
|
|
900526 |
DP(DEF_LEVEL,
|
|
|
900526 |
"dns_adb_createfind: "
|
|
|
900526 |
@@ -3754,6 +3768,12 @@ fetch_callback(isc_task_t *task, isc_eve
|
|
|
900526 |
DP(DEF_LEVEL, "adb: fetch of '%s' %s failed: %s",
|
|
|
900526 |
buf, address_type == DNS_ADBFIND_INET ? "A" : "AAAA",
|
|
|
900526 |
dns_result_totext(dev->result));
|
|
|
900526 |
+ /*
|
|
|
900526 |
+ * Don't record a failure unless this is the initial
|
|
|
900526 |
+ * fetch of a chain.
|
|
|
900526 |
+ */
|
|
|
900526 |
+ if (fetch->depth > 1)
|
|
|
900526 |
+ goto out;
|
|
|
900526 |
/* XXXMLG Don't pound on bad servers. */
|
|
|
900526 |
if (address_type == DNS_ADBFIND_INET) {
|
|
|
900526 |
name->expire_v4 = ISC_MIN(name->expire_v4, now + 300);
|
|
|
900526 |
@@ -3791,9 +3811,8 @@ fetch_callback(isc_task_t *task, isc_eve
|
|
|
900526 |
}
|
|
|
900526 |
|
|
|
900526 |
static isc_result_t
|
|
|
900526 |
-fetch_name(dns_adbname_t *adbname,
|
|
|
900526 |
- isc_boolean_t start_at_zone,
|
|
|
900526 |
- dns_rdatatype_t type)
|
|
|
900526 |
+fetch_name(dns_adbname_t *adbname, isc_boolean_t start_at_zone,
|
|
|
900526 |
+ unsigned int depth, isc_counter_t *qc, dns_rdatatype_t type)
|
|
|
900526 |
{
|
|
|
900526 |
isc_result_t result;
|
|
|
900526 |
dns_adbfetch_t *fetch = NULL;
|
|
|
900526 |
@@ -3838,12 +3857,14 @@ fetch_name(dns_adbname_t *adbname,
|
|
|
900526 |
result = ISC_R_NOMEMORY;
|
|
|
900526 |
goto cleanup;
|
|
|
900526 |
}
|
|
|
900526 |
+ fetch->depth = depth;
|
|
|
900526 |
|
|
|
900526 |
- result = dns_resolver_createfetch(adb->view->resolver, &adbname->name,
|
|
|
900526 |
- type, name, nameservers, NULL,
|
|
|
900526 |
- options, adb->task, fetch_callback,
|
|
|
900526 |
- adbname, &fetch->rdataset, NULL,
|
|
|
900526 |
- &fetch->fetch);
|
|
|
900526 |
+ result = dns_resolver_createfetch3(adb->view->resolver, &adbname->name,
|
|
|
900526 |
+ type, name, nameservers, NULL,
|
|
|
900526 |
+ NULL, 0, options, depth, qc,
|
|
|
900526 |
+ adb->task, fetch_callback, adbname,
|
|
|
900526 |
+ &fetch->rdataset, NULL,
|
|
|
900526 |
+ &fetch->fetch);
|
|
|
900526 |
if (result != ISC_R_SUCCESS)
|
|
|
900526 |
goto cleanup;
|
|
|
900526 |
|
|
|
900526 |
diff -up bind-9.9.4/lib/dns/include/dns/adb.h.CVE-2014-8500 bind-9.9.4/lib/dns/include/dns/adb.h
|
|
|
900526 |
--- bind-9.9.4/lib/dns/include/dns/adb.h.CVE-2014-8500 2013-09-05 07:09:08.000000000 +0200
|
|
|
900526 |
+++ bind-9.9.4/lib/dns/include/dns/adb.h 2014-12-10 14:56:24.965552566 +0100
|
|
|
900526 |
@@ -334,6 +334,13 @@ dns_adb_createfind(dns_adb_t *adb, isc_t
|
|
|
900526 |
dns_rdatatype_t qtype, unsigned int options,
|
|
|
900526 |
isc_stdtime_t now, dns_name_t *target,
|
|
|
900526 |
in_port_t port, dns_adbfind_t **find);
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+dns_adb_createfind2(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
|
|
|
900526 |
+ void *arg, dns_name_t *name, dns_name_t *qname,
|
|
|
900526 |
+ dns_rdatatype_t qtype, unsigned int options,
|
|
|
900526 |
+ isc_stdtime_t now, dns_name_t *target, in_port_t port,
|
|
|
900526 |
+ unsigned int depth, isc_counter_t *qc,
|
|
|
900526 |
+ dns_adbfind_t **find);
|
|
|
900526 |
/*%<
|
|
|
900526 |
* Main interface for clients. The adb will look up the name given in
|
|
|
900526 |
* "name" and will build up a list of found addresses, and perhaps start
|
|
|
900526 |
diff -up bind-9.9.4/lib/dns/include/dns/resolver.h.CVE-2014-8500 bind-9.9.4/lib/dns/include/dns/resolver.h
|
|
|
900526 |
--- bind-9.9.4/lib/dns/include/dns/resolver.h.CVE-2014-8500 2013-09-05 07:09:08.000000000 +0200
|
|
|
900526 |
+++ bind-9.9.4/lib/dns/include/dns/resolver.h 2014-12-10 14:56:24.965552566 +0100
|
|
|
900526 |
@@ -274,6 +274,18 @@ dns_resolver_createfetch2(dns_resolver_t
|
|
|
900526 |
dns_rdataset_t *rdataset,
|
|
|
900526 |
dns_rdataset_t *sigrdataset,
|
|
|
900526 |
dns_fetch_t **fetchp);
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+dns_resolver_createfetch3(dns_resolver_t *res, dns_name_t *name,
|
|
|
900526 |
+ dns_rdatatype_t type,
|
|
|
900526 |
+ dns_name_t *domain, dns_rdataset_t *nameservers,
|
|
|
900526 |
+ dns_forwarders_t *forwarders,
|
|
|
900526 |
+ isc_sockaddr_t *client, isc_uint16_t id,
|
|
|
900526 |
+ unsigned int options, unsigned int depth,
|
|
|
900526 |
+ isc_counter_t *qc, isc_task_t *task,
|
|
|
900526 |
+ isc_taskaction_t action, void *arg,
|
|
|
900526 |
+ dns_rdataset_t *rdataset,
|
|
|
900526 |
+ dns_rdataset_t *sigrdataset,
|
|
|
900526 |
+ dns_fetch_t **fetchp);
|
|
|
900526 |
/*%<
|
|
|
900526 |
* Recurse to answer a question.
|
|
|
900526 |
*
|
|
|
900526 |
@@ -573,6 +585,30 @@ dns_resolver_printbadcache(dns_resolver_
|
|
|
900526 |
*
|
|
|
900526 |
* Requires:
|
|
|
900526 |
* \li resolver to be valid.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+dns_resolver_setmaxdepth(dns_resolver_t *resolver, unsigned int maxdepth);
|
|
|
900526 |
+unsigned int
|
|
|
900526 |
+dns_resolver_getmaxdepth(dns_resolver_t *resolver);
|
|
|
900526 |
+/*%
|
|
|
900526 |
+ * Get and set how many NS indirections will be followed when looking for
|
|
|
900526 |
+ * nameserver addresses.
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * Requires:
|
|
|
900526 |
+ * \li resolver to be valid.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+dns_resolver_setmaxqueries(dns_resolver_t *resolver, unsigned int queries);
|
|
|
900526 |
+unsigned int
|
|
|
900526 |
+dns_resolver_getmaxqueries(dns_resolver_t *resolver);
|
|
|
900526 |
+/*%
|
|
|
900526 |
+ * Get and set how many iterative queries will be allowed before
|
|
|
900526 |
+ * terminating a recursive query.
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * Requires:
|
|
|
900526 |
+ * \li resolver to be valid.
|
|
|
900526 |
*/
|
|
|
900526 |
|
|
|
900526 |
ISC_LANG_ENDDECLS
|
|
|
900526 |
diff -up bind-9.9.4/lib/dns/resolver.c.CVE-2014-8500 bind-9.9.4/lib/dns/resolver.c
|
|
|
900526 |
--- bind-9.9.4/lib/dns/resolver.c.CVE-2014-8500 2014-12-10 14:56:24.952552551 +0100
|
|
|
900526 |
+++ bind-9.9.4/lib/dns/resolver.c 2014-12-10 15:01:56.855970646 +0100
|
|
|
900526 |
@@ -21,6 +21,7 @@
|
|
|
900526 |
|
|
|
900526 |
#include <config.h>
|
|
|
900526 |
|
|
|
900526 |
+#include <isc/counter.h>
|
|
|
900526 |
#include <isc/log.h>
|
|
|
900526 |
#include <isc/platform.h>
|
|
|
900526 |
#include <isc/print.h>
|
|
|
900526 |
@@ -130,6 +131,16 @@
|
|
|
900526 |
#define MAXIMUM_QUERY_TIMEOUT 30 /* The maximum time in seconds for the whole query to live. */
|
|
|
900526 |
#endif
|
|
|
900526 |
|
|
|
900526 |
+/* The default maximum number of recursions to follow before giving up. */
|
|
|
900526 |
+#ifndef DEFAULT_RECURSION_DEPTH
|
|
|
900526 |
+#define DEFAULT_RECURSION_DEPTH 7
|
|
|
900526 |
+#endif
|
|
|
900526 |
+
|
|
|
900526 |
+/* The default maximum number of iterative queries to allow before giving up. */
|
|
|
900526 |
+#ifndef DEFAULT_MAX_QUERIES
|
|
|
900526 |
+#define DEFAULT_MAX_QUERIES 50
|
|
|
900526 |
+#endif
|
|
|
900526 |
+
|
|
|
900526 |
/*%
|
|
|
900526 |
* Maximum EDNS0 input packet size.
|
|
|
900526 |
*/
|
|
|
900526 |
@@ -233,12 +244,13 @@ struct fetchctx {
|
|
|
900526 |
isc_sockaddrlist_t edns;
|
|
|
900526 |
isc_sockaddrlist_t edns512;
|
|
|
900526 |
isc_sockaddrlist_t bad_edns;
|
|
|
900526 |
- dns_validator_t *validator;
|
|
|
900526 |
+ dns_validator_t * validator;
|
|
|
900526 |
ISC_LIST(dns_validator_t) validators;
|
|
|
900526 |
dns_db_t * cache;
|
|
|
900526 |
dns_adb_t * adb;
|
|
|
900526 |
isc_boolean_t ns_ttl_ok;
|
|
|
900526 |
isc_uint32_t ns_ttl;
|
|
|
900526 |
+ isc_counter_t * qc;
|
|
|
900526 |
|
|
|
900526 |
/*%
|
|
|
900526 |
* The number of events we're waiting for.
|
|
|
900526 |
@@ -306,6 +318,7 @@ struct fetchctx {
|
|
|
900526 |
isc_boolean_t timeout;
|
|
|
900526 |
dns_adbaddrinfo_t *addrinfo;
|
|
|
900526 |
isc_sockaddr_t *client;
|
|
|
900526 |
+ unsigned int depth;
|
|
|
900526 |
};
|
|
|
900526 |
|
|
|
900526 |
#define FCTX_MAGIC ISC_MAGIC('F', '!', '!', '!')
|
|
|
900526 |
@@ -418,6 +431,8 @@ struct dns_resolver {
|
|
|
900526 |
isc_timer_t * spillattimer;
|
|
|
900526 |
isc_boolean_t zero_no_soa_ttl;
|
|
|
900526 |
unsigned int query_timeout;
|
|
|
900526 |
+ unsigned int maxdepth;
|
|
|
900526 |
+ unsigned int maxqueries;
|
|
|
900526 |
|
|
|
900526 |
/* Locked by lock. */
|
|
|
900526 |
unsigned int references;
|
|
|
900526 |
@@ -1533,6 +1548,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddr
|
|
|
900526 |
if (result != ISC_R_SUCCESS)
|
|
|
900526 |
goto cleanup_dispatch;
|
|
|
900526 |
}
|
|
|
900526 |
+
|
|
|
900526 |
fctx->querysent++;
|
|
|
900526 |
|
|
|
900526 |
ISC_LIST_APPEND(fctx->queries, query, link);
|
|
|
900526 |
@@ -2186,9 +2202,9 @@ fctx_finddone(isc_task_t *task, isc_even
|
|
|
900526 |
*/
|
|
|
900526 |
INSIST(!SHUTTINGDOWN(fctx));
|
|
|
900526 |
fctx->attributes &= ~FCTX_ATTR_ADDRWAIT;
|
|
|
900526 |
- if (event->ev_type == DNS_EVENT_ADBMOREADDRESSES)
|
|
|
900526 |
+ if (event->ev_type == DNS_EVENT_ADBMOREADDRESSES) {
|
|
|
900526 |
want_try = ISC_TRUE;
|
|
|
900526 |
- else {
|
|
|
900526 |
+ } else {
|
|
|
900526 |
fctx->findfail++;
|
|
|
900526 |
if (fctx->pending == 0) {
|
|
|
900526 |
/*
|
|
|
900526 |
@@ -2471,12 +2487,13 @@ findname(fetchctx_t *fctx, dns_name_t *n
|
|
|
900526 |
* See what we know about this address.
|
|
|
900526 |
*/
|
|
|
900526 |
find = NULL;
|
|
|
900526 |
- result = dns_adb_createfind(fctx->adb,
|
|
|
900526 |
- res->buckets[fctx->bucketnum].task,
|
|
|
900526 |
- fctx_finddone, fctx, name,
|
|
|
900526 |
- &fctx->name, fctx->type,
|
|
|
900526 |
- options, now, NULL,
|
|
|
900526 |
- res->view->dstport, &find);
|
|
|
900526 |
+ result = dns_adb_createfind2(fctx->adb,
|
|
|
900526 |
+ res->buckets[fctx->bucketnum].task,
|
|
|
900526 |
+ fctx_finddone, fctx, name,
|
|
|
900526 |
+ &fctx->name, fctx->type,
|
|
|
900526 |
+ options, now, NULL,
|
|
|
900526 |
+ res->view->dstport,
|
|
|
900526 |
+ fctx->depth + 1, fctx->qc, &find);
|
|
|
900526 |
if (result != ISC_R_SUCCESS) {
|
|
|
900526 |
if (result == DNS_R_ALIAS) {
|
|
|
900526 |
/*
|
|
|
900526 |
@@ -2584,6 +2601,14 @@ fctx_getaddresses(fetchctx_t *fctx, isc_
|
|
|
900526 |
|
|
|
900526 |
res = fctx->res;
|
|
|
900526 |
|
|
|
900526 |
+ if (fctx->depth > res->maxdepth) {
|
|
|
900526 |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
|
|
|
900526 |
+ DNS_LOGMODULE_RESOLVER, ISC_LOG_DEBUG(3),
|
|
|
900526 |
+ "too much NS indirection resolving '%s'",
|
|
|
900526 |
+ fctx->info);
|
|
|
900526 |
+ return (DNS_R_SERVFAIL);
|
|
|
900526 |
+ }
|
|
|
900526 |
+
|
|
|
900526 |
/*
|
|
|
900526 |
* Forwarders.
|
|
|
900526 |
*/
|
|
|
900526 |
@@ -3059,6 +3084,16 @@ fctx_try(fetchctx_t *fctx, isc_boolean_t
|
|
|
900526 |
}
|
|
|
900526 |
}
|
|
|
900526 |
|
|
|
900526 |
+ result = isc_counter_increment(fctx->qc);
|
|
|
900526 |
+ if (result != ISC_R_SUCCESS) {
|
|
|
900526 |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
|
|
|
900526 |
+ DNS_LOGMODULE_RESOLVER, ISC_LOG_DEBUG(3),
|
|
|
900526 |
+ "exceeded max queries resolving '%s'",
|
|
|
900526 |
+ fctx->info);
|
|
|
900526 |
+ fctx_done(fctx, DNS_R_SERVFAIL, __LINE__);
|
|
|
900526 |
+ return;
|
|
|
900526 |
+ }
|
|
|
900526 |
+
|
|
|
900526 |
result = fctx_query(fctx, addrinfo, fctx->options);
|
|
|
900526 |
if (result != ISC_R_SUCCESS)
|
|
|
900526 |
fctx_done(fctx, result, __LINE__);
|
|
|
900526 |
@@ -3157,6 +3192,7 @@ fctx_destroy(fetchctx_t *fctx) {
|
|
|
900526 |
isc_mem_put(fctx->mctx, sa, sizeof(*sa));
|
|
|
900526 |
}
|
|
|
900526 |
|
|
|
900526 |
+ isc_counter_detach(&fctx->qc);
|
|
|
900526 |
isc_timer_detach(&fctx->timer);
|
|
|
900526 |
dns_message_destroy(&fctx->rmessage);
|
|
|
900526 |
dns_message_destroy(&fctx->qmessage);
|
|
|
900526 |
@@ -3485,7 +3521,8 @@ log_ns_ttl(fetchctx_t *fctx, const char
|
|
|
900526 |
static isc_result_t
|
|
|
900526 |
fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type,
|
|
|
900526 |
dns_name_t *domain, dns_rdataset_t *nameservers,
|
|
|
900526 |
- unsigned int options, unsigned int bucketnum, fetchctx_t **fctxp)
|
|
|
900526 |
+ unsigned int options, unsigned int bucketnum, unsigned int depth,
|
|
|
900526 |
+ isc_counter_t *qc, fetchctx_t **fctxp)
|
|
|
900526 |
{
|
|
|
900526 |
fetchctx_t *fctx;
|
|
|
900526 |
isc_result_t result;
|
|
|
900526 |
@@ -3507,6 +3544,21 @@ fctx_create(dns_resolver_t *res, dns_nam
|
|
|
900526 |
fctx = isc_mem_get(mctx, sizeof(*fctx));
|
|
|
900526 |
if (fctx == NULL)
|
|
|
900526 |
return (ISC_R_NOMEMORY);
|
|
|
900526 |
+
|
|
|
900526 |
+ fctx->qc = NULL;
|
|
|
900526 |
+ if (qc != NULL) {
|
|
|
900526 |
+ isc_counter_attach(qc, &fctx->qc);
|
|
|
900526 |
+ } else {
|
|
|
900526 |
+ result = isc_counter_create(res->mctx,
|
|
|
900526 |
+ res->maxqueries, &fctx->qc);
|
|
|
900526 |
+ if (result != ISC_R_SUCCESS)
|
|
|
900526 |
+ goto cleanup_fetch;
|
|
|
900526 |
+ }
|
|
|
900526 |
+
|
|
|
900526 |
+ /*
|
|
|
900526 |
+ * Make fctx->info point to a copy of a formatted string
|
|
|
900526 |
+ * "name/type".
|
|
|
900526 |
+ */
|
|
|
900526 |
dns_name_format(name, buf, sizeof(buf));
|
|
|
900526 |
dns_rdatatype_format(type, typebuf, sizeof(typebuf));
|
|
|
900526 |
strcat(buf, "/"); /* checked */
|
|
|
900526 |
@@ -3514,7 +3566,7 @@ fctx_create(dns_resolver_t *res, dns_nam
|
|
|
900526 |
fctx->info = isc_mem_strdup(mctx, buf);
|
|
|
900526 |
if (fctx->info == NULL) {
|
|
|
900526 |
result = ISC_R_NOMEMORY;
|
|
|
900526 |
- goto cleanup_fetch;
|
|
|
900526 |
+ goto cleanup_counter;
|
|
|
900526 |
}
|
|
|
900526 |
FCTXTRACE("create");
|
|
|
900526 |
dns_name_init(&fctx->name, NULL);
|
|
|
900526 |
@@ -3537,6 +3589,7 @@ fctx_create(dns_resolver_t *res, dns_nam
|
|
|
900526 |
fctx->state = fetchstate_init;
|
|
|
900526 |
fctx->want_shutdown = ISC_FALSE;
|
|
|
900526 |
fctx->cloned = ISC_FALSE;
|
|
|
900526 |
+ fctx->depth = depth;
|
|
|
900526 |
ISC_LIST_INIT(fctx->queries);
|
|
|
900526 |
ISC_LIST_INIT(fctx->finds);
|
|
|
900526 |
ISC_LIST_INIT(fctx->altfinds);
|
|
|
900526 |
@@ -3742,6 +3795,9 @@ fctx_create(dns_resolver_t *res, dns_nam
|
|
|
900526 |
cleanup_info:
|
|
|
900526 |
isc_mem_free(mctx, fctx->info);
|
|
|
900526 |
|
|
|
900526 |
+ cleanup_counter:
|
|
|
900526 |
+ isc_counter_detach(&fctx->qc);
|
|
|
900526 |
+
|
|
|
900526 |
cleanup_fetch:
|
|
|
900526 |
isc_mem_put(mctx, fctx, sizeof(*fctx));
|
|
|
900526 |
|
|
|
900526 |
@@ -5655,7 +5711,7 @@ noanswer_response(fetchctx_t *fctx, dns_
|
|
|
900526 |
char qbuf[DNS_NAME_FORMATSIZE];
|
|
|
900526 |
char nbuf[DNS_NAME_FORMATSIZE];
|
|
|
900526 |
char tbuf[DNS_RDATATYPE_FORMATSIZE];
|
|
|
900526 |
- dns_rdatatype_format(fctx->type, tbuf,
|
|
|
900526 |
+ dns_rdatatype_format(type, tbuf,
|
|
|
900526 |
sizeof(tbuf));
|
|
|
900526 |
dns_name_format(name, nbuf,
|
|
|
900526 |
sizeof(nbuf));
|
|
|
900526 |
@@ -5664,7 +5720,7 @@ noanswer_response(fetchctx_t *fctx, dns_
|
|
|
900526 |
log_formerr(fctx,
|
|
|
900526 |
"unrelated %s %s in "
|
|
|
900526 |
"%s authority section",
|
|
|
900526 |
- tbuf, qbuf, nbuf);
|
|
|
900526 |
+ tbuf, nbuf, qbuf);
|
|
|
900526 |
return (DNS_R_FORMERR);
|
|
|
900526 |
}
|
|
|
900526 |
if (type == dns_rdatatype_ns) {
|
|
|
900526 |
@@ -7725,6 +7781,8 @@ dns_resolver_create(dns_view_t *view,
|
|
|
900526 |
res->spillattimer = NULL;
|
|
|
900526 |
res->zero_no_soa_ttl = ISC_FALSE;
|
|
|
900526 |
res->query_timeout = DEFAULT_QUERY_TIMEOUT;
|
|
|
900526 |
+ res->maxdepth = DEFAULT_RECURSION_DEPTH;
|
|
|
900526 |
+ res->maxqueries = DEFAULT_MAX_QUERIES;
|
|
|
900526 |
res->nbuckets = ntasks;
|
|
|
900526 |
res->activebuckets = ntasks;
|
|
|
900526 |
res->buckets = isc_mem_get(view->mctx,
|
|
|
900526 |
@@ -8163,9 +8221,9 @@ dns_resolver_createfetch(dns_resolver_t
|
|
|
900526 |
dns_rdataset_t *sigrdataset,
|
|
|
900526 |
dns_fetch_t **fetchp)
|
|
|
900526 |
{
|
|
|
900526 |
- return (dns_resolver_createfetch2(res, name, type, domain,
|
|
|
900526 |
+ return (dns_resolver_createfetch3(res, name, type, domain,
|
|
|
900526 |
nameservers, forwarders, NULL, 0,
|
|
|
900526 |
- options, task, action, arg,
|
|
|
900526 |
+ options, 0, NULL, task, action, arg,
|
|
|
900526 |
rdataset, sigrdataset, fetchp));
|
|
|
900526 |
}
|
|
|
900526 |
|
|
|
900526 |
@@ -8181,6 +8239,25 @@ dns_resolver_createfetch2(dns_resolver_t
|
|
|
900526 |
dns_rdataset_t *sigrdataset,
|
|
|
900526 |
dns_fetch_t **fetchp)
|
|
|
900526 |
{
|
|
|
900526 |
+ return (dns_resolver_createfetch3(res, name, type, domain,
|
|
|
900526 |
+ nameservers, forwarders, client, id,
|
|
|
900526 |
+ options, 0, NULL, task, action, arg,
|
|
|
900526 |
+ rdataset, sigrdataset, fetchp));
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+dns_resolver_createfetch3(dns_resolver_t *res, dns_name_t *name,
|
|
|
900526 |
+ dns_rdatatype_t type,
|
|
|
900526 |
+ dns_name_t *domain, dns_rdataset_t *nameservers,
|
|
|
900526 |
+ dns_forwarders_t *forwarders,
|
|
|
900526 |
+ isc_sockaddr_t *client, dns_messageid_t id,
|
|
|
900526 |
+ unsigned int options, unsigned int depth,
|
|
|
900526 |
+ isc_counter_t *qc, isc_task_t *task,
|
|
|
900526 |
+ isc_taskaction_t action, void *arg,
|
|
|
900526 |
+ dns_rdataset_t *rdataset,
|
|
|
900526 |
+ dns_rdataset_t *sigrdataset,
|
|
|
900526 |
+ dns_fetch_t **fetchp)
|
|
|
900526 |
+{
|
|
|
900526 |
dns_fetch_t *fetch;
|
|
|
900526 |
fetchctx_t *fctx = NULL;
|
|
|
900526 |
isc_result_t result = ISC_R_SUCCESS;
|
|
|
900526 |
@@ -8269,11 +8346,12 @@ dns_resolver_createfetch2(dns_resolver_t
|
|
|
900526 |
|
|
|
900526 |
if (fctx == NULL) {
|
|
|
900526 |
result = fctx_create(res, name, type, domain, nameservers,
|
|
|
900526 |
- options, bucketnum, &fctx);
|
|
|
900526 |
+ options, bucketnum, depth, qc, &fctx);
|
|
|
900526 |
if (result != ISC_R_SUCCESS)
|
|
|
900526 |
goto unlock;
|
|
|
900526 |
new_fctx = ISC_TRUE;
|
|
|
900526 |
- }
|
|
|
900526 |
+ } else if (fctx->depth > depth)
|
|
|
900526 |
+ fctx->depth = depth;
|
|
|
900526 |
|
|
|
900526 |
result = fctx_join(fctx, task, client, id, action, arg,
|
|
|
900526 |
rdataset, sigrdataset, fetch);
|
|
|
900526 |
@@ -9045,3 +9123,27 @@ dns_resolver_settimeout(dns_resolver_t *
|
|
|
900526 |
|
|
|
900526 |
resolver->query_timeout = seconds;
|
|
|
900526 |
}
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+dns_resolver_setmaxdepth(dns_resolver_t *resolver, unsigned int maxdepth) {
|
|
|
900526 |
+ REQUIRE(VALID_RESOLVER(resolver));
|
|
|
900526 |
+ resolver->maxdepth = maxdepth;
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+unsigned int
|
|
|
900526 |
+dns_resolver_getmaxdepth(dns_resolver_t *resolver) {
|
|
|
900526 |
+ REQUIRE(VALID_RESOLVER(resolver));
|
|
|
900526 |
+ return (resolver->maxdepth);
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+dns_resolver_setmaxqueries(dns_resolver_t *resolver, unsigned int queries) {
|
|
|
900526 |
+ REQUIRE(VALID_RESOLVER(resolver));
|
|
|
900526 |
+ resolver->maxqueries = queries;
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+unsigned int
|
|
|
900526 |
+dns_resolver_getmaxqueries(dns_resolver_t *resolver) {
|
|
|
900526 |
+ REQUIRE(VALID_RESOLVER(resolver));
|
|
|
900526 |
+ return (resolver->maxqueries);
|
|
|
900526 |
+}
|
|
|
900526 |
diff -up bind-9.9.4/lib/export/isc/Makefile.in.CVE-2014-8500 bind-9.9.4/lib/export/isc/Makefile.in
|
|
|
900526 |
--- bind-9.9.4/lib/export/isc/Makefile.in.CVE-2014-8500 2014-12-10 14:56:24.907552500 +0100
|
|
|
900526 |
+++ bind-9.9.4/lib/export/isc/Makefile.in 2014-12-10 14:56:24.967552568 +0100
|
|
|
900526 |
@@ -63,7 +63,7 @@ WIN32OBJS = win32/condition.@O@ win32/d
|
|
|
900526 |
# Alphabetically
|
|
|
900526 |
OBJS = @ISC_EXTRA_OBJS@ \
|
|
|
900526 |
assertions.@O@ backtrace.@O@ backtrace-emptytbl.@O@ base32.@O@ \
|
|
|
900526 |
- base64.@O@ buffer.@O@ bufferlist.@O@ \
|
|
|
900526 |
+ base64.@O@ buffer.@O@ bufferlist.@O@ counter.@O@ \
|
|
|
900526 |
error.@O@ event.@O@ \
|
|
|
900526 |
hash.@O@ hex.@O@ hmacmd5.@O@ hmacsha.@O@ \
|
|
|
900526 |
inet_aton.@O@ iterated_hash.@O@ lex.@O@ lfsr.@O@ log.@O@ \
|
|
|
900526 |
@@ -85,7 +85,7 @@ ISCDRIVERSRCS = mem.c task.c lib.c timer
|
|
|
900526 |
|
|
|
900526 |
SRCS = @ISC_EXTRA_SRCS@ \
|
|
|
900526 |
assertions.c backtrace.c backtrace-emptytbl.c base32.c \
|
|
|
900526 |
- base64.c buffer.c bufferlist.c \
|
|
|
900526 |
+ base64.c buffer.c bufferlist.c counter.c \
|
|
|
900526 |
error.c event.c \
|
|
|
900526 |
hash.c hex.c hmacmd5.c hmacsha.c \
|
|
|
900526 |
inet_aton.c iterated_hash.c lex.c log.c lfsr.c \
|
|
|
900526 |
diff -up bind-9.9.4/lib/isccfg/namedconf.c.CVE-2014-8500 bind-9.9.4/lib/isccfg/namedconf.c
|
|
|
900526 |
--- bind-9.9.4/lib/isccfg/namedconf.c.CVE-2014-8500 2014-12-10 14:56:24.969552570 +0100
|
|
|
900526 |
+++ bind-9.9.4/lib/isccfg/namedconf.c 2014-12-10 15:04:14.636091707 +0100
|
|
|
900526 |
@@ -1421,6 +1421,8 @@ view_clauses[] = {
|
|
|
900526 |
{ "max-cache-ttl", &cfg_type_uint32, 0 },
|
|
|
900526 |
{ "max-clients-per-query", &cfg_type_uint32, 0 },
|
|
|
900526 |
{ "max-ncache-ttl", &cfg_type_uint32, 0 },
|
|
|
900526 |
+ { "max-recursion-depth", &cfg_type_uint32, 0 },
|
|
|
900526 |
+ { "max-recursion-queries", &cfg_type_uint32, 0 },
|
|
|
900526 |
{ "max-udp-size", &cfg_type_uint32, 0 },
|
|
|
900526 |
{ "min-roots", &cfg_type_uint32, CFG_CLAUSEFLAG_NOTIMP },
|
|
|
900526 |
{ "minimal-responses", &cfg_type_boolean, 0 },
|
|
|
900526 |
diff -up bind-9.9.4/lib/isc/counter.c.CVE-2014-8500 bind-9.9.4/lib/isc/counter.c
|
|
|
900526 |
--- bind-9.9.4/lib/isc/counter.c.CVE-2014-8500 2014-12-10 14:56:24.968552569 +0100
|
|
|
900526 |
+++ bind-9.9.4/lib/isc/counter.c 2014-12-10 14:56:24.968552569 +0100
|
|
|
900526 |
@@ -0,0 +1,138 @@
|
|
|
900526 |
+/*
|
|
|
900526 |
+ * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * Permission to use, copy, modify, and/or distribute this software for any
|
|
|
900526 |
+ * purpose with or without fee is hereby granted, provided that the above
|
|
|
900526 |
+ * copyright notice and this permission notice appear in all copies.
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
|
|
900526 |
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
900526 |
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
900526 |
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
900526 |
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
900526 |
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
900526 |
+ * PERFORMANCE OF THIS SOFTWARE.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+/*! \file */
|
|
|
900526 |
+
|
|
|
900526 |
+#include <config.h>
|
|
|
900526 |
+
|
|
|
900526 |
+#include <stddef.h>
|
|
|
900526 |
+
|
|
|
900526 |
+#include <isc/counter.h>
|
|
|
900526 |
+#include <isc/magic.h>
|
|
|
900526 |
+#include <isc/mem.h>
|
|
|
900526 |
+#include <isc/util.h>
|
|
|
900526 |
+
|
|
|
900526 |
+#define COUNTER_MAGIC ISC_MAGIC('C', 'n', 't', 'r')
|
|
|
900526 |
+#define VALID_COUNTER(r) ISC_MAGIC_VALID(r, COUNTER_MAGIC)
|
|
|
900526 |
+
|
|
|
900526 |
+struct isc_counter {
|
|
|
900526 |
+ unsigned int magic;
|
|
|
900526 |
+ isc_mem_t *mctx;
|
|
|
900526 |
+ isc_mutex_t lock;
|
|
|
900526 |
+ unsigned int references;
|
|
|
900526 |
+ unsigned int limit;
|
|
|
900526 |
+ unsigned int used;
|
|
|
900526 |
+};
|
|
|
900526 |
+
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+isc_counter_create(isc_mem_t *mctx, int limit, isc_counter_t **counterp) {
|
|
|
900526 |
+ isc_result_t result;
|
|
|
900526 |
+ isc_counter_t *counter;
|
|
|
900526 |
+
|
|
|
900526 |
+ REQUIRE(counterp != NULL && *counterp == NULL);
|
|
|
900526 |
+
|
|
|
900526 |
+ counter = isc_mem_get(mctx, sizeof(*counter));
|
|
|
900526 |
+ if (counter == NULL)
|
|
|
900526 |
+ return (ISC_R_NOMEMORY);
|
|
|
900526 |
+
|
|
|
900526 |
+ result = isc_mutex_init(&counter->lock);
|
|
|
900526 |
+ if (result != ISC_R_SUCCESS) {
|
|
|
900526 |
+ isc_mem_put(mctx, counter, sizeof(*counter));
|
|
|
900526 |
+ return (result);
|
|
|
900526 |
+ }
|
|
|
900526 |
+
|
|
|
900526 |
+ counter->mctx = NULL;
|
|
|
900526 |
+ isc_mem_attach(mctx, &counter->mctx);
|
|
|
900526 |
+
|
|
|
900526 |
+ counter->references = 1;
|
|
|
900526 |
+ counter->limit = limit;
|
|
|
900526 |
+ counter->used = 0;
|
|
|
900526 |
+
|
|
|
900526 |
+ counter->magic = COUNTER_MAGIC;
|
|
|
900526 |
+ *counterp = counter;
|
|
|
900526 |
+ return (ISC_R_SUCCESS);
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+isc_counter_increment(isc_counter_t *counter) {
|
|
|
900526 |
+ isc_result_t result = ISC_R_SUCCESS;
|
|
|
900526 |
+
|
|
|
900526 |
+ LOCK(&counter->lock);
|
|
|
900526 |
+ counter->used++;
|
|
|
900526 |
+ if (counter->limit != 0 && counter->used >= counter->limit)
|
|
|
900526 |
+ result = ISC_R_QUOTA;
|
|
|
900526 |
+ UNLOCK(&counter->lock);
|
|
|
900526 |
+
|
|
|
900526 |
+ return (result);
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+unsigned int
|
|
|
900526 |
+isc_counter_used(isc_counter_t *counter) {
|
|
|
900526 |
+ REQUIRE(VALID_COUNTER(counter));
|
|
|
900526 |
+
|
|
|
900526 |
+ return (counter->used);
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+isc_counter_setlimit(isc_counter_t *counter, int limit) {
|
|
|
900526 |
+ REQUIRE(VALID_COUNTER(counter));
|
|
|
900526 |
+
|
|
|
900526 |
+ LOCK(&counter->lock);
|
|
|
900526 |
+ counter->limit = limit;
|
|
|
900526 |
+ UNLOCK(&counter->lock);
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+isc_counter_attach(isc_counter_t *source, isc_counter_t **targetp) {
|
|
|
900526 |
+ REQUIRE(VALID_COUNTER(source));
|
|
|
900526 |
+ REQUIRE(targetp != NULL && *targetp == NULL);
|
|
|
900526 |
+
|
|
|
900526 |
+ LOCK(&source->lock);
|
|
|
900526 |
+ source->references++;
|
|
|
900526 |
+ INSIST(source->references > 0);
|
|
|
900526 |
+ UNLOCK(&source->lock);
|
|
|
900526 |
+
|
|
|
900526 |
+ *targetp = source;
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+static void
|
|
|
900526 |
+destroy(isc_counter_t *counter) {
|
|
|
900526 |
+ counter->magic = 0;
|
|
|
900526 |
+ isc_mutex_destroy(&counter->lock);
|
|
|
900526 |
+ isc_mem_putanddetach(&counter->mctx, counter, sizeof(*counter));
|
|
|
900526 |
+}
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+isc_counter_detach(isc_counter_t **counterp) {
|
|
|
900526 |
+ isc_counter_t *counter;
|
|
|
900526 |
+ isc_boolean_t want_destroy = ISC_FALSE;
|
|
|
900526 |
+
|
|
|
900526 |
+ REQUIRE(counterp != NULL && *counterp != NULL);
|
|
|
900526 |
+ counter = *counterp;
|
|
|
900526 |
+ REQUIRE(VALID_COUNTER(counter));
|
|
|
900526 |
+
|
|
|
900526 |
+ *counterp = NULL;
|
|
|
900526 |
+
|
|
|
900526 |
+ LOCK(&counter->lock);
|
|
|
900526 |
+ INSIST(counter->references > 0);
|
|
|
900526 |
+ counter->references--;
|
|
|
900526 |
+ if (counter->references == 0)
|
|
|
900526 |
+ want_destroy = ISC_TRUE;
|
|
|
900526 |
+ UNLOCK(&counter->lock);
|
|
|
900526 |
+
|
|
|
900526 |
+ if (want_destroy)
|
|
|
900526 |
+ destroy(counter);
|
|
|
900526 |
+}
|
|
|
900526 |
diff -up bind-9.9.4/lib/isc/include/isc/counter.h.CVE-2014-8500 bind-9.9.4/lib/isc/include/isc/counter.h
|
|
|
900526 |
--- bind-9.9.4/lib/isc/include/isc/counter.h.CVE-2014-8500 2014-12-10 14:56:24.968552569 +0100
|
|
|
900526 |
+++ bind-9.9.4/lib/isc/include/isc/counter.h 2014-12-10 14:56:24.968552569 +0100
|
|
|
900526 |
@@ -0,0 +1,90 @@
|
|
|
900526 |
+/*
|
|
|
900526 |
+ * Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * Permission to use, copy, modify, and/or distribute this software for any
|
|
|
900526 |
+ * purpose with or without fee is hereby granted, provided that the above
|
|
|
900526 |
+ * copyright notice and this permission notice appear in all copies.
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
|
|
900526 |
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
|
900526 |
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
|
900526 |
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
900526 |
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
900526 |
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
900526 |
+ * PERFORMANCE OF THIS SOFTWARE.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+#ifndef ISC_COUNTER_H
|
|
|
900526 |
+#define ISC_COUNTER_H 1
|
|
|
900526 |
+
|
|
|
900526 |
+/*****
|
|
|
900526 |
+ ***** Module Info
|
|
|
900526 |
+ *****/
|
|
|
900526 |
+
|
|
|
900526 |
+/*! \file isc/counter.h
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * \brief The isc_counter_t object is a simplified version of the
|
|
|
900526 |
+ * isc_quota_t object; it tracks the consumption of limited
|
|
|
900526 |
+ * resources, returning an error condition when the quota is
|
|
|
900526 |
+ * exceeded. However, unlike isc_quota_t, attaching and detaching
|
|
|
900526 |
+ * from a counter object does not increment or decrement the counter.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+/***
|
|
|
900526 |
+ *** Imports.
|
|
|
900526 |
+ ***/
|
|
|
900526 |
+
|
|
|
900526 |
+#include <isc/lang.h>
|
|
|
900526 |
+#include <isc/mutex.h>
|
|
|
900526 |
+#include <isc/types.h>
|
|
|
900526 |
+
|
|
|
900526 |
+/*****
|
|
|
900526 |
+ ***** Types.
|
|
|
900526 |
+ *****/
|
|
|
900526 |
+
|
|
|
900526 |
+ISC_LANG_BEGINDECLS
|
|
|
900526 |
+
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+isc_counter_create(isc_mem_t *mctx, int limit, isc_counter_t **counterp);
|
|
|
900526 |
+/*%<
|
|
|
900526 |
+ * Allocate and initialize a counter object.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+isc_result_t
|
|
|
900526 |
+isc_counter_increment(isc_counter_t *counter);
|
|
|
900526 |
+/*%<
|
|
|
900526 |
+ * Increment the counter.
|
|
|
900526 |
+ *
|
|
|
900526 |
+ * If the counter limit is nonzero and has been reached, then
|
|
|
900526 |
+ * return ISC_R_QUOTA, otherwise ISC_R_SUCCESS. (The counter is
|
|
|
900526 |
+ * incremented regardless of return value.)
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+unsigned int
|
|
|
900526 |
+isc_counter_used(isc_counter_t *counter);
|
|
|
900526 |
+/*%<
|
|
|
900526 |
+ * Return the current counter value.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+isc_counter_setlimit(isc_counter_t *counter, int limit);
|
|
|
900526 |
+/*%<
|
|
|
900526 |
+ * Set the counter limit.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+isc_counter_attach(isc_counter_t *source, isc_counter_t **targetp);
|
|
|
900526 |
+/*%<
|
|
|
900526 |
+ * Attach to a counter object, increasing its reference counter.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+void
|
|
|
900526 |
+isc_counter_detach(isc_counter_t **counterp);
|
|
|
900526 |
+/*%<
|
|
|
900526 |
+ * Detach (and destroy if reference counter has dropped to zero)
|
|
|
900526 |
+ * a counter object.
|
|
|
900526 |
+ */
|
|
|
900526 |
+
|
|
|
900526 |
+ISC_LANG_ENDDECLS
|
|
|
900526 |
+
|
|
|
900526 |
+#endif /* ISC_COUNTER_H */
|
|
|
900526 |
diff -up bind-9.9.4/lib/isc/include/isc/Makefile.in.CVE-2014-8500 bind-9.9.4/lib/isc/include/isc/Makefile.in
|
|
|
900526 |
--- bind-9.9.4/lib/isc/include/isc/Makefile.in.CVE-2014-8500 2014-12-10 15:02:34.811005903 +0100
|
|
|
900526 |
+++ bind-9.9.4/lib/isc/include/isc/Makefile.in 2014-12-10 15:03:01.099030322 +0100
|
|
|
900526 |
@@ -27,7 +27,7 @@ top_srcdir = @top_srcdir@
|
|
|
900526 |
# install target below.
|
|
|
900526 |
#
|
|
|
900526 |
HEADERS = app.h assertions.h base64.h bind9.h bitstring.h boolean.h \
|
|
|
900526 |
- buffer.h bufferlist.h commandline.h entropy.h error.h event.h \
|
|
|
900526 |
+ buffer.h bufferlist.h commandline.h counter.h entropy.h error.h event.h \
|
|
|
900526 |
eventclass.h file.h formatcheck.h fsaccess.h \
|
|
|
900526 |
hash.h heap.h hex.h hmacmd5.h hmacsha.h \
|
|
|
900526 |
httpd.h \
|
|
|
900526 |
diff -up bind-9.9.4/lib/isc/include/isc/types.h.CVE-2014-8500 bind-9.9.4/lib/isc/include/isc/types.h
|
|
|
900526 |
--- bind-9.9.4/lib/isc/include/isc/types.h.CVE-2014-8500 2013-09-05 07:09:08.000000000 +0200
|
|
|
900526 |
+++ bind-9.9.4/lib/isc/include/isc/types.h 2014-12-10 14:56:24.968552569 +0100
|
|
|
900526 |
@@ -50,6 +50,7 @@ typedef struct isc_buffer isc_buffer_t;
|
|
|
900526 |
typedef ISC_LIST(isc_buffer_t) isc_bufferlist_t; /*%< Buffer List */
|
|
|
900526 |
typedef struct isc_constregion isc_constregion_t; /*%< Const region */
|
|
|
900526 |
typedef struct isc_consttextregion isc_consttextregion_t; /*%< Const Text Region */
|
|
|
900526 |
+typedef struct isc_counter isc_counter_t; /*%< Counter */
|
|
|
900526 |
typedef struct isc_entropy isc_entropy_t; /*%< Entropy */
|
|
|
900526 |
typedef struct isc_entropysource isc_entropysource_t; /*%< Entropy Source */
|
|
|
900526 |
typedef struct isc_event isc_event_t; /*%< Event */
|
|
|
900526 |
diff -up bind-9.9.4/lib/isc/Makefile.in.CVE-2014-8500 bind-9.9.4/lib/isc/Makefile.in
|
|
|
900526 |
--- bind-9.9.4/lib/isc/Makefile.in.CVE-2014-8500 2014-12-10 14:56:24.860552447 +0100
|
|
|
900526 |
+++ bind-9.9.4/lib/isc/Makefile.in 2014-12-10 14:56:24.968552569 +0100
|
|
|
900526 |
@@ -53,7 +53,7 @@ WIN32OBJS = win32/condition.@O@ win32/d
|
|
|
900526 |
OBJS = @ISC_EXTRA_OBJS@ \
|
|
|
900526 |
assertions.@O@ backtrace.@O@ base32.@O@ base64.@O@ \
|
|
|
900526 |
bitstring.@O@ buffer.@O@ bufferlist.@O@ commandline.@O@ \
|
|
|
900526 |
- error.@O@ event.@O@ \
|
|
|
900526 |
+ counter.@O@ error.@O@ event.@O@ \
|
|
|
900526 |
hash.@O@ heap.@O@ hex.@O@ hmacmd5.@O@ hmacsha.@O@ \
|
|
|
900526 |
httpd.@O@ inet_aton.@O@ iterated_hash.@O@ \
|
|
|
900526 |
lex.@O@ lfsr.@O@ lib.@O@ log.@O@ \
|
|
|
900526 |
@@ -70,8 +70,8 @@ SYMTBLOBJS = backtrace-emptytbl.@O@
|
|
|
900526 |
# Alphabetically
|
|
|
900526 |
SRCS = @ISC_EXTRA_SRCS@ \
|
|
|
900526 |
assertions.c backtrace.c base32.c base64.c bitstring.c \
|
|
|
900526 |
- buffer.c bufferlist.c commandline.c error.c event.c \
|
|
|
900526 |
- heap.c hex.c hmacmd5.c hmacsha.c \
|
|
|
900526 |
+ buffer.c bufferlist.c commandline.c counter.c \
|
|
|
900526 |
+ error.c event.c heap.c hex.c hmacmd5.c hmacsha.c \
|
|
|
900526 |
httpd.c inet_aton.c iterated_hash.c \
|
|
|
900526 |
lex.c lfsr.c lib.c log.c \
|
|
|
900526 |
md5.c mem.c mutexblock.c \
|