From ba53be405112d10b85e88cc2637156804b88bd91 Mon Sep 17 00:00:00 2001 From: Hank Leininger Date: Wed, 11 Dec 2019 15:06:45 -0700 Subject: app-shells/bash: fix CVE-2019-18276 (priv-dropping bug) Cherry-picked the relevant parts of https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=951bdaad7a18cc0dc1036bba86b18b90874d39ff and modified the patches to apply. Note that the existing bash-5.0*patch files are applied with -p0, which is not the norm for eapply, etc. I simply followed what was required to work with the rest of the existing patches. Signed-off-by: Hank Leininger Bug: https://bugs.gentoo.org/702488 Package-Manager: Portage-2.3.81, Repoman-2.3.18 Closes: https://github.com/gentoo/gentoo/pull/13941 Signed-off-by: Lars Wendler --- app-shells/bash/bash-5.0_p11-r1.ebuild | 266 +++++++++++++++++++++ .../files/bash-5.0_p11-disable_priv_mode.patch | 85 +++++++ 2 files changed, 351 insertions(+) create mode 100644 app-shells/bash/bash-5.0_p11-r1.ebuild create mode 100644 app-shells/bash/files/bash-5.0_p11-disable_priv_mode.patch (limited to 'app-shells/bash') diff --git a/app-shells/bash/bash-5.0_p11-r1.ebuild b/app-shells/bash/bash-5.0_p11-r1.ebuild new file mode 100644 index 000000000000..a6cf9c086ced --- /dev/null +++ b/app-shells/bash/bash-5.0_p11-r1.ebuild @@ -0,0 +1,266 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit flag-o-matic toolchain-funcs multilib prefix + +# Official patchlevel +# See ftp://ftp.cwru.edu/pub/bash/bash-5.0-patches/ +PLEVEL=${PV##*_p} +MY_PV=${PV/_p*} +MY_PV=${MY_PV/_/-} +MY_P=${PN}-${MY_PV} +is_release() { + case ${PV} in + *_alpha*|*_beta*|*_rc*) return 1 ;; + *) return 0 ;; + esac +} +[[ ${PV} != *_p* ]] && PLEVEL=0 +patches() { + local opt=$1 plevel=${2:-${PLEVEL}} pn=${3:-${PN}} pv=${4:-${MY_PV}} + [[ ${plevel} -eq 0 ]] && return 1 + eval set -- {1..${plevel}} + set -- $(printf "${pn}${pv/\.}-%03d " "$@") + if [[ ${opt} == -s ]] ; then + echo "${@/#/${DISTDIR}/}" + else + local u + for u in ftp://ftp.cwru.edu/pub/bash mirror://gnu/${pn} ; do + printf "${u}/${pn}-${pv}-patches/%s " "$@" + done + fi +} + +# The version of readline this bash normally ships with. +READLINE_VER="8.0" + +DESCRIPTION="The standard GNU Bourne again shell" +HOMEPAGE="http://tiswww.case.edu/php/chet/bash/bashtop.html" +if is_release ; then + SRC_URI="mirror://gnu/bash/${MY_P}.tar.gz $(patches)" +else + SRC_URI="ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz" +fi + +LICENSE="GPL-3" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" +IUSE="afs bashlogger examples mem-scramble +net nls plugins +readline" + +DEPEND=" + >=sys-libs/ncurses-5.2-r2:0= + nls? ( virtual/libintl ) + readline? ( >=sys-libs/readline-${READLINE_VER}:0= ) +" +RDEPEND=" + ${DEPEND} + !>confdefs.h <<_ACEOF ++#define HAVE_DECL_ $ac_have_decl ++_ACEOF ++(setresuid, setresgid) + ac_fn_c_check_decl "$LINENO" "strcpy" "ac_cv_have_decl_strcpy" "$ac_includes_default" + if test "x$ac_cv_have_decl_strcpy" = xyes; then : + ac_have_decl=1 +diff -urP ../bash-5.0.orig/configure.ac configure.ac +--- ../bash-5.0.orig/configure.ac 2019-01-02 07:39:11.000000000 -0700 ++++ configure.ac 2019-12-10 11:34:42.168926317 -0700 +@@ -810,6 +810,7 @@ + AC_CHECK_DECLS([printf]) + AC_CHECK_DECLS([sbrk]) + AC_CHECK_DECLS([setregid]) ++AC_CHECK_DECLS[(setresuid, setresgid]) + AC_CHECK_DECLS([strcpy]) + AC_CHECK_DECLS([strsignal]) + +diff -urP ../bash-5.0.orig/shell.c shell.c +--- ../bash-5.0.orig/shell.c 2018-12-06 09:28:21.000000000 -0700 ++++ shell.c 2019-12-10 11:34:42.170926317 -0700 +@@ -1293,7 +1293,11 @@ + { + int e; + ++#if HAVE_DECL_SETRESUID ++ if (setresuid (current_user.uid, current_user.uid, current_user.uid) < 0) ++#else + if (setuid (current_user.uid) < 0) ++#endif + { + e = errno; + sys_error (_("cannot set uid to %d: effective uid %d"), current_user.uid, current_user.euid); +@@ -1302,7 +1306,11 @@ + exit (e); + #endif + } ++#if HAVE_DECL_SETRESGID ++ if (setresgid (current_user.gid, current_user.gid, current_user.gid) < 0) ++#else + if (setgid (current_user.gid) < 0) ++#endif + sys_error (_("cannot set gid to %d: effective gid %d"), current_user.gid, current_user.egid); + + current_user.euid = current_user.uid; -- cgit v1.2.3-65-gdbad