Change-Id: I6f47f4be0a1b2ae8cca23557c81c3e12760177d9
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5301
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Dweep Advani <dadvani@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,150 @@ |
0 |
+From af7519f7b35024224c163e32a89fb247b0c446fc Mon Sep 17 00:00:00 2001 |
|
1 |
+From: Paul Pluzhnikov <ppluzhnikov@google.com> |
|
2 |
+Date: Tue, 8 May 2018 18:12:41 -0700 |
|
3 |
+Subject: [PATCH] Fix path length overflow in realpath [BZ #22786] |
|
4 |
+ |
|
5 |
+Integer addition overflow may cause stack buffer overflow |
|
6 |
+when realpath() input length is close to SSIZE_MAX. |
|
7 |
+ |
|
8 |
+2018-05-09 Paul Pluzhnikov <ppluzhnikov@google.com> |
|
9 |
+ |
|
10 |
+ [BZ #22786] |
|
11 |
+ * stdlib/canonicalize.c (__realpath): Fix overflow in path length |
|
12 |
+ computation. |
|
13 |
+ * stdlib/Makefile (test-bz22786): New test. |
|
14 |
+ * stdlib/test-bz22786.c: New test. |
|
15 |
+ |
|
16 |
+(cherry picked from commit 5460617d1567657621107d895ee2dd83bc1f88f2) |
|
17 |
+--- |
|
18 |
+ ChangeLog | 8 +++++ |
|
19 |
+ NEWS | 1 + |
|
20 |
+ stdlib/Makefile | 2 +- |
|
21 |
+ stdlib/canonicalize.c | 2 +- |
|
22 |
+ stdlib/test-bz22786.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
23 |
+ 5 files changed, 101 insertions(+), 2 deletions(-) |
|
24 |
+ create mode 100644 stdlib/test-bz22786.c |
|
25 |
+ |
|
26 |
+diff --git a/stdlib/Makefile b/stdlib/Makefile |
|
27 |
+index 0314d59..5cdc910 100644 |
|
28 |
+--- a/stdlib/Makefile |
|
29 |
+@@ -76,7 +76,7 @@ |
|
30 |
+ tst-secure-getenv tst-strtod-overflow tst-strtod-round \ |
|
31 |
+ tst-tininess tst-strtod-underflow tst-tls-atexit \ |
|
32 |
+ tst-setcontext3 tst-tls-atexit-nodelete \ |
|
33 |
+- tst-strtol-locale tst-strtod-nan-locale |
|
34 |
++ tst-strtol-locale tst-strtod-nan-locale test-bz22786 |
|
35 |
+ tests-static := tst-secure-getenv |
|
36 |
+ |
|
37 |
+ modules-names = tst-tls-atexit-lib |
|
38 |
+diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c |
|
39 |
+index c3d892c..a497d06 100644 |
|
40 |
+--- a/stdlib/canonicalize.c |
|
41 |
+@@ -181,7 +181,7 @@ __realpath (const char *name, char *resolved) |
|
42 |
+ extra_buf = __alloca (path_max); |
|
43 |
+ |
|
44 |
+ len = strlen (end); |
|
45 |
+- if ((long int) (n + len) >= path_max) |
|
46 |
++ if (path_max - n <= len) |
|
47 |
+ { |
|
48 |
+ __set_errno (ENAMETOOLONG); |
|
49 |
+ goto error; |
|
50 |
+diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c |
|
51 |
+new file mode 100644 |
|
52 |
+index 0000000..e7837f9 |
|
53 |
+--- /dev/null |
|
54 |
+@@ -0,0 +1,90 @@ |
|
55 |
++/* Bug 22786: test for buffer overflow in realpath. |
|
56 |
++ Copyright (C) 2018 Free Software Foundation, Inc. |
|
57 |
++ This file is part of the GNU C Library. |
|
58 |
++ |
|
59 |
++ The GNU C Library is free software; you can redistribute it and/or |
|
60 |
++ modify it under the terms of the GNU Lesser General Public |
|
61 |
++ License as published by the Free Software Foundation; either |
|
62 |
++ version 2.1 of the License, or (at your option) any later version. |
|
63 |
++ |
|
64 |
++ The GNU C Library is distributed in the hope that it will be useful, |
|
65 |
++ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
66 |
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
67 |
++ Lesser General Public License for more details. |
|
68 |
++ |
|
69 |
++ You should have received a copy of the GNU Lesser General Public |
|
70 |
++ License along with the GNU C Library; if not, see |
|
71 |
++ <http://www.gnu.org/licenses/>. */ |
|
72 |
++ |
|
73 |
++/* This file must be run from within a directory called "stdlib". */ |
|
74 |
++ |
|
75 |
++#include <errno.h> |
|
76 |
++#include <limits.h> |
|
77 |
++#include <stdio.h> |
|
78 |
++#include <stdlib.h> |
|
79 |
++#include <string.h> |
|
80 |
++#include <unistd.h> |
|
81 |
++#include <sys/stat.h> |
|
82 |
++#include <sys/types.h> |
|
83 |
++#include <support/test-driver.h> |
|
84 |
++#include <libc-diag.h> |
|
85 |
++ |
|
86 |
++static int |
|
87 |
++do_test (void) |
|
88 |
++{ |
|
89 |
++ const char dir[] = "bz22786"; |
|
90 |
++ const char lnk[] = "bz22786/symlink"; |
|
91 |
++ |
|
92 |
++ rmdir (dir); |
|
93 |
++ if (mkdir (dir, 0755) != 0 && errno != EEXIST) |
|
94 |
++ { |
|
95 |
++ printf ("mkdir %s: %m\n", dir); |
|
96 |
++ return EXIT_FAILURE; |
|
97 |
++ } |
|
98 |
++ if (symlink (".", lnk) != 0 && errno != EEXIST) |
|
99 |
++ { |
|
100 |
++ printf ("symlink (%s, %s): %m\n", dir, lnk); |
|
101 |
++ return EXIT_FAILURE; |
|
102 |
++ } |
|
103 |
++ |
|
104 |
++ const size_t path_len = (size_t) INT_MAX + 1; |
|
105 |
++ |
|
106 |
++ DIAG_PUSH_NEEDS_COMMENT; |
|
107 |
++#if __GNUC_PREREQ (7, 0) |
|
108 |
++ /* GCC 7 warns about too-large allocations; here we need such |
|
109 |
++ allocation to succeed for the test to work. */ |
|
110 |
++ DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than="); |
|
111 |
++#endif |
|
112 |
++ char *path = malloc (path_len); |
|
113 |
++ DIAG_POP_NEEDS_COMMENT; |
|
114 |
++ |
|
115 |
++ if (path == NULL) |
|
116 |
++ { |
|
117 |
++ printf ("malloc (%zu): %m\n", path_len); |
|
118 |
++ return EXIT_UNSUPPORTED; |
|
119 |
++ } |
|
120 |
++ |
|
121 |
++ /* Construct very long path = "bz22786/symlink/aaaa....." */ |
|
122 |
++ char *p = mempcpy (path, lnk, sizeof (lnk) - 1); |
|
123 |
++ *(p++) = '/'; |
|
124 |
++ memset (p, 'a', path_len - (path - p) - 2); |
|
125 |
++ p[path_len - (path - p) - 1] = '\0'; |
|
126 |
++ |
|
127 |
++ /* This call crashes before the fix for bz22786 on 32-bit platforms. */ |
|
128 |
++ p = realpath (path, NULL); |
|
129 |
++ |
|
130 |
++ if (p != NULL || errno != ENAMETOOLONG) |
|
131 |
++ { |
|
132 |
++ printf ("realpath: %s (%m)", p); |
|
133 |
++ return EXIT_FAILURE; |
|
134 |
++ } |
|
135 |
++ |
|
136 |
++ /* Cleanup. */ |
|
137 |
++ unlink (lnk); |
|
138 |
++ rmdir (dir); |
|
139 |
++ |
|
140 |
++ return 0; |
|
141 |
++} |
|
142 |
++ |
|
143 |
++#define TEST_FUNCTION do_test |
|
144 |
++#include <support/test-driver.c> |
|
145 |
+-- |
|
146 |
+2.9.3 |
... | ... |
@@ -6,7 +6,7 @@ |
6 | 6 |
Summary: Main C library |
7 | 7 |
Name: glibc |
8 | 8 |
Version: 2.22 |
9 |
-Release: 20%{?dist} |
|
9 |
+Release: 21%{?dist} |
|
10 | 10 |
License: LGPLv2+ |
11 | 11 |
URL: http://www.gnu.org/software/libc |
12 | 12 |
Group: Applications/System |
... | ... |
@@ -49,6 +49,7 @@ Patch21: glibc-fix-CVE-2017-16997.patch |
49 | 49 |
Patch22: glibc-fix-CVE-2018-1000001.patch |
50 | 50 |
Patch23: glibc-fix-CVE-2018-6485.patch |
51 | 51 |
Patch24: glibc-fix-CVE-2017-18269.patch |
52 |
+Patch25: glibc-fix-CVE-2018-11236.patch |
|
52 | 53 |
Provides: rtld(GNU_HASH) |
53 | 54 |
Requires: filesystem |
54 | 55 |
%description |
... | ... |
@@ -99,6 +100,8 @@ sed -i 's/\\$$(pwd)/`pwd`/' timezone/Makefile |
99 | 99 |
%patch22 -p1 |
100 | 100 |
%patch23 -p1 |
101 | 101 |
%patch24 -p1 |
102 |
+%patch25 -p1 |
|
103 |
+ |
|
102 | 104 |
install -vdm 755 %{_builddir}/%{name}-build |
103 | 105 |
# do not try to explicitly provide GLIBC_PRIVATE versioned libraries |
104 | 106 |
%define __find_provides %{_builddir}/%{name}-%{version}/find_provides.sh |
... | ... |
@@ -225,6 +228,8 @@ popd |
225 | 225 |
%{_datarootdir}/locale/locale.alias |
226 | 226 |
|
227 | 227 |
%changelog |
228 |
+* Tue Jun 26 2018 Keerthana K <keerthnanak@vmware.com> 2.22-21 |
|
229 |
+- Fix for CVE-2018-11236. |
|
228 | 230 |
* Mon Jun 25 2018 Keerthana K <keerthanak@vmware.com> 2.22-20 |
229 | 231 |
- Fix for CVE-2017-18269. |
230 | 232 |
* Tue Jan 20 2018 Xiaolin Li <xiaolinl@vmware.com> 2.22-19 |