~ubuntu-branches/ubuntu/lucid/eglibc/lucid-security

« back to all changes in this revision

Viewing changes to debian/patches/any/CVE-2014-4043.diff

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2014-07-28 11:23:55 UTC
  • Revision ID: package-import@ubuntu.com-20140728112355-d1m3idnt2n38dzj1
Tags: 2.11.1-0ubuntu7.14
* SECURITY UPDATE: denial of service via buffer overflow in getaddrinfo
  - debian/patches/CVE-2013-4357.patch: fix overflow in include/alloca.h,
    nis/nss_nis/nis-alias.c, nscd/nscd_getserv_r.c, posix/glob.c,
    sysdeps/posix/getaddrinfo.c.
  - CVE-2013-4357
* SECURITY UPDATE: denial of service via buffer overflow in getaddrinfo
  - debian/patches/any/CVE-2013-4458.patch: fix overflow in
    sysdeps/posix/getaddrinfo.c.
  - CVE-2013-4458
* SECURITY UPDATE: Directory traversal in locale environment handling
  - debian/patches/any/CVE-2014-0475.diff: validate locale names in
    locale/findlocale.c, locale/setlocale.c, added test to
    localedata/tst-setlocale3.c, localedata/Makefile.
  - CVE-2014-0475
* SECURITY UPDATE: use-after-free via posix_spawn_file_actions_addopen
  failing to copy the path argument
  - debian/patches/any/CVE-2014-4043.diff: properly copy path in
    posix/spawn_faction_addopen.c, posix/spawn_faction_destroy.c,
    posix/spawn_int.h, added test to posix/tst-spawn.c.
  - CVE-2014-4043
* debian/patches/any/CVE-2013-4237-part2.diff: fix alignment issue
  causing a readdir regression on sparc.
* debian/patches/any/CVE-2013-4332-part2.diff: added a couple of extra
  commits to fix another overflow and an infinite loop.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: fix use-after-free via posix_spawn_file_actions_addopen
 
2
 failing to copy the path argument
 
3
Origin: backport, https://sourceware.org/git/?p=glibc.git;h=89e435f3559c53084498e9baad22172b64429362
 
4
Origin: backport, https://sourceware.org/git/?p=glibc.git;h=35a5e3e338ae17f3d42c60a708763c5d498fb840
 
5
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17048
 
6
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=751774
 
7
 
 
8
Index: eglibc-2.15/posix/spawn_faction_addopen.c
 
9
===================================================================
 
10
--- eglibc-2.15.orig/posix/spawn_faction_addopen.c      2006-08-16 21:18:26.000000000 -0400
 
11
+++ eglibc-2.15/posix/spawn_faction_addopen.c   2014-07-25 13:31:56.634828694 -0400
 
12
@@ -19,6 +19,7 @@
 
13
 #include <errno.h>
 
14
 #include <spawn.h>
 
15
 #include <unistd.h>
 
16
+#include <string.h>
 
17
 
 
18
 #include "spawn_int.h"
 
19
 
 
20
@@ -36,17 +37,24 @@
 
21
   if (fd < 0 || fd >= maxfd)
 
22
     return EBADF;
 
23
 
 
24
+  char *path_copy = strdup (path);
 
25
+  if (path_copy == NULL)
 
26
+    return ENOMEM;
 
27
+
 
28
   /* Allocate more memory if needed.  */
 
29
   if (file_actions->__used == file_actions->__allocated
 
30
       && __posix_spawn_file_actions_realloc (file_actions) != 0)
 
31
-    /* This can only mean we ran out of memory.  */
 
32
-    return ENOMEM;
 
33
+    {
 
34
+      /* This can only mean we ran out of memory.  */
 
35
+      free (path_copy);
 
36
+      return ENOMEM;
 
37
+    }
 
38
 
 
39
   /* Add the new value.  */
 
40
   rec = &file_actions->__actions[file_actions->__used];
 
41
   rec->tag = spawn_do_open;
 
42
   rec->action.open_action.fd = fd;
 
43
-  rec->action.open_action.path = path;
 
44
+  rec->action.open_action.path = path_copy;
 
45
   rec->action.open_action.oflag = oflag;
 
46
   rec->action.open_action.mode = mode;
 
47
 
 
48
Index: eglibc-2.15/posix/spawn_faction_destroy.c
 
49
===================================================================
 
