summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/bind/bind/CVE-2016-1286_2.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/bind/bind/CVE-2016-1286_2.patch')
-rw-r--r--meta/recipes-connectivity/bind/bind/CVE-2016-1286_2.patch318
1 files changed, 318 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/bind/bind/CVE-2016-1286_2.patch b/meta/recipes-connectivity/bind/bind/CVE-2016-1286_2.patch
new file mode 100644
index 0000000..eba4ea3
--- /dev/null
+++ b/meta/recipes-connectivity/bind/bind/CVE-2016-1286_2.patch
@@ -0,0 +1,318 @@
1From ce3cd91caee698cb144e1350c6c78292c6be6339 Mon Sep 17 00:00:00 2001
2From: Mark Andrews <marka@isc.org>
3Date: Mon, 29 Feb 2016 07:16:48 +1100
4Subject: [PATCH] Part 2 of: 4319. [security] Fix resolver assertion
5 failure due to improper DNAME handling when parsing
6 fetch reply messages. (CVE-2016-1286) [RT #41753]
7
8(cherry picked from commit 2de89ee9de8c8da9dc153a754b02dcdbb7fe2374)
9
10CVE: CVE-2016-1286
11Upstream-Status: Backport
12
13Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
14---
15 lib/dns/resolver.c | 192 ++++++++++++++++++++++++++---------------------------
16 1 file changed, 93 insertions(+), 99 deletions(-)
17
18diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c
19index 0602070..273e06c 100644
20--- a/lib/dns/resolver.c
21+++ b/lib/dns/resolver.c
22@@ -5808,14 +5808,11 @@ cname_target(dns_rdataset_t *rdataset, dns_name_t *tname) {
23 }
24
25 static inline isc_result_t
26-dname_target(fetchctx_t *fctx, dns_rdataset_t *rdataset, dns_name_t *qname,
27- dns_name_t *oname, dns_fixedname_t *fixeddname)
28+dname_target(dns_rdataset_t *rdataset, dns_name_t *qname,
29+ unsigned int nlabels, dns_fixedname_t *fixeddname)
30 {
31 isc_result_t result;
32 dns_rdata_t rdata = DNS_RDATA_INIT;
33- unsigned int nlabels;
34- int order;
35- dns_namereln_t namereln;
36 dns_rdata_dname_t dname;
37 dns_fixedname_t prefix;
38
39@@ -5830,21 +5827,6 @@ dname_target(fetchctx_t *fctx, dns_rdataset_t *rdataset, dns_name_t *qname,
40 if (result != ISC_R_SUCCESS)
41 return (result);
42
43- /*
44- * Get the prefix of qname.
45- */
46- namereln = dns_name_fullcompare(qname, oname, &order, &nlabels);
47- if (namereln != dns_namereln_subdomain) {
48- char qbuf[DNS_NAME_FORMATSIZE];
49- char obuf[DNS_NAME_FORMATSIZE];
50-
51- dns_rdata_freestruct(&dname);
52- dns_name_format(qname, qbuf, sizeof(qbuf));
53- dns_name_format(oname, obuf, sizeof(obuf));
54- log_formerr(fctx, "unrelated DNAME in answer: "
55- "%s is not in %s", qbuf, obuf);
56- return (DNS_R_FORMERR);
57- }
58 dns_fixedname_init(&prefix);
59 dns_name_split(qname, nlabels, dns_fixedname_name(&prefix), NULL);
60 dns_fixedname_init(fixeddname);
61@@ -6470,13 +6452,13 @@ static isc_result_t
62 answer_response(fetchctx_t *fctx) {
63 isc_result_t result;
64 dns_message_t *message;
65- dns_name_t *name, *qname, tname, *ns_name;
66+ dns_name_t *name, *dname, *qname, tname, *ns_name;
67 dns_rdataset_t *rdataset, *ns_rdataset;
68 isc_boolean_t done, external, chaining, aa, found, want_chaining;
69 isc_boolean_t have_answer, found_cname, found_type, wanted_chaining;
70 unsigned int aflag;
71 dns_rdatatype_t type;
72- dns_fixedname_t dname, fqname;
73+ dns_fixedname_t fdname, fqname;
74 dns_view_t *view;
75
76 FCTXTRACE("answer_response");
77@@ -6504,10 +6486,15 @@ answer_response(fetchctx_t *fctx) {
78 view = fctx->res->view;
79 result = dns_message_firstname(message, DNS_SECTION_ANSWER);
80 while (!done && result == ISC_R_SUCCESS) {
81+ dns_namereln_t namereln;
82+ int order;
83+ unsigned int nlabels;
84+
85 name = NULL;
86 dns_message_currentname(message, DNS_SECTION_ANSWER, &name);
87 external = ISC_TF(!dns_name_issubdomain(name, &fctx->domain));
88- if (dns_name_equal(name, qname)) {
89+ namereln = dns_name_fullcompare(qname, name, &order, &nlabels);
90+ if (namereln == dns_namereln_equal) {
91 wanted_chaining = ISC_FALSE;
92 for (rdataset = ISC_LIST_HEAD(name->list);
93 rdataset != NULL;
94@@ -6632,10 +6619,11 @@ answer_response(fetchctx_t *fctx) {
95 */
96 INSIST(!external);
97 if (aflag ==
98- DNS_RDATASETATTR_ANSWER)
99+ DNS_RDATASETATTR_ANSWER) {
100 have_answer = ISC_TRUE;
101- name->attributes |=
102- DNS_NAMEATTR_ANSWER;
103+ name->attributes |=
104+ DNS_NAMEATTR_ANSWER;
105+ }
106 rdataset->attributes |= aflag;
107 if (aa)
108 rdataset->trust =
109@@ -6690,6 +6678,8 @@ answer_response(fetchctx_t *fctx) {
110 if (wanted_chaining)
111 chaining = ISC_TRUE;
112 } else {
113+ dns_rdataset_t *dnameset = NULL;
114+
115 /*
116 * Look for a DNAME (or its SIG). Anything else is
117 * ignored.
118@@ -6697,10 +6687,8 @@ answer_response(fetchctx_t *fctx) {
119 wanted_chaining = ISC_FALSE;
120 for (rdataset = ISC_LIST_HEAD(name->list);
121 rdataset != NULL;
122- rdataset = ISC_LIST_NEXT(rdataset, link)) {
123- isc_boolean_t found_dname = ISC_FALSE;
124- dns_name_t *dname_name;
125-
126+ rdataset = ISC_LIST_NEXT(rdataset, link))
127+ {
128 /*
129 * Only pass DNAME or RRSIG(DNAME).
130 */
131@@ -6714,20 +6702,41 @@ answer_response(fetchctx_t *fctx) {
132 * its signature should not be external.
133 */
134 if (!chaining && external) {
135- log_formerr(fctx, "external DNAME");
136+ char qbuf[DNS_NAME_FORMATSIZE];
137+ char obuf[DNS_NAME_FORMATSIZE];
138+
139+ dns_name_format(name, qbuf,
140+ sizeof(qbuf));
141+ dns_name_format(&fctx->domain, obuf,
142+ sizeof(obuf));
143+ log_formerr(fctx, "external DNAME or "
144+ "RRSIG covering DNAME "
145+ "in answer: %s is "
146+ "not in %s", qbuf, obuf);
147+ return (DNS_R_FORMERR);
148+ }
149+
150+ if (namereln != dns_namereln_subdomain) {
151+ char qbuf[DNS_NAME_FORMATSIZE];
152+ char obuf[DNS_NAME_FORMATSIZE];
153+
154+ dns_name_format(qname, qbuf,
155+ sizeof(qbuf));
156+ dns_name_format(name, obuf,
157+ sizeof(obuf));
158+ log_formerr(fctx, "unrelated DNAME "
159+ "in answer: %s is "
160+ "not in %s", qbuf, obuf);
161 return (DNS_R_FORMERR);
162 }
163
164- found = ISC_FALSE;
165 aflag = 0;
166 if (rdataset->type == dns_rdatatype_dname) {
167- found = ISC_TRUE;
168 want_chaining = ISC_TRUE;
169 POST(want_chaining);
170 aflag = DNS_RDATASETATTR_ANSWER;
171- result = dname_target(fctx, rdataset,
172- qname, name,
173- &dname);
174+ result = dname_target(rdataset, qname,
175+ nlabels, &fdname);
176 if (result == ISC_R_NOSPACE) {
177 /*
178 * We can't construct the
179@@ -6739,14 +6748,12 @@ answer_response(fetchctx_t *fctx) {
180 } else if (result != ISC_R_SUCCESS)
181 return (result);
182 else
183- found_dname = ISC_TRUE;
184+ dnameset = rdataset;
185
186- dname_name = dns_fixedname_name(&dname);
187+ dname = dns_fixedname_name(&fdname);
188 if (!is_answertarget_allowed(view,
189- qname,
190- rdataset->type,
191- dname_name,
192- &fctx->domain)) {
193+ qname, rdataset->type,
194+ dname, &fctx->domain)) {
195 return (DNS_R_SERVFAIL);
196 }
197 } else {
198@@ -6754,73 +6761,60 @@ answer_response(fetchctx_t *fctx) {
199 * We've found a signature that
200 * covers the DNAME.
201 */
202- found = ISC_TRUE;
203 aflag = DNS_RDATASETATTR_ANSWERSIG;
204 }
205
206- if (found) {
207+ /*
208+ * We've found an answer to our
209+ * question.
210+ */
211+ name->attributes |= DNS_NAMEATTR_CACHE;
212+ rdataset->attributes |= DNS_RDATASETATTR_CACHE;
213+ rdataset->trust = dns_trust_answer;
214+ if (!chaining) {
215 /*
216- * We've found an answer to our
217- * question.
218+ * This data is "the" answer to
219+ * our question only if we're
220+ * not chaining.
221 */
222- name->attributes |=
223- DNS_NAMEATTR_CACHE;
224- rdataset->attributes |=
225- DNS_RDATASETATTR_CACHE;
226- rdataset->trust = dns_trust_answer;
227- if (!chaining) {
228- /*
229- * This data is "the" answer
230- * to our question only if
231- * we're not chaining.
232- */
233- INSIST(!external);
234- if (aflag ==
235- DNS_RDATASETATTR_ANSWER)
236- have_answer = ISC_TRUE;
237+ INSIST(!external);
238+ if (aflag == DNS_RDATASETATTR_ANSWER) {
239+ have_answer = ISC_TRUE;
240 name->attributes |=
241 DNS_NAMEATTR_ANSWER;
242- rdataset->attributes |= aflag;
243- if (aa)
244- rdataset->trust =
245- dns_trust_authanswer;
246- } else if (external) {
247- rdataset->attributes |=
248- DNS_RDATASETATTR_EXTERNAL;
249- }
250-
251- /*
252- * DNAME chaining.
253- */
254- if (found_dname) {
255- /*
256- * Copy the dname into the
257- * qname fixed name.
258- *
259- * Although we check for
260- * failure of the copy
261- * operation, in practice it
262- * should never fail since
263- * we already know that the
264- * result fits in a fixedname.
265- */
266- dns_fixedname_init(&fqname);
267- result = dns_name_copy(
268- dns_fixedname_name(&dname),
269- dns_fixedname_name(&fqname),
270- NULL);
271- if (result != ISC_R_SUCCESS)
272- return (result);
273- wanted_chaining = ISC_TRUE;
274- name->attributes |=
275- DNS_NAMEATTR_CHAINING;
276- rdataset->attributes |=
277- DNS_RDATASETATTR_CHAINING;
278- qname = dns_fixedname_name(
279- &fqname);
280 }
281+ rdataset->attributes |= aflag;
282+ if (aa)
283+ rdataset->trust =
284+ dns_trust_authanswer;
285+ } else if (external) {
286+ rdataset->attributes |=
287+ DNS_RDATASETATTR_EXTERNAL;
288 }
289 }
290+
291+ /*
292+ * DNAME chaining.
293+ */
294+ if (dnameset != NULL) {
295+ /*
296+ * Copy the dname into the qname fixed name.
297+ *
298+ * Although we check for failure of the copy
299+ * operation, in practice it should never fail
300+ * since we already know that the result fits
301+ * in a fixedname.
302+ */
303+ dns_fixedname_init(&fqname);
304+ qname = dns_fixedname_name(&fqname);
305+ result = dns_name_copy(dname, qname, NULL);
306+ if (result != ISC_R_SUCCESS)
307+ return (result);
308+ wanted_chaining = ISC_TRUE;
309+ name->attributes |= DNS_NAMEATTR_CHAINING;
310+ dnameset->attributes |=
311+ DNS_RDATASETATTR_CHAINING;
312+ }
313 if (wanted_chaining)
314 chaining = ISC_TRUE;
315 }
316--
3171.9.1
318