~ubuntu-branches/ubuntu/trusty/eglibc/trusty-security

« back to all changes in this revision

Viewing changes to debian/patches/any/CVE-2015-8779.diff

  • Committer: Package Import Robot
  • Author(s): Steve Beattie
  • Date: 2016-04-08 23:26:02 UTC
  • Revision ID: package-import@ubuntu.com-20160408232602-694337pzn1m5xgc3
Tags: 2.19-0ubuntu6.8
* SECURITY UPDATE: buffer overflow in gethostbyname_r and related
  functions
  - debian/patches/any/CVE-2015-1781.diff: take alignment padding
    into account when computing if buffer is too small.
  - CVE-2015-1781
* SECURITY UPDATE: glibc Name Service Switch (NSS) denial of sevice
  - debian/patches/any/CVE-2014-8121-1.diff: do not close NSS files
    database during iteration.
  - debian/patches/any/CVE-2014-8121-2.diff: Separate internal state
    between getXXent and getXXbyYY NSS calls.
  - CVE-2014-8121
* SECURITY UPDATE: glibc unbounded stack usage in NaN strtod
  conversion
  - debian/patches/any/CVE-2014-9761-1.diff: Refactor strtod parsing
    of NaN payloads.
  - debian/patches/any/CVE-2014-9761-1.diff:  Fix nan functions
    handling of payload strings
  - CVE-2014-9761
* SECURITY UPDATE: NSS files long line buffer overflow
  - debian/patches/any/CVE-2015-5277.diff: Don't ignore too long
    lines in nss_files
  - CVE-2015-5277
* SECURITY UPDATE: out of range data to strftime() causes segfault
  (denial of service)
  - debian/patches/any/CVE-2015-8776.diff: add range checks to
    strftime() processing
  - CVE-2015-8776
* SECURITY UPDATE: glibc honors LD_POINTER_GUARD env for setuid
  AT_SECURE programs (e.g. setuid), allowing disabling of pointer
  mangling
  - debian/patches/any/CVE-2015-8777.diff: Always enable pointer
    guard
  - CVE-2015-8777
* SECURITY UPDATE: integer overflow in hcreate and hcreate_r
  - debian/patches/any/CVE-2015-8778.diff: check for large inputs
  - CVE-2015-8778
* SECURITY UPDATE: unbounded stack allocation in catopen()
  - debian/patches/any/CVE-2015-8779.diff: stop using unbounded
    alloca()
  - CVE-2015-8779
* SECURITY UPDATE: Stack overflow in _nss_dns_getnetbyname_r
  - debian/patches/any/CVE-2016-3075.diff: do not make unneeded
    memory copy on the stack.
  - CVE-2016-3075
* SECURITY UPDATE: pt_chown privilege escalation
  - debian/patches/any/CVE-2016-2856.diff: grantpt: trust the kernel
    about pty group and permission mode
  - debian/sysdeps/linux.mk: don't build pt_chown
  - debian/rules.d/debhelper.mk: only install pt_chown when built.
  - CVE-2016-2856, CVE-2013-2207
