From 972dcfcdbfe75dcfeb777150c136576cf1a71e99 Mon Sep 17 00:00:00 2001 From: Tudor Florea Date: Fri, 9 Oct 2015 22:59:03 +0200 Subject: initial commit for Enea Linux 5.0 arm Signed-off-by: Tudor Florea --- .../grep/grep-2.19/grep2.19-CVE-2015-1345.patch | 129 +++++++++++++++++++++ meta/recipes-extended/grep/grep-2.5.1a/Makevars | 25 ++++ .../grep/grep-2.5.1a/fix-for-texinfo-5.1.patch | 17 +++ .../grep/grep-2.5.1a/fix64-int-to-pointer.patch | 17 +++ .../grep/grep-2.5.1a/gettext.patch | 15 +++ .../grep/grep-2.5.1a/grep-CVE-2012-5667.patch | 32 +++++ .../grep-2.5.1a/grep_fix_for_automake-1.12.patch | 52 +++++++++ .../grep/grep-2.5.1a/uclibc-fix.patch | 55 +++++++++ meta/recipes-extended/grep/grep_2.19.bb | 41 +++++++ meta/recipes-extended/grep/grep_2.5.1a.bb | 51 ++++++++ 10 files changed, 434 insertions(+) create mode 100644 meta/recipes-extended/grep/grep-2.19/grep2.19-CVE-2015-1345.patch create mode 100644 meta/recipes-extended/grep/grep-2.5.1a/Makevars create mode 100644 meta/recipes-extended/grep/grep-2.5.1a/fix-for-texinfo-5.1.patch create mode 100644 meta/recipes-extended/grep/grep-2.5.1a/fix64-int-to-pointer.patch create mode 100644 meta/recipes-extended/grep/grep-2.5.1a/gettext.patch create mode 100644 meta/recipes-extended/grep/grep-2.5.1a/grep-CVE-2012-5667.patch create mode 100644 meta/recipes-extended/grep/grep-2.5.1a/grep_fix_for_automake-1.12.patch create mode 100644 meta/recipes-extended/grep/grep-2.5.1a/uclibc-fix.patch create mode 100644 meta/recipes-extended/grep/grep_2.19.bb create mode 100644 meta/recipes-extended/grep/grep_2.5.1a.bb (limited to 'meta/recipes-extended/grep') diff --git a/meta/recipes-extended/grep/grep-2.19/grep2.19-CVE-2015-1345.patch b/meta/recipes-extended/grep/grep-2.19/grep2.19-CVE-2015-1345.patch new file mode 100644 index 0000000000..32846f50be --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.19/grep2.19-CVE-2015-1345.patch @@ -0,0 +1,129 @@ +From 83a95bd8c8561875b948cadd417c653dbe7ef2e2 Mon Sep 17 00:00:00 2001 +From: Yuliy Pisetsky +Date: Thu, 01 Jan 2015 23:36:55 +0000 +Subject: grep -F: fix a heap buffer (read) overrun + +grep's read buffer is often filled to its full size, except when +reading the final buffer of a file. In that case, the number of +bytes read may be far less than the size of the buffer. However, for +certain unusual pattern/text combinations, grep -F would mistakenly +examine bytes in that uninitialized region of memory when searching +for a match. With carefully chosen inputs, one can cause grep -F to +read beyond the end of that buffer altogether. This problem arose via +commit v2.18-90-g73893ff with the introduction of a more efficient +heuristic using what is now the memchr_kwset function. The use of +that function in bmexec_trans could leave TP much larger than EP, +and the subsequent call to bm_delta2_search would mistakenly access +beyond end of the main input read buffer. + +* src/kwset.c (bmexec_trans): When TP reaches or exceeds EP, +do not call bm_delta2_search. +* tests/kwset-abuse: New file. +* tests/Makefile.am (TESTS): Add it. +* NEWS (Bug fixes): Mention it. + +Prior to this patch, this command would trigger a UMR: + + printf %0360db 0 | valgrind src/grep -F $(printf %019dXb 0) + + Use of uninitialised value of size 8 + at 0x4142BE: bmexec_trans (kwset.c:657) + by 0x4143CA: bmexec (kwset.c:678) + by 0x414973: kwsexec (kwset.c:848) + by 0x414DC4: Fexecute (kwsearch.c:128) + by 0x404E2E: grepbuf (grep.c:1238) + by 0x4054BF: grep (grep.c:1417) + by 0x405CEB: grepdesc (grep.c:1645) + by 0x405EC1: grep_command_line_arg (grep.c:1692) + by 0x4077D4: main (grep.c:2570) + +See the accompanying test for how to trigger the heap buffer overrun. + +Thanks to Nima Aghdaii for testing and finding numerous +ways to break early iterations of this patch. + +Fixes CVE-2015-1345. +Upstream-Status: Backport + +--- +diff --git a/NEWS b/NEWS +index 975440d..3835d8d 100644 +--- a/NEWS ++++ b/NEWS +@@ -2,6 +2,11 @@ GNU grep NEWS -*- outline -*- + + * Noteworthy changes in release ?.? (????-??-??) [?] + ++** Bug fixes ++ ++ grep no longer reads from uninitialized memory or from beyond the end ++ of the heap-allocated input buffer. ++ + + * Noteworthy changes in release 2.21 (2014-11-23) [stable] + +diff --git a/src/kwset.c b/src/kwset.c +index 4003c8d..376f7c3 100644 +--- a/src/kwset.c ++++ b/src/kwset.c +@@ -643,6 +643,8 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size) + if (! tp) + return -1; + tp++; ++ if (ep <= tp) ++ break; + } + } + } +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 2cba2cd..0508cd2 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -75,6 +75,7 @@ TESTS = \ + inconsistent-range \ + invalid-multibyte-infloop \ + khadafy \ ++ kwset-abuse \ + long-line-vs-2GiB-read \ + match-lines \ + max-count-overread \ +diff --git a/tests/kwset-abuse b/tests/kwset-abuse +new file mode 100755 +index 0000000..6d8ec0c +--- a/dev/null ++++ b/tests/kwset-abuse +@@ -0,0 +1,32 @@ ++#! /bin/sh ++# Evoke a segfault in a hard-to-reach code path of kwset.c. ++# This bug affected grep versions 2.19 through 2.21. ++# ++# Copyright (C) 2015 Free Software Foundation, Inc. ++# ++# This program is free software: you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation, either version 3 of the License, or ++# (at your option) any later version. ++ ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++ ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../src ++ ++fail=0 ++ ++# This test case chooses a haystack of size 260,000, since prodding ++# with gdb showed a reallocation slightly larger than that in fillbuf. ++# To reach the buggy code, the needle must have length < 1/11 that of ++# the haystack, and 10,000 is a nice round number that fits the bill. ++printf '%0260000dXy\n' 0 | grep -F $(printf %010000dy 0) ++ ++test $? = 1 || fail=1 ++ ++Exit $fail +-- +cgit v0.9.0.2 diff --git a/meta/recipes-extended/grep/grep-2.5.1a/Makevars b/meta/recipes-extended/grep/grep-2.5.1a/Makevars new file mode 100644 index 0000000000..8b09f53b0f --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.5.1a/Makevars @@ -0,0 +1,25 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Free Software Foundation, Inc. + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = diff --git a/meta/recipes-extended/grep/grep-2.5.1a/fix-for-texinfo-5.1.patch b/meta/recipes-extended/grep/grep-2.5.1a/fix-for-texinfo-5.1.patch new file mode 100644 index 0000000000..5a4149cfc0 --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.5.1a/fix-for-texinfo-5.1.patch @@ -0,0 +1,17 @@ +Upstream-Status: Inappropriate [Poky Specific this is gplv2 version] + +Signed-off-by Saul Wold + +Index: grep-2.5.1a/doc/grep.texi +=================================================================== +--- grep-2.5.1a.orig/doc/grep.texi ++++ grep-2.5.1a/doc/grep.texi +@@ -288,7 +288,7 @@ This version number should be included i + Print a usage message briefly summarizing these command-line options + and the bug-reporting address, then exit. + +-@itemx --binary-files=@var{type} ++@item --binary-files=@var{type} + @opindex --binary-files + @cindex binary files + If the first few bytes of a file indicate that the file contains binary diff --git a/meta/recipes-extended/grep/grep-2.5.1a/fix64-int-to-pointer.patch b/meta/recipes-extended/grep/grep-2.5.1a/fix64-int-to-pointer.patch new file mode 100644 index 0000000000..3b91520fb2 --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.5.1a/fix64-int-to-pointer.patch @@ -0,0 +1,17 @@ +Always use locale.h as HAVE_LOCALE_H is no longer handled by ./configure +Upstream-Status: Inappropriate [ old version that will not be maintained ] +Signed-off-by: Alex DAMIAN + +diff --recursive --unified grep-2.5.1a-orig/lib/hard-locale.c grep-2.5.1a/lib/hard-locale.c +--- grep-2.5.1a-orig/lib/hard-locale.c 2001-03-04 07:33:12.000000000 +0200 ++++ grep-2.5.1a/lib/hard-locale.c 2013-03-11 17:05:52.086444891 +0200 +@@ -38,9 +38,7 @@ + # endif + #endif + +-#if HAVE_LOCALE_H + # include +-#endif + + #if HAVE_STRING_H + # include diff --git a/meta/recipes-extended/grep/grep-2.5.1a/gettext.patch b/meta/recipes-extended/grep/grep-2.5.1a/gettext.patch new file mode 100644 index 0000000000..57463355a7 --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.5.1a/gettext.patch @@ -0,0 +1,15 @@ +Enable operation with later versions of gettext. + +Upstream-Status: Inappropriate +RP 2012/10/19 + +Index: grep-2.5.1a/configure.in +=================================================================== +--- grep-2.5.1a.orig/configure.in 2012-10-19 12:57:51.646970204 +0000 ++++ grep-2.5.1a/configure.in 2012-10-19 12:59:49.946968803 +0000 +@@ -140,4 +140,4 @@ + AC_CHECK_LIB(pcre, pcre_exec) + fi + +-AC_OUTPUT(Makefile lib/Makefile lib/posix/Makefile src/Makefile tests/Makefile po/Makefile.in intl/Makefile doc/Makefile m4/Makefile vms/Makefile bootstrap/Makefile, [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile; echo timestamp > stamp-h]) ++AC_OUTPUT(Makefile lib/Makefile lib/posix/Makefile src/Makefile tests/Makefile po/Makefile.in intl/Makefile doc/Makefile m4/Makefile vms/Makefile bootstrap/Makefile, [echo timestamp > stamp-h]) diff --git a/meta/recipes-extended/grep/grep-2.5.1a/grep-CVE-2012-5667.patch b/meta/recipes-extended/grep/grep-2.5.1a/grep-CVE-2012-5667.patch new file mode 100644 index 0000000000..059d0687b3 --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.5.1a/grep-CVE-2012-5667.patch @@ -0,0 +1,32 @@ +The patch to fix CVE-2012-5667 +Reference: https://bugzilla.redhat.com/attachment.cgi?id=686605&action=diff + +Multiple integer overflows in GNU Grep before 2.11 might allow +context-dependent attackers to execute arbitrary code via vectors +involving a long input line that triggers a heap-based buffer overflow. + +http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-5667 + +Upstream-Status: Inappropriate [other] +This version of GNU Grep has been abandoned upstream and they are no longer +accepting patches. This is not a backport. + +Signed-off-by Ming Liu +--- + grep.c | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +--- a/src/grep.c 2013-05-15 13:39:33.359191769 +0800 ++++ a/src/grep.c 2013-05-15 13:50:22.609191882 +0800 +@@ -306,6 +306,11 @@ fillbuf (size_t save, struct stats const + int cc = 1; + char *readbuf; + size_t readsize; ++ const size_t max_save = INT_MAX / 2; ++ ++ /* Limit the amount of saved data to INT_MAX to fix CVE-2012-5667 */ ++ if (save > max_save) ++ error (2, 0, _("line too long")); + + /* Offset from start of buffer to start of old stuff + that we want to save. */ diff --git a/meta/recipes-extended/grep/grep-2.5.1a/grep_fix_for_automake-1.12.patch b/meta/recipes-extended/grep/grep-2.5.1a/grep_fix_for_automake-1.12.patch new file mode 100644 index 0000000000..3ccce5fc36 --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.5.1a/grep_fix_for_automake-1.12.patch @@ -0,0 +1,52 @@ +Upstream-Status: Pending + +automake 1.12 has depricated automatic de-ANSI-fication support + +this patch avoids these kinds of errors: + +| configure.in:33: error: automatic de-ANSI-fication support has been removed +| /srv/home/nitin/builds/build-gcc47/tmp/sysroots/x86_64-linux/usr/share/aclocal-1.12/protos.m4:12: AM_C_PROTOTYPES is expanded from... +| configure.in:33: the top level +| autom4te: m4 failed with exit status: 1 +... +| lib/Makefile.am:2: error: automatic de-ANSI-fication support has been removed +| src/Makefile.am:2: error: automatic de-ANSI-fication support has been removed +| autoreconf: automake failed with exit status: 1 + +Signed-Off-By: Nitin A Kamble +2012/05/04 + +Index: grep-2.5.1a/configure.in +=================================================================== +--- grep-2.5.1a.orig/configure.in ++++ grep-2.5.1a/configure.in +@@ -30,7 +30,6 @@ AC_PROG_RANLIB + + dnl Checks for typedefs, structures, and compiler characteristics. + AC_SYS_LARGEFILE +-AM_C_PROTOTYPES + AC_TYPE_SIZE_T + AC_CHECK_TYPE(ssize_t, int) + AC_C_CONST +Index: grep-2.5.1a/lib/Makefile.am +=================================================================== +--- grep-2.5.1a.orig/lib/Makefile.am ++++ grep-2.5.1a/lib/Makefile.am +@@ -1,5 +1,5 @@ + # +-AUTOMAKE_OPTIONS = ../src/ansi2knr ++AUTOMAKE_OPTIONS = + + SUBDIRS = posix + +Index: grep-2.5.1a/src/Makefile.am +=================================================================== +--- grep-2.5.1a.orig/src/Makefile.am ++++ grep-2.5.1a/src/Makefile.am +@@ -1,5 +1,5 @@ + ## Process this file with automake to create Makefile.in +-AUTOMAKE_OPTIONS = ansi2knr no-dependencies ++AUTOMAKE_OPTIONS = no-dependencies + + LN = ln + diff --git a/meta/recipes-extended/grep/grep-2.5.1a/uclibc-fix.patch b/meta/recipes-extended/grep/grep-2.5.1a/uclibc-fix.patch new file mode 100644 index 0000000000..de054fc755 --- /dev/null +++ b/meta/recipes-extended/grep/grep-2.5.1a/uclibc-fix.patch @@ -0,0 +1,55 @@ +Upstream-Status: Inappropriate [licensing] + +# Fix to use mempcpy instead of __mempcpy. This is needed for uclibc which +# doesn't define __mempcpy, only mempcpy. Since both uclibc and glibc have +# mempcpy, we'll just use that instead. +# Patch source: OpenEmbedded + +Index: grep-2.5.1/intl/localealias.c +=================================================================== +--- grep-2.5.1.orig/intl/localealias.c 2002-03-14 00:39:06.000000000 +1100 ++++ grep-2.5.1/intl/localealias.c 2007-05-17 13:53:58.000000000 +1000 +@@ -65,7 +65,7 @@ + # define strcasecmp __strcasecmp + + # ifndef mempcpy +-# define mempcpy __mempcpy ++# error "mempcpy not detected" + # endif + # define HAVE_MEMPCPY 1 + # define HAVE___FSETLOCKING 1 +Index: grep-2.5.1/lib/getopt.c +=================================================================== +--- grep-2.5.1.orig/lib/getopt.c 2001-03-04 16:33:12.000000000 +1100 ++++ grep-2.5.1/lib/getopt.c 2007-05-17 13:51:44.000000000 +1000 +@@ -326,7 +326,7 @@ + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { +- memset (__mempcpy (new_str, __getopt_nonoption_flags, ++ memset (mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; +@@ -437,7 +437,7 @@ + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else +- memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), ++ memset (mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } +Index: grep-2.5.1/lib/regex.c +=================================================================== +--- grep-2.5.1.orig/lib/regex.c 2001-04-03 04:04:45.000000000 +1000 ++++ grep-2.5.1/lib/regex.c 2007-05-17 13:51:48.000000000 +1000 +@@ -7842,7 +7842,7 @@ + if (msg_size > errbuf_size) + { + #if defined HAVE_MEMPCPY || defined _LIBC +- *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0'; ++ *((char *) mempcpy (errbuf, msg, errbuf_size - 1)) = '\0'; + #else + memcpy (errbuf, msg, errbuf_size - 1); + errbuf[errbuf_size - 1] = 0; diff --git a/meta/recipes-extended/grep/grep_2.19.bb b/meta/recipes-extended/grep/grep_2.19.bb new file mode 100644 index 0000000000..d60ce5e389 --- /dev/null +++ b/meta/recipes-extended/grep/grep_2.19.bb @@ -0,0 +1,41 @@ +SUMMARY = "GNU grep utility" +HOMEPAGE = "http://savannah.gnu.org/projects/grep/" +BUGTRACKER = "http://savannah.gnu.org/bugs/?group=grep" +SECTION = "console/utils" +LICENSE = "GPLv3" +LIC_FILES_CHKSUM = "file://COPYING;md5=8006d9c814277c1bfc4ca22af94b59ee" + +SRC_URI = "${GNU_MIRROR}/grep/grep-${PV}.tar.xz \ + file://grep2.19-CVE-2015-1345.patch \ + " + +SRC_URI[md5sum] = "ac732142227d9fe9567d71301e127979" +SRC_URI[sha256sum] = "6388295be48cfcaf7665d9cd3914e6625ea000e9414132bfefd45cf1d8eec34d" + +inherit autotools gettext texinfo + +EXTRA_OECONF = "--disable-perl-regexp" + +do_configure_prepend () { + rm -f ${S}/m4/init.m4 +} + +do_install () { + autotools_do_install + install -d ${D}${base_bindir} + mv ${D}${bindir}/grep ${D}${base_bindir}/grep + mv ${D}${bindir}/egrep ${D}${base_bindir}/egrep + mv ${D}${bindir}/fgrep ${D}${base_bindir}/fgrep + rmdir ${D}${bindir}/ +} + +inherit update-alternatives + +ALTERNATIVE_PRIORITY = "100" + +ALTERNATIVE_${PN} = "grep egrep fgrep" +ALTERNATIVE_LINK_NAME[grep] = "${base_bindir}/grep" +ALTERNATIVE_LINK_NAME[egrep] = "${base_bindir}/egrep" +ALTERNATIVE_LINK_NAME[fgrep] = "${base_bindir}/fgrep" + +export CONFIG_SHELL="/bin/sh" diff --git a/meta/recipes-extended/grep/grep_2.5.1a.bb b/meta/recipes-extended/grep/grep_2.5.1a.bb new file mode 100644 index 0000000000..1ce112e43d --- /dev/null +++ b/meta/recipes-extended/grep/grep_2.5.1a.bb @@ -0,0 +1,51 @@ +SUMMARY = "Pattern matching utilities" +DESCRIPTION = "The GNU versions of commonly used grep utilities. The grep command searches one or more input \ +files for lines containing a match to a specified pattern." +SECTION = "console/utils" +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3" + +PR = "r2" + +SRC_URI = "${GNU_MIRROR}/grep/grep-${PV}.tar.bz2 \ + file://uclibc-fix.patch \ + file://grep_fix_for_automake-1.12.patch \ + file://gettext.patch \ + file://fix64-int-to-pointer.patch \ + file://Makevars \ + file://grep-CVE-2012-5667.patch \ + file://fix-for-texinfo-5.1.patch \ + " + +SRC_URI[md5sum] = "52202fe462770fa6be1bb667bd6cf30c" +SRC_URI[sha256sum] = "38c8a2bb9223d1fb1b10bdd607cf44830afc92fd451ac4cd07619bf92bdd3132" + +inherit autotools gettext texinfo + +EXTRA_OECONF = "--disable-perl-regexp --disable-ncurses" + +CFLAGS += "-D PROTOTYPES" +do_configure_prepend () { + rm -f ${S}/m4/init.m4 + cp -f ${WORKDIR}/Makevars ${S}/po/ +} + +do_install () { + autotools_do_install + install -d ${D}${base_bindir} + mv ${D}${bindir}/grep ${D}${base_bindir}/grep + mv ${D}${bindir}/egrep ${D}${base_bindir}/egrep + mv ${D}${bindir}/fgrep ${D}${base_bindir}/fgrep + rmdir ${D}${bindir}/ +} + +inherit update-alternatives + +ALTERNATIVE_PRIORITY = "100" + +ALTERNATIVE_${PN} = "grep egrep fgrep" +ALTERNATIVE_LINK_NAME[grep] = "${base_bindir}/grep" +ALTERNATIVE_LINK_NAME[egrep] = "${base_bindir}/egrep" +ALTERNATIVE_LINK_NAME[fgrep] = "${base_bindir}/fgrep" + +export CONFIG_SHELL="/bin/sh" -- cgit v1.2.3-54-g00ecf