50
--- eglibc-2.15.orig/posix/spawn_faction_destroy.c      2006-08-16 21:18:26.000000000 -0400
 
51
+++ eglibc-2.15/posix/spawn_faction_destroy.c   2014-07-25 13:31:56.638828694 -0400
 
52
@@ -19,11 +19,29 @@
 
53
 #include <spawn.h>
 
54
 #include <stdlib.h>
 
55
 
 
56
-/* Initialize data structure for file attribute for `spawn' call.  */
 
57
+#include "spawn_int.h"
 
58
+
 
59
+/* Deallocate the file actions.  */
 
60
 int
 
61
 posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions)
 
62
 {
 
63
-  /* Free the memory allocated.  */
 
64
+  /* Free the paths in the open actions.  */
 
65
+  for (int i = 0; i < file_actions->__used; ++i)
 
66
+    {
 
67
+      struct __spawn_action *sa = &file_actions->__actions[i];
 
68
+      switch (sa->tag)
 
69
+       {
 
70
+       case spawn_do_open:
 
71
+         free (sa->action.open_action.path);
 
72
+         break;
 
73
+       case spawn_do_close:
 
74
+       case spawn_do_dup2:
 
75
+         /* No cleanup required.  */
 
76
+         break;
 
77
+       }
 
78
+    }
 
79
+
 
80
+  /* Free the array of actions.  */
 
81
   free (file_actions->__actions);
 
82
   return 0;
 
83
 }
 
84
Index: eglibc-2.15/posix/spawn_int.h
 
85
===================================================================
 
86
--- eglibc-2.15.orig/posix/spawn_int.h  2011-09-06 11:08:18.000000000 -0400
 
87
+++ eglibc-2.15/posix/spawn_int.h       2014-07-25 13:31:56.638828694 -0400
 
88
@@ -22,7 +22,7 @@
 
89
     struct
 
90
     {
 
91
       int fd;
 
92
-      const char *path;
 
93
+      char *path;
 
94
       int oflag;
 
95
       mode_t mode;
 
96
     } open_action;
 
97
Index: eglibc-2.15/posix/tst-spawn.c
 
98
===================================================================
 
99
--- eglibc-2.15.orig/posix/tst-spawn.c  2006-08-26 17:52:38.000000000 -0400
 
100
+++ eglibc-2.15/posix/tst-spawn.c       2014-07-25 13:31:56.638828694 -0400
 
101
@@ -169,6 +169,7 @@
 
102
   char fd2name[18];
 
103
   char fd3name[18];
 
104
   char fd4name[18];
 
105
+  char *name3_copy;
 
106
   char *spargv[12];
 
107
 
 
108
   /* We must have
 
109
@@ -222,9 +223,15 @@
 
110
    if (posix_spawn_file_actions_addclose (&actions, fd1) != 0)
 
111
      error (EXIT_FAILURE, errno, "posix_spawn_file_actions_addclose");
 
112
    /* We want to open the third file.  */
 
113
-   if (posix_spawn_file_actions_addopen (&actions, fd3, name3,
 
114
+   name3_copy = strdup (name3);
 
115
+   if (name3_copy == NULL)
 
116
+     error (EXIT_FAILURE, errno, "strdup");
 
117
+   if (posix_spawn_file_actions_addopen (&actions, fd3, name3_copy,
 
118
                                         O_RDONLY, 0666) != 0)
 
119
      error (EXIT_FAILURE, errno, "posix_spawn_file_actions_addopen");
 
120
+   /* Overwrite the name to check that a copy has been made.  */
 
121
+   memset (name3_copy, 'X', strlen (name3_copy));
 
122
+
 
123
    /* We dup the second descriptor.  */
 
124
    fd4 = MAX (2, MAX (fd1, MAX (fd2, fd3))) + 1;
 
125
    if (posix_spawn_file_actions_adddup2 (&actions, fd2, fd4) != 0)
 
126
@@ -255,6 +262,7 @@
 
127
    /* Cleanup.  */
 
128
    if (posix_spawn_file_actions_destroy (&actions) != 0)
 
129
      error (EXIT_FAILURE, errno, "posix_spawn_file_actions_destroy");
 
130
+   free (name3_copy);
 
131
 
 
132
   /* Wait for the child.  */
 
133
   if (waitpid (pid, &status, 0) != pid)