<div><br><div class="gmail_quote"><div dir="auto">On Wed, Nov 15, 2017 at 12:36 PM George McCollister &lt;<a href="mailto:george.mccollister@gmail.com">george.mccollister@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add backported patch to fix CVE-2015-5180 from the upstream<br>
release/2.24/master branch.<br>
</blockquote><div dir="auto"><br></div><div dir="auto">This is ok</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Signed-off-by: George McCollister &lt;<a href="mailto:george.mccollister@gmail.com" target="_blank">george.mccollister@gmail.com</a>&gt;<br>
---<br>
<br>
Changes in v2:<br>
 - Fix commit message<br>
<br>
 ...80-resolv-Fix-crash-with-internal-QTYPE-B.patch | 357 +++++++++++++++++++++<br>
 meta/recipes-core/glibc/<a href="http://glibc_2.24.bb" rel="noreferrer" target="_blank">glibc_2.24.bb</a>              |   1 +<br>
 2 files changed, 358 insertions(+)<br>
 create mode 100644 meta/recipes-core/glibc/glibc/0001-CVE-2015-5180-resolv-Fix-crash-with-internal-QTYPE-B.patch<br>
<br>
diff --git a/meta/recipes-core/glibc/glibc/0001-CVE-2015-5180-resolv-Fix-crash-with-internal-QTYPE-B.patch b/meta/recipes-core/glibc/glibc/0001-CVE-2015-5180-resolv-Fix-crash-with-internal-QTYPE-B.patch<br>
new file mode 100644<br>
index 0000000000..ba0bebe488<br>
--- /dev/null<br>
+++ b/meta/recipes-core/glibc/glibc/0001-CVE-2015-5180-resolv-Fix-crash-with-internal-QTYPE-B.patch<br>
@@ -0,0 +1,357 @@<br>
+From ff9b7c4fb73295cd2de2d2ccfbbf4f6d50883d47 Mon Sep 17 00:00:00 2001<br>
+From: Florian Weimer &lt;<a href="mailto:fweimer@redhat.com" target="_blank">fweimer@redhat.com</a>&gt;<br>
+Date: Sat, 31 Dec 2016 20:22:09 +0100<br>
+Subject: [PATCH] CVE-2015-5180: resolv: Fix crash with internal QTYPE [BZ<br>
+ #18784]<br>
+<br>
+Also rename T_UNSPEC because an upcoming public header file<br>
+update will use that name.<br>
+<br>
+(cherry picked from commit fc82b0a2dfe7dbd35671c10510a8da1043d746a5)<br>
+<br>
+Upstream-Status: Backport<br>
+<a href="https://sourceware.org/git/?p=glibc.git;a=patch;h=b3b37f1a5559a7620e31c8053ed1b44f798f2b6d" rel="noreferrer" target="_blank">https://sourceware.org/git/?p=glibc.git;a=patch;h=b3b37f1a5559a7620e31c8053ed1b44f798f2b6d</a><br>
+<br>
+CVE: CVE-2015-5180<br>
+<br>
+Signed-off-by: George McCollister &lt;<a href="mailto:george.mccollister@gmail.com" target="_blank">george.mccollister@gmail.com</a>&gt;<br>
+---<br>
+ ChangeLog                     |  14 ++++<br>
+ NEWS                          |   6 ++<br>
+ include/arpa/nameser_compat.h |   6 +-<br>
+ resolv/Makefile               |   5 ++<br>
+ resolv/nss_dns/dns-host.c     |   2 +-<br>
+ resolv/res_mkquery.c          |   4 +<br>
+ resolv/res_query.c            |   6 +-<br>
+ resolv/tst-resolv-qtypes.c    | 185 ++++++++++++++++++++++++++++++++++++++++++<br>
+ 8 files changed, 221 insertions(+), 7 deletions(-)<br>
+ create mode 100644 resolv/tst-resolv-qtypes.c<br>
+<br>
+diff --git a/ChangeLog b/ChangeLog<br>
+index 893262de11..2bdaf69e43 100644<br>
+--- a/ChangeLog<br>
++++ b/ChangeLog<br>
+@@ -1,3 +1,17 @@<br>
++2016-12-31  Florian Weimer  &lt;<a href="mailto:fweimer@redhat.com" target="_blank">fweimer@redhat.com</a>&gt;<br>
++<br>
++      [BZ #18784]<br>
++      CVE-2015-5180<br>
++      * include/arpa/nameser_compat.h (T_QUERY_A_AND_AAAA): Rename from<br>
++      T_UNSPEC.  Adjust value.<br>
++      * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname4_r): Use it.<br>
++      * resolv/res_query.c (__libc_res_nquery): Likewise.<br>
++      * resolv/res_mkquery.c (res_nmkquery): Check for out-of-range<br>
++      QTYPEs.<br>
++      * resolv/tst-resolv-qtypes.c: New file.<br>
++      * resolv/Makefile (xtests): Add tst-resolv-qtypes.<br>
++      (tst-resolv-qtypes): Link against libresolv and libpthread.<br>
++<br>
+ 2016-10-26  Carlos O&#39;Donell  &lt;<a href="mailto:carlos@redhat.com" target="_blank">carlos@redhat.com</a>&gt;<br>
+<br>
+       * include/atomic.h<br>
+diff --git a/NEWS b/NEWS<br>
+index 3002773c16..4b1ca3cb65 100644<br>
+--- a/NEWS<br>
++++ b/NEWS<br>
+@@ -11,6 +11,12 @@ using `glibc&#39; in the &quot;product&quot; field.<br>
+   printers show various pthread variables in human-readable form when read<br>
+   using the &#39;print&#39; or &#39;display&#39; commands in gdb.<br>
+<br>
++* The DNS stub resolver functions would crash due to a NULL pointer<br>
++  dereference when processing a query with a valid DNS question type which<br>
++  was used internally in the implementation.  The stub resolver now uses a<br>
++  question type which is outside the range of valid question type values.<br>
++  (CVE-2015-5180)<br>
++<br>
+ Version 2.24<br>
+<br>
+ * The minimum Linux kernel version that this version of the GNU C Library<br>
+diff --git a/include/arpa/nameser_compat.h b/include/arpa/nameser_compat.h<br>
+index 2e735ede4c..7c0deed9ae 100644<br>
+--- a/include/arpa/nameser_compat.h<br>
++++ b/include/arpa/nameser_compat.h<br>
+@@ -1,8 +1,8 @@<br>
+ #ifndef _ARPA_NAMESER_COMPAT_<br>
+ #include &lt;resolv/arpa/nameser_compat.h&gt;<br>
+<br>
+-/* Picksome unused number to represent lookups of IPv4 and IPv6 (i.e.,<br>
+-   T_A and T_AAAA).  */<br>
+-#define T_UNSPEC 62321<br>
++/* The number is outside the 16-bit RR type range and is used<br>
++   internally by the implementation.  */<br>
++#define T_QUERY_A_AND_AAAA 439963904<br>
+<br>
+ #endif<br>
+diff --git a/resolv/Makefile b/resolv/Makefile<br>
+index 8be41d3ae1..a4c86b9762 100644<br>
+--- a/resolv/Makefile<br>
++++ b/resolv/Makefile<br>
+@@ -40,6 +40,9 @@ ifeq ($(have-thread-library),yes)<br>
+ extra-libs += libanl<br>
+ routines += gai_sigqueue<br>
+ tests += tst-res_hconf_reorder<br>
++<br>
++# This test sends millions of packets and is rather slow.<br>
++xtests += tst-resolv-qtypes<br>
+ endif<br>
+ extra-libs-others = $(extra-libs)<br>
+ libresolv-routines := gethnamaddr res_comp res_debug  \<br>
+@@ -117,3 +120,5 @@ tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace<br>
+ $(objpfx)mtrace-tst-leaks2.out: $(objpfx)tst-leaks2.out<br>
+       $(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace &gt; $@; \<br>
+       $(evaluate-test)<br>
++<br>
++$(objpfx)tst-resolv-qtypes: $(objpfx)libresolv.so $(shared-thread-library)<br>
+diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c<br>
+index 5f9e35701b..d16fa4b8ed 100644<br>
+--- a/resolv/nss_dns/dns-host.c<br>
++++ b/resolv/nss_dns/dns-host.c<br>
+@@ -323,7 +323,7 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,<br>
+<br>
+   int olderr = errno;<br>
+   enum nss_status status;<br>
+-  int n = __libc_res_nsearch (&amp;_res, name, C_IN, T_UNSPEC,<br>
++  int n = __libc_res_nsearch (&amp;_res, name, C_IN, T_QUERY_A_AND_AAAA,<br>
+                             host_buffer.buf-&gt;buf, 2048, &amp;host_buffer.ptr,<br>
+                             &amp;ans2p, &amp;nans2p, &amp;resplen2, &amp;ans2p_malloced);<br>
+   if (n &gt;= 0)<br>
+diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c<br>
+index 12f9730199..d80b5318e5 100644<br>
+--- a/resolv/res_mkquery.c<br>
++++ b/resolv/res_mkquery.c<br>
+@@ -103,6 +103,10 @@ res_nmkquery(res_state statp,<br>
+       int n;<br>
+       u_char *dnptrs[20], **dpp, **lastdnptr;<br>
+<br>
++      if (class &lt; 0 || class &gt; 65535<br>
++          || type &lt; 0 || type &gt; 65535)<br>
++        return -1;<br>
++<br>
+ #ifdef DEBUG<br>
+       if (statp-&gt;options &amp; RES_DEBUG)<br>
+               printf(&quot;;; res_nmkquery(%s, %s, %s, %s)\n&quot;,<br>
+diff --git a/resolv/res_query.c b/resolv/res_query.c<br>
+index 944d1a90f5..07dc6f6583 100644<br>
+--- a/resolv/res_query.c<br>
++++ b/resolv/res_query.c<br>
+@@ -122,7 +122,7 @@ __libc_res_nquery(res_state statp,<br>
+       int n, use_malloc = 0;<br>
+       u_int oflags = statp-&gt;_flags;<br>
+<br>
+-      size_t bufsize = (type == T_UNSPEC ? 2 : 1) * QUERYSIZE;<br>
++      size_t bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * QUERYSIZE;<br>
+       u_char *buf = alloca (bufsize);<br>
+       u_char *query1 = buf;<br>
+       int nquery1 = -1;<br>
+@@ -137,7 +137,7 @@ __libc_res_nquery(res_state statp,<br>
+               printf(&quot;;; res_query(%s, %d, %d)\n&quot;, name, class, type);<br>
+ #endif<br>
+<br>
+-      if (type == T_UNSPEC)<br>
++      if (type == T_QUERY_A_AND_AAAA)<br>
+         {<br>
+           n = res_nmkquery(statp, QUERY, name, class, T_A, NULL, 0, NULL,<br>
+                            query1, bufsize);<br>
+@@ -190,7 +190,7 @@ __libc_res_nquery(res_state statp,<br>
+       if (__builtin_expect (n &lt;= 0, 0) &amp;&amp; !use_malloc) {<br>
+               /* Retry just in case res_nmkquery failed because of too<br>
+                  short buffer.  Shouldn&#39;t happen.  */<br>
+-              bufsize = (type == T_UNSPEC ? 2 : 1) * MAXPACKET;<br>
++              bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * MAXPACKET;<br>
+               buf = malloc (bufsize);<br>
+               if (buf != NULL) {<br>
+                       query1 = buf;<br>
+diff --git a/resolv/tst-resolv-qtypes.c b/resolv/tst-resolv-qtypes.c<br>
+new file mode 100644<br>
+index 0000000000..b3e60c693b<br>
+--- /dev/null<br>
++++ b/resolv/tst-resolv-qtypes.c<br>
+@@ -0,0 +1,185 @@<br>
++/* Exercise low-level query functions with different QTYPEs.<br>
++   Copyright (C) 2016 Free Software Foundation, Inc.<br>
++   This file is part of the GNU C Library.<br>
++<br>
++   The GNU C Library is free software; you can redistribute it and/or<br>
++   modify it under the terms of the GNU Lesser General Public<br>
++   License as published by the Free Software Foundation; either<br>
++   version 2.1 of the License, or (at your option) any later version.<br>
++<br>
++   The GNU C Library is distributed in the hope that it will be useful,<br>
++   but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>
++   Lesser General Public License for more details.<br>
++<br>
++   You should have received a copy of the GNU Lesser General Public<br>
++   License along with the GNU C Library; if not, see<br>
++   &lt;<a href="http://www.gnu.org/licenses/" rel="noreferrer" target="_blank">http://www.gnu.org/licenses/</a>&gt;.  */<br>
++<br>
++#include &lt;resolv.h&gt;<br>
++#include &lt;string.h&gt;<br>
++#include &lt;support/check.h&gt;<br>
++#include &lt;support/check_nss.h&gt;<br>
++#include &lt;support/resolv_test.h&gt;<br>
++#include &lt;support/support.h&gt;<br>
++#include &lt;support/test-driver.h&gt;<br>
++#include &lt;support/xmemstream.h&gt;<br>
++<br>
++/* If ture, the response function will send the actual response packet<br>
++   over TCP instead of UDP.  */<br>
++static volatile bool force_tcp;<br>
++<br>
++/* Send back a fake resource record matching the QTYPE.  */<br>
++static void<br>
++response (const struct resolv_response_context *ctx,<br>
++          struct resolv_response_builder *b,<br>
++          const char *qname, uint16_t qclass, uint16_t qtype)<br>
++{<br>
++  if (force_tcp &amp;&amp; ctx-&gt;tcp)<br>
++    {<br>
++      resolv_response_init (b, (struct resolv_response_flags) { .tc = 1 });<br>
++      resolv_response_add_question (b, qname, qclass, qtype);<br>
++      return;<br>
++    }<br>
++<br>
++  resolv_response_init (b, (struct resolv_response_flags) { });<br>
++  resolv_response_add_question (b, qname, qclass, qtype);<br>
++  resolv_response_section (b, ns_s_an);<br>
++  resolv_response_open_record (b, qname, qclass, qtype, 0);<br>
++  resolv_response_add_data (b, &amp;qtype, sizeof (qtype));<br>
++  resolv_response_close_record (b);<br>
++}<br>
++<br>
++static const const char *domain = &quot;<a href="http://www.example.com" rel="noreferrer" target="_blank">www.example.com</a>&quot;;<br>
++<br>
++static int<br>
++wrap_res_query (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  return res_query (domain, C_IN, type, answer, answer_length);<br>
++}<br>
++<br>
++static int<br>
++wrap_res_search (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  return res_query (domain, C_IN, type, answer, answer_length);<br>
++}<br>
++<br>
++static int<br>
++wrap_res_querydomain (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  return res_querydomain (&quot;www&quot;, &quot;<a href="http://example.com" rel="noreferrer" target="_blank">example.com</a>&quot;, C_IN, type,<br>
++                           answer, answer_length);<br>
++}<br>
++<br>
++static int<br>
++wrap_res_send (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  unsigned char buf[512];<br>
++  int ret = res_mkquery (QUERY, domain, C_IN, type,<br>
++                         (const unsigned char *) &quot;&quot;, 0, NULL,<br>
++                         buf, sizeof (buf));<br>
++  if (type &lt; 0 || type &gt;= 65536)<br>
++    {<br>
++      /* res_mkquery fails for out-of-range record types.  */<br>
++      TEST_VERIFY_EXIT (ret == -1);<br>
++      return -1;<br>
++    }<br>
++  TEST_VERIFY_EXIT (ret &gt; 12);  /* DNS header length.  */<br>
++  return res_send (buf, ret, answer, answer_length);<br>
++}<br>
++<br>
++static int<br>
++wrap_res_nquery (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  return res_nquery (&amp;_res, domain, C_IN, type, answer, answer_length);<br>
++}<br>
++<br>
++static int<br>
++wrap_res_nsearch (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  return res_nquery (&amp;_res, domain, C_IN, type, answer, answer_length);<br>
++}<br>
++<br>
++static int<br>
++wrap_res_nquerydomain (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  return res_nquerydomain (&amp;_res, &quot;www&quot;, &quot;<a href="http://example.com" rel="noreferrer" target="_blank">example.com</a>&quot;, C_IN, type,<br>
++                           answer, answer_length);<br>
++}<br>
++<br>
++static int<br>
++wrap_res_nsend (int type, unsigned char *answer, int answer_length)<br>
++{<br>
++  unsigned char buf[512];<br>
++  int ret = res_nmkquery (&amp;_res, QUERY, domain, C_IN, type,<br>
++                         (const unsigned char *) &quot;&quot;, 0, NULL,<br>
++                         buf, sizeof (buf));<br>
++  if (type &lt; 0 || type &gt;= 65536)<br>
++    {<br>
++      /* res_mkquery fails for out-of-range record types.  */<br>
++      TEST_VERIFY_EXIT (ret == -1);<br>
++      return -1;<br>
++    }<br>
++  TEST_VERIFY_EXIT (ret &gt; 12);  /* DNS header length.  */<br>
++  return res_nsend (&amp;_res, buf, ret, answer, answer_length);<br>
++}<br>
++<br>
++static void<br>
++test_function (const char *fname,<br>
++               int (*func) (int type,<br>
++                            unsigned char *answer, int answer_length))<br>
++{<br>
++  unsigned char buf[512];<br>
++  for (int tcp = 0; tcp &lt; 2; ++tcp)<br>
++    {<br>
++      force_tcp = tcp;<br>
++      for (unsigned int type = 1; type &lt;= 65535; ++type)<br>
++        {<br>
++          if (test_verbose)<br>
++            printf (&quot;info: sending QTYPE %d with %s (tcp=%d)\n&quot;,<br>
++                    type, fname, tcp);<br>
++          int ret = func (type, buf, sizeof (buf));<br>
++          if (ret != 47)<br>
++            FAIL_EXIT1 (&quot;%s tcp=%d qtype=%d return value %d&quot;,<br>
++                        fname,tcp, type, ret);<br>
++          /* One question, one answer record.  */<br>
++          TEST_VERIFY (memcmp (buf + 4, &quot;\0\1\0\1\0\0\0\0&quot;, 8) == 0);<br>
++          /* Question section.  */<br>
++          static const char qname[] = &quot;\3www\7example\3com&quot;;<br>
++          size_t qname_length = sizeof (qname);<br>
++          TEST_VERIFY (memcmp (buf + 12, qname, qname_length) == 0);<br>
++          /* RDATA part of answer.  */<br>
++          uint16_t type16 = type;<br>
++          TEST_VERIFY (memcmp (buf + ret - 2, &amp;type16, sizeof (type16)) == 0);<br>
++        }<br>
++    }<br>
++<br>
++  TEST_VERIFY (func (-1, buf, sizeof (buf) == -1));<br>
++  TEST_VERIFY (func (65536, buf, sizeof (buf) == -1));<br>
++}<br>
++<br>
++static int<br>
++do_test (void)<br>
++{<br>
++  struct resolv_redirect_config config =<br>
++    {<br>
++      .response_callback = response,<br>
++    };<br>
++  struct resolv_test *obj = resolv_test_start (config);<br>
++<br>
++  test_function (&quot;res_query&quot;, &amp;wrap_res_query);<br>
++  test_function (&quot;res_search&quot;, &amp;wrap_res_search);<br>
++  test_function (&quot;res_querydomain&quot;, &amp;wrap_res_querydomain);<br>
++  test_function (&quot;res_send&quot;, &amp;wrap_res_send);<br>
++<br>
++  test_function (&quot;res_nquery&quot;, &amp;wrap_res_nquery);<br>
++  test_function (&quot;res_nsearch&quot;, &amp;wrap_res_nsearch);<br>
++  test_function (&quot;res_nquerydomain&quot;, &amp;wrap_res_nquerydomain);<br>
++  test_function (&quot;res_nsend&quot;, &amp;wrap_res_nsend);<br>
++<br>
++  resolv_test_end (obj);<br>
++  return 0;<br>
++}<br>
++<br>
++#define TIMEOUT 300<br>
++#include &lt;support/test-driver.c&gt;<br>
+--<br>
+2.15.0<br>
+<br>
diff --git a/meta/recipes-core/glibc/<a href="http://glibc_2.24.bb" rel="noreferrer" target="_blank">glibc_2.24.bb</a> b/meta/recipes-core/glibc/<a href="http://glibc_2.24.bb" rel="noreferrer" target="_blank">glibc_2.24.bb</a><br>
index e723e03dcf..4c7d901149 100644<br>
--- a/meta/recipes-core/glibc/<a href="http://glibc_2.24.bb" rel="noreferrer" target="_blank">glibc_2.24.bb</a><br>
+++ b/meta/recipes-core/glibc/<a href="http://glibc_2.24.bb" rel="noreferrer" target="_blank">glibc_2.24.bb</a><br>
@@ -45,6 +45,7 @@ SRC_URI = &quot;${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \<br>
            file://0004-New-condvar-implementation-that-provides-stronger-or.patch \<br>
            file://0005-Remove-__ASSUME_REQUEUE_PI.patch \<br>
            file://0006-Fix-atomic_fetch_xor_release.patch \<br>
+           file://0001-CVE-2015-5180-resolv-Fix-crash-with-internal-QTYPE-B.patch \<br>
 &quot;<br>
<br>
 SRC_URI += &quot;\<br>
--<br>
2.15.0<br>
<br>
--<br>
_______________________________________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org" target="_blank">Openembedded-core@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/openembedded-core</a><br>
</blockquote></div></div>