From 185aa1593d30b9543387a7ce78a86e4cce212587 Mon Sep 17 00:00:00 2001 From: Roman Rakus Date: Thu, 27 Jun 2013 10:03:57 +0200 Subject: [PATCH] fix deadlock in trap, backported from devel branch Signed-off-by: Roman Rakus --- bash-4.2-trap.patch | 60 +++++++++++++++++++++++++++++++++++++++++++++ bash.spec | 9 ++++++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 bash-4.2-trap.patch diff --git a/bash-4.2-trap.patch b/bash-4.2-trap.patch new file mode 100644 index 0000000..92c785d --- /dev/null +++ b/bash-4.2-trap.patch @@ -0,0 +1,60 @@ +commit 41d203e21f94c1b8bfc457606ee633c22da3cf04 +Author: Chet Ramey +Date: Wed Jun 12 09:29:51 2013 -0400 + + commit bash-20130523 snapshot + +diff --git a/trap.c b/trap.c +index 1e11d1f..da59b26 100644 +--- a/trap.c ++++ b/trap.c +@@ -286,6 +286,9 @@ run_pending_traps () + if (catch_flag == 0) /* simple optimization */ + return; + ++ if (running_trap > 0) ++ return; /* no recursive trap invocations */ ++ + catch_flag = trapped_signal_received = 0; + + /* Preserve $? when running trap. */ +@@ -304,6 +307,8 @@ run_pending_traps () + + BLOCK_SIGNAL (sig, set, oset); + ++ running_trap = sig + 1; ++ + if (sig == SIGINT) + { + run_interrupt_trap (); +@@ -324,6 +329,7 @@ run_pending_traps () + { + /* This can happen when run_pending_traps is called while + running a SIGCHLD trap handler. */ ++ running_trap = 0; + UNBLOCK_SIGNAL (oset); + continue; /* XXX */ + } +@@ -359,7 +365,14 @@ run_pending_traps () + save_subst_varlist = subst_assign_varlist; + subst_assign_varlist = 0; + ++#if defined (JOB_CONTROL) ++ save_pipeline (1); /* XXX only provides one save level */ ++#endif + evalstring (savestring (trap_list[sig]), "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE); ++#if defined (JOB_CONTROL) ++ restore_pipeline (1); ++#endif ++ + restore_token_state (token_state); + free (token_state); + +@@ -367,6 +380,7 @@ run_pending_traps () + } + + pending_traps[sig] = 0; ++ running_trap = 0; + + UNBLOCK_SIGNAL (oset); + } diff --git a/bash.spec b/bash.spec index d9124c9..d114947 100644 --- a/bash.spec +++ b/bash.spec @@ -6,7 +6,7 @@ Version: %{baseversion}%{patchleveltag} Name: bash Summary: The GNU Bourne Again shell -Release: 1%{?dist} +Release: 2%{?dist} Group: System Environment/Shells License: GPLv3+ Url: http://www.gnu.org/software/bash @@ -115,6 +115,9 @@ Patch125: bash-4.2-size_type.patch # 903833, Fix missing close(), fixes fd leaks Patch126: bash-4.2-missing_closes.patch +# fix deadlock in trap, backported from devel branch +Patch127: bash-4.2-trap.patch + BuildRequires: texinfo bison BuildRequires: ncurses-devel BuildRequires: autoconf, gettext @@ -408,6 +411,10 @@ end #%doc doc/*.ps doc/*.0 doc/*.html doc/article.txt %changelog +* Thu Jun 27 2013 Roman Rakus - 4.2.45-2 +- Fixed a bug that caused trap handlers to be executed recursively, + corrupting internal data structures. + * Mon Mar 11 2013 Roman Rakus - 4.2.45-1 - Patchlevel 45