summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/musl
diff options
context:
space:
mode:
authorArmin Kuster <akuster@mvista.com>2016-10-19 18:00:46 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-10-28 16:15:19 +0100
commit2031738d28768ebd95cce9c355521142dd1a88c4 (patch)
treed6bd13d6338beb63d66eb9217a86870e7ff7e51d /meta/recipes-core/musl
parent95970f1941e9972103f6b1dc8f2f91fb84b5e75a (diff)
downloadpoky-2031738d28768ebd95cce9c355521142dd1a88c4.tar.gz
musl: Security fix CVE-2016-8859
CVE-2016-8859: TRE & musl libc regex integer overflows in buffer size computations Affects musl <= 1.1.15 (From OE-Core rev: ac82bd95ec62a6af8286289889a9d36fa5f58005) Signed-off-by: Armin Kuster <akuster@mvista.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/musl')
-rw-r--r--meta/recipes-core/musl/files/CVE-2016-8859.patch79
-rw-r--r--meta/recipes-core/musl/musl_git.bb1
2 files changed, 80 insertions, 0 deletions
diff --git a/meta/recipes-core/musl/files/CVE-2016-8859.patch b/meta/recipes-core/musl/files/CVE-2016-8859.patch
new file mode 100644
index 0000000000..82da86f0bd
--- /dev/null
+++ b/meta/recipes-core/musl/files/CVE-2016-8859.patch
@@ -0,0 +1,79 @@
1From c3edc06d1e1360f3570db9155d6b318ae0d0f0f7 Mon Sep 17 00:00:00 2001
2From: Rich Felker <dalias@aerifal.cx>
3Date: Thu, 6 Oct 2016 18:34:58 -0400
4Subject: [PATCH] fix missing integer overflow checks in regexec buffer size
5 computations
6
7most of the possible overflows were already ruled out in practice by
8regcomp having already succeeded performing larger allocations.
9however at least the num_states*num_tags multiplication can clearly
10overflow in practice. for safety, check them all, and use the proper
11type, size_t, rather than int.
12
13also improve comments, use calloc in place of malloc+memset, and
14remove bogus casts.
15
16Upstream-Status: Backport
17CVE: CVE-2016-8859
18
19Signed-off-by: Armin Kuster <akuster@mvista.com>
20
21---
22 src/regex/regexec.c | 23 ++++++++++++++++++-----
23 1 file changed, 18 insertions(+), 5 deletions(-)
24
25diff --git a/src/regex/regexec.c b/src/regex/regexec.c
26index 16c5d0a..dd52319 100644
27--- a/src/regex/regexec.c
28+++ b/src/regex/regexec.c
29@@ -34,6 +34,7 @@
30 #include <wchar.h>
31 #include <wctype.h>
32 #include <limits.h>
33+#include <stdint.h>
34
35 #include <regex.h>
36
37@@ -206,11 +207,24 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
38
39 /* Allocate memory for temporary data required for matching. This needs to
40 be done for every matching operation to be thread safe. This allocates
41- everything in a single large block from the stack frame using alloca()
42- or with malloc() if alloca is unavailable. */
43+ everything in a single large block with calloc(). */
44 {
45- int tbytes, rbytes, pbytes, xbytes, total_bytes;
46+ size_t tbytes, rbytes, pbytes, xbytes, total_bytes;
47 char *tmp_buf;
48+
49+ /* Ensure that tbytes and xbytes*num_states cannot overflow, and that
50+ * they don't contribute more than 1/8 of SIZE_MAX to total_bytes. */
51+ if (num_tags > SIZE_MAX/(8 * sizeof(int) * tnfa->num_states))
52+ goto error_exit;
53+
54+ /* Likewise check rbytes. */
55+ if (tnfa->num_states+1 > SIZE_MAX/(8 * sizeof(*reach_next)))
56+ goto error_exit;
57+
58+ /* Likewise check pbytes. */
59+ if (tnfa->num_states > SIZE_MAX/(8 * sizeof(*reach_pos)))
60+ goto error_exit;
61+
62 /* Compute the length of the block we need. */
63 tbytes = sizeof(*tmp_tags) * num_tags;
64 rbytes = sizeof(*reach_next) * (tnfa->num_states + 1);
65@@ -221,10 +235,9 @@ tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, const void *string,
66 + (rbytes + xbytes * tnfa->num_states) * 2 + tbytes + pbytes;
67
68 /* Allocate the memory. */
69- buf = xmalloc((unsigned)total_bytes);
70+ buf = calloc(total_bytes, 1);
71 if (buf == NULL)
72 return REG_ESPACE;
73- memset(buf, 0, (size_t)total_bytes);
74
75 /* Get the various pointers within tmp_buf (properly aligned). */
76 tmp_tags = (void *)buf;
77--
782.7.4
79
diff --git a/meta/recipes-core/musl/musl_git.bb b/meta/recipes-core/musl/musl_git.bb
index c07101b748..1ee56b6434 100644
--- a/meta/recipes-core/musl/musl_git.bb
+++ b/meta/recipes-core/musl/musl_git.bb
@@ -11,6 +11,7 @@ PV = "1.1.15+git${SRCPV}"
11 11
12SRC_URI = "git://git.musl-libc.org/musl \ 12SRC_URI = "git://git.musl-libc.org/musl \
13 file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \ 13 file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \
14 file://CVE-2016-8859.patch \
14 " 15 "
15 16
16S = "${WORKDIR}/git" 17S = "${WORKDIR}/git"