* debian/debhelper.in/libc.postinst: add reboot notifications for
  security updates (LP: #1546457)
* debian/patches/ubuntu/submitted-no-stack-backtrace.diff: update
  patch to eliminate compiler warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 0f58539030e436449f79189b6edab17d7479796e Mon Sep 17 00:00:00 2001
 
2
From: Paul Pluzhnikov <ppluzhnikov@google.com>
 
3
Date: Sat, 8 Aug 2015 15:53:03 -0700
 
4
Subject: [PATCH] Fix BZ #17905
 
5
 
 
6
        [BZ #17905]
 
7
        * catgets/Makefile (tst-catgets-mem): New test.
 
8
        * catgets/catgets.c (catopen): Don't use unbounded alloca.
 
9
        * catgets/open_catalog.c (__open_catalog): Likewise.
 
10
        * catgets/tst-catgets.c (do_bz17905): Test unbounded alloca.
 
11
 
 
12
[Note: patch differs from upstream commit in that the entries in
 
13
the Changelog and NEWS were dropped to avoid patch conflicts. -- sbeattie]
 
14
---
 
15
 catgets/Makefile       |   10 ++++++++--
 
16
 catgets/catgets.c      |   19 ++++++++++++-------
 
17
 catgets/open_catalog.c |   23 ++++++++++++++---------
 
18
 catgets/tst-catgets.c  |   31 +++++++++++++++++++++++++++++++
 
19
 4 files changed, 65 insertions(+), 18 deletions(-)
 
20
 
 
21
Index: b/catgets/Makefile
 
22
===================================================================
 
23
--- a/catgets/Makefile
 
24
+++ b/catgets/Makefile
 
25
@@ -48,14 +48,16 @@ CPPFLAGS-gencat = -DNOT_IN_libc
 
26
 
 
27
 generated = de.msg test1.cat test1.h test2.cat test2.h sample.SJIS.cat \
 
28
            test-gencat.h
 
29
+generated += tst-catgets.mtrace tst-catgets-mem.out
 
30
+
 
31
 generated-dirs = de
 
32
 
 
33
-tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de
 
34
+tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de MALLOC_TRACE=$(objpfx)tst-catgets.mtrace
 
35
 
 
36
 ifeq ($(run-built-tests),yes)
 
37
 ifeq (y,$(OPTION_EGLIBC_CATGETS))
 
38
 tests: $(objpfx)de/libc.cat $(objpfx)test1.cat $(objpfx)test2.cat \
 
39
-       $(objpfx)test-gencat.out
 
40
+       $(objpfx)test-gencat.out $(objpfx)tst-catgets-mem.out
 
41
 endif
 
42
 # This test just checks whether the program produces any error or not.
 
43
 # The result is not tested.
 
44
@@ -84,4 +86,8 @@ $(objpfx)test-gencat.out: test-gencat.sh
 
45
 $(objpfx)sample.SJIS.cat: sample.SJIS $(objpfx)gencat
 
46
        GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
 
47
        $(built-program-cmd) -H $(objpfx)test-gencat.h < $(word 1,$^) > $@
 
48
+
 
49
+$(objpfx)tst-catgets-mem.out: $(objpfx)tst-catgets.out
 
50
+       $(common-objpfx)malloc/mtrace $(objpfx)tst-catgets.mtrace > $@; \
 
51
+       $(evaluate-test)
 
52
 endif
 
53
Index: b/catgets/catgets.c
 
54
===================================================================
 
55
--- a/catgets/catgets.c
 
56
+++ b/catgets/catgets.c
 
57
@@ -16,7 +16,6 @@
 
58
    License along with the GNU C Library; if not, see
 
59
    <http://www.gnu.org/licenses/>.  */
 
60
 
 
61
-#include <alloca.h>
 
62
 #include <errno.h>
 
63
 #include <locale.h>
 
64
 #include <nl_types.h>
 
65
@@ -35,6 +34,7 @@ catopen (const char *cat_name, int flag)
 
66
   __nl_catd result;
 
67
   const char *env_var = NULL;
 
68
   const char *nlspath = NULL;
 
69
+  char *tmp = NULL;
 
70
 
 
71
   if (strchr (cat_name, '/') == NULL)
 
72
     {
 
73
@@ -54,7 +54,10 @@ catopen (const char *cat_name, int flag)
 
74
        {
 
75
          /* Append the system dependent directory.  */
 
76
          size_t len = strlen (nlspath) + 1 + sizeof NLSPATH;
 
77
-         char *tmp = alloca (len);
 
78
+         tmp = malloc (len);
 
79
+
 
80
+         if (__glibc_unlikely (tmp == NULL))
 
81
+           return (nl_catd) -1;
 
82
 
 
83
          __stpcpy (__stpcpy (__stpcpy (tmp, nlspath), ":"), NLSPATH);
 
84
          nlspath = tmp;
 
85
@@ -65,16 +68,18 @@ catopen (const char *cat_name, int flag)
 
86
 
 
87
   result = (__nl_catd) malloc (sizeof (*result));
 
88
   if (result == NULL)
 
89
-    /* We cannot get enough memory.  */
 
90
-    return (nl_catd) -1;
 
91
-
 
92
-  if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
 
93
+    {
 
94
+      /* We cannot get enough memory.  */
 
95
+      result = (nl_catd) -1;
 
96
+    }
 
97
+  else if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
 
98
     {
 
99
       /* Couldn't open the file.  */
 
100
       free ((void *) result);
 
101
-      return (nl_catd) -1;
 
102
+      result = (nl_catd) -1;
 
103
     }
 
104
 
 
105
+  free (tmp);
 
106
   return (nl_catd) result;
 
107
 }
 
108
 
 
109
Index: b/catgets/open_catalog.c
 
110
===================================================================
 
111
--- a/catgets/open_catalog.c
 
112
+++ b/catgets/open_catalog.c
 
113
@@ -47,6 +47,7 @@ __open_catalog (const char *cat_name, co
 
114
   size_t tab_size;
 
115
   const char *lastp;
 
116
   int result = -1;
 
117
+  char *buf = NULL;
 
118
 
 
119
   if (strchr (cat_name, '/') != NULL || nlspath == NULL)
 
120
     fd = open_not_cancel_2 (cat_name, O_RDONLY);
 
121
@@ -57,23 +58,23 @@ __open_catalog (const char *cat_name, co
 
122
   if (__builtin_expect (bufact + (n) >= bufmax, 0))                          \
 
123
     {                                                                        \
 
124
       char *old_buf = buf;                                                   \
 
125
-      bufmax += 256 + (n);                                                   \
 
126
-      buf = (char *) alloca (bufmax);                                        \
 
127
-      memcpy (buf, old_buf, bufact);                                         \
 
128
+      bufmax += (bufmax < 256 + (n)) ? 256 + (n) : bufmax;                   \
 
129
+      buf = realloc (buf, bufmax);                                           \
 
130
+      if (__glibc_unlikely (buf == NULL))                                    \
 
131
+       {                                                                     \
 
132
+         free (old_buf);                                                     \
 
133
+         return -1;                                                          \
 
134
+       }                                                                     \
 
135
     }
 
136
 
 
137
       /* The RUN_NLSPATH variable contains a colon separated list of
 
138
         descriptions where we expect to find catalogs.  We have to
 
139
         recognize certain % substitutions and stop when we found the
 
140
         first existing file.  */
 
141
-      char *buf;
 
142
       size_t bufact;
 
143
-      size_t bufmax;
 
144
+      size_t bufmax = 0;
 
145
       size_t len;
 
146
 
 
147
-      buf = NULL;
 
148
-      bufmax = 0;
 
149
-
 
150
       fd = -1;
 
151
       while (*run_nlspath != '\0')
 
152
        {
 
153
@@ -188,7 +189,10 @@ __open_catalog (const char *cat_name, co
 
154
 
 
155
   /* Avoid dealing with directories and block devices */
 
156
   if (__builtin_expect (fd, 0) < 0)
 
157
-    return -1;
 
158
+    {
 
159
+      free (buf);
 
160
+      return -1;
 
161
+    }
 
162
 
 
163
   if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
 
164
     goto close_unlock_return;
 
165
@@ -325,6 +329,7 @@ __open_catalog (const char *cat_name, co
 
166
   /* Release the lock again.  */
 
167
  close_unlock_return:
 
168
   close_not_cancel_no_status (fd);
 
169
+  free (buf);
 
170
 
 
171
   return result;
 
172
 }
 
173
Index: b/catgets/tst-catgets.c
 
174
===================================================================
 
175
--- a/catgets/tst-catgets.c
 
176
+++ b/catgets/tst-catgets.c
 
177
@@ -1,7 +1,10 @@
 
178
+#include <assert.h>
 
179
 #include <mcheck.h>
 
180
 #include <nl_types.h>
 
181
 #include <stdio.h>
 
182
+#include <stdlib.h>
 
183
 #include <string.h>
 
184
+#include <sys/resource.h>
 
185
 
 
186
 
 
187
 static const char *msgs[] =
 
188
@@ -12,6 +15,33 @@ static const char *msgs[] =
 
189
 };
 
190
 #define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
 
191
 
 
192
+
 
193
+/* Test for unbounded alloca.  */
 
194
+static int
 
195
+do_bz17905 (void)
 
196
+{
 
197
+  char *buf;
 
198
+  struct rlimit rl;
 
199
+  nl_catd result;
 
200
+
 
201
+  const int sz = 1024 * 1024;
 
202
+
 
203
+  getrlimit (RLIMIT_STACK, &rl);
 
204
+  rl.rlim_cur = sz;
 
205
+  setrlimit (RLIMIT_STACK, &rl);
 
206
+
 
207
+  buf = malloc (sz + 1); 
 
208
+  memset (buf, 'A', sz);
 
209
+  buf[sz] = '\0';
 
210
+  setenv ("NLSPATH", buf, 1);
 
211
+
 
212
+  result = catopen (buf, NL_CAT_LOCALE);
 
213
+  assert (result == (nl_catd) -1);
 
214
+
 
215
+  free (buf);
 
216
+  return 0;
 
217
+}
 
218
+
 
219
 #define ROUNDS 5
 
220
 
 
221
 int
 
222
@@ -62,5 +92,6 @@ main (void)
 
223
        }
 
224
     }
 
225
 
 
226
+  result += do_bz17905 ();
 
227
   return result;
 
228
 }