Fixes for the following CVEs
1. CVE-2018-11236
2. CVE-2018-11237
Change-Id: I58a1f79a79f2af19802fdd02738fa831f63315f0
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5302
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Alexey Makhalov <amakhalov@vmware.com>
Reviewed-by: Dweep Advani <dadvani@vmware.com>
Reviewed-by: Sharath George
| 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 |
+@@ -80,7 +80,7 @@ tests := tst-strtol tst-strtod testmb testrand testsort testdiv \ |
|
| 30 |
+ tst-strtol-locale tst-strtod-nan-locale tst-strfmon_l \ |
|
| 31 |
+ tst-quick_exit tst-thread-quick_exit tst-width \ |
|
| 32 |
+ tst-width-stdint tst-strfrom tst-strfrom-locale \ |
|
| 33 |
+- tst-getrandom |
|
| 34 |
++ tst-getrandom test-bz22786 |
|
| 35 |
+ tests-internal := tst-strtod1i tst-strtod3 tst-strtod4 tst-strtod5i \ |
|
| 36 |
+ tst-tls-atexit tst-tls-atexit-nodelete |
|
| 37 |
+ tests-static := tst-secure-getenv |
|
| 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 |
| 0 | 147 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,117 @@ |
| 0 |
+From 9aaaab7c6e4176e61c59b0a63c6ba906d875dc0e Mon Sep 17 00:00:00 2001 |
|
| 1 |
+From: Andreas Schwab <schwab@suse.de> |
|
| 2 |
+Date: Tue, 22 May 2018 10:37:59 +0200 |
|
| 3 |
+Subject: [PATCH] Don't write beyond destination in |
|
| 4 |
+ __mempcpy_avx512_no_vzeroupper (bug 23196) |
|
| 5 |
+ |
|
| 6 |
+When compiled as mempcpy, the return value is the end of the destination |
|
| 7 |
+buffer, thus it cannot be used to refer to the start of it. |
|
| 8 |
+--- |
|
| 9 |
+ ChangeLog | 9 +++++++++ |
|
| 10 |
+ string/test-mempcpy.c | 1 + |
|
| 11 |
+ sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S | 5 +++-- |
|
| 12 |
+ 3 files changed, 13 insertions(+), 2 deletions(-) |
|
| 13 |
+ |
|
| 14 |
+diff --git a/string/test-mempcpy.c b/string/test-mempcpy.c |
|
| 15 |
+index c08fba8..d98ecdd 100644 |
|
| 16 |
+--- a/string/test-mempcpy.c |
|
| 17 |
+@@ -18,6 +18,7 @@ |
|
| 18 |
+ <http://www.gnu.org/licenses/>. */ |
|
| 19 |
+ |
|
| 20 |
+ #define MEMCPY_RESULT(dst, len) (dst) + (len) |
|
| 21 |
++#define MIN_PAGE_SIZE 131072 |
|
| 22 |
+ #define TEST_MAIN |
|
| 23 |
+ #define TEST_NAME "mempcpy" |
|
| 24 |
+ #include "test-string.h" |
|
| 25 |
+diff --git a/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S b/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S |
|
| 26 |
+index 23c0f7a..effc3ac 100644 |
|
| 27 |
+--- a/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S |
|
| 28 |
+@@ -336,6 +336,7 @@ L(preloop_large): |
|
| 29 |
+ vmovups (%rsi), %zmm4 |
|
| 30 |
+ vmovups 0x40(%rsi), %zmm5 |
|
| 31 |
+ |
|
| 32 |
++ mov %rdi, %r11 |
|
| 33 |
+ /* Align destination for access with non-temporal stores in the loop. */ |
|
| 34 |
+ mov %rdi, %r8 |
|
| 35 |
+ and $-0x80, %rdi |
|
| 36 |
+@@ -366,8 +367,8 @@ L(gobble_256bytes_nt_loop): |
|
| 37 |
+ cmp $256, %rdx |
|
| 38 |
+ ja L(gobble_256bytes_nt_loop) |
|
| 39 |
+ sfence |
|
| 40 |
+- vmovups %zmm4, (%rax) |
|
| 41 |
+- vmovups %zmm5, 0x40(%rax) |
|
| 42 |
++ vmovups %zmm4, (%r11) |
|
| 43 |
++ vmovups %zmm5, 0x40(%r11) |
|
| 44 |
+ jmp L(check) |
|
| 45 |
+ |
|
| 46 |
+ L(preloop_large_bkw): |
|
| 47 |
+ |
|
| 48 |
+diff --git a/string/test-memcpy.c b/string/test-memcpy.c |
|
| 49 |
+index 45f20a6..3c8066d 100644 |
|
| 50 |
+--- a/string/test-memcpy.c |
|
| 51 |
+@@ -212,6 +212,50 @@ do_random_tests (void) |
|
| 52 |
+ } |
|
| 53 |
+ } |
|
| 54 |
+ |
|
| 55 |
++static void |
|
| 56 |
++do_test1 (void) |
|
| 57 |
++{
|
|
| 58 |
++ size_t size = 0x100000; |
|
| 59 |
++ void *large_buf; |
|
| 60 |
++ |
|
| 61 |
++ large_buf = mmap (NULL, size * 2 + page_size, PROT_READ | PROT_WRITE, |
|
| 62 |
++ MAP_PRIVATE | MAP_ANON, -1, 0); |
|
| 63 |
++ if (large_buf == MAP_FAILED) |
|
| 64 |
++ {
|
|
| 65 |
++ puts ("Failed to allocat large_buf, skipping do_test1");
|
|
| 66 |
++ return; |
|
| 67 |
++ } |
|
| 68 |
++ |
|
| 69 |
++ if (mprotect (large_buf + size, page_size, PROT_NONE)) |
|
| 70 |
++ error (EXIT_FAILURE, errno, "mprotect failed"); |
|
| 71 |
++ |
|
| 72 |
++ size_t arrary_size = size / sizeof (uint32_t); |
|
| 73 |
++ uint32_t *dest = large_buf; |
|
| 74 |
++ uint32_t *src = large_buf + size + page_size; |
|
| 75 |
++ size_t i; |
|
| 76 |
++ |
|
| 77 |
++ for (i = 0; i < arrary_size; i++) |
|
| 78 |
++ src[i] = (uint32_t) i; |
|
| 79 |
++ |
|
| 80 |
++ FOR_EACH_IMPL (impl, 0) |
|
| 81 |
++ {
|
|
| 82 |
++ memset (dest, -1, size); |
|
| 83 |
++ CALL (impl, (char *) dest, (char *) src, size); |
|
| 84 |
++ for (i = 0; i < arrary_size; i++) |
|
| 85 |
++ if (dest[i] != src[i]) |
|
| 86 |
++ {
|
|
| 87 |
++ error (0, 0, |
|
| 88 |
++ "Wrong result in function %s dst \"%p\" src \"%p\" offset \"%zd\"", |
|
| 89 |
++ impl->name, dest, src, i); |
|
| 90 |
++ ret = 1; |
|
| 91 |
++ break; |
|
| 92 |
++ } |
|
| 93 |
++ } |
|
| 94 |
++ |
|
| 95 |
++ munmap ((void *) dest, size); |
|
| 96 |
++ munmap ((void *) src, size); |
|
| 97 |
++} |
|
| 98 |
++ |
|
| 99 |
+ int |
|
| 100 |
+ test_main (void) |
|
| 101 |
+ {
|
|
| 102 |
+@@ -253,6 +297,9 @@ test_main (void) |
|
| 103 |
+ do_test (0, 0, getpagesize ()); |
|
| 104 |
+ |
|
| 105 |
+ do_random_tests (); |
|
| 106 |
++ |
|
| 107 |
++ do_test1 (); |
|
| 108 |
++ |
|
| 109 |
+ return ret; |
|
| 110 |
+ } |
|
| 111 |
+ |
|
| 112 |
+-- |
|
| 113 |
+2.9.3 |
| ... | ... |
@@ -4,7 +4,7 @@ |
| 4 | 4 |
Summary: Main C library |
| 5 | 5 |
Name: glibc |
| 6 | 6 |
Version: 2.26 |
| 7 |
-Release: 12%{?dist}
|
|
| 7 |
+Release: 13%{?dist}
|
|
| 8 | 8 |
License: LGPLv2+ |
| 9 | 9 |
URL: http://www.gnu.org/software/libc |
| 10 | 10 |
Group: Applications/System |
| ... | ... |
@@ -26,6 +26,8 @@ Patch8: glibc-fix-CVE-2018-1000001.patch |
| 26 | 26 |
Patch9: glibc-fix-CVE-2018-6485.patch |
| 27 | 27 |
Patch10: glibc-fix-CVE-2017-15671.patch |
| 28 | 28 |
Patch11: glibc-fix-CVE-2017-18269.patch |
| 29 |
+Patch12: glibc-fix-CVE-2018-11236.patch |
|
| 30 |
+Patch13: glibc-fix-CVE-2018-11237.patch |
|
| 29 | 31 |
Provides: rtld(GNU_HASH) |
| 30 | 32 |
Requires: filesystem |
| 31 | 33 |
%description |
| ... | ... |
@@ -91,6 +93,8 @@ sed -i 's/\\$$(pwd)/`pwd`/' timezone/Makefile |
| 91 | 91 |
%patch9 -p1 |
| 92 | 92 |
%patch10 -p1 |
| 93 | 93 |
%patch11 -p1 |
| 94 |
+%patch12 -p1 |
|
| 95 |
+%patch13 -p1 |
|
| 94 | 96 |
|
| 95 | 97 |
install -vdm 755 %{_builddir}/%{name}-build
|
| 96 | 98 |
# do not try to explicitly provide GLIBC_PRIVATE versioned libraries |
| ... | ... |
@@ -295,6 +299,8 @@ grep "^FAIL: nptl/tst-eintr1" tests.sum >/dev/null && n=$((n+1)) ||: |
| 295 | 295 |
|
| 296 | 296 |
|
| 297 | 297 |
%changelog |
| 298 |
+* Tue Jun 26 2018 Keerthana K <keerthanak@vmware.com> 2.26-13 |
|
| 299 |
+- Fix for CVE-2018-11236, CVE-2018-11237. |
|
| 298 | 300 |
* Mon Jun 25 2018 Keerthana K <keerthanak@vmware.com> 2.26-12 |
| 299 | 301 |
- Fix for CVE-2017-18269. |
| 300 | 302 |
* Tue Jun 19 2018 Dweep Advani <dadvani@vmware.com> 2.26-11 |