]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/bash/bash51-012
Merge branch 'next' into temp-c165-development
[people/pmueller/ipfire-2.x.git] / src / patches / bash / bash51-012
1 BASH PATCH REPORT
2 =================
3
4 Bash-Release: 5.1
5 Patch-ID: bash51-012
6
7 Bug-Reported-by: Nikolay Borisov <nborisov@suse.com>
8 Bug-Reference-ID: <1a715205-06ce-413b-c1c0-2f5639ce06c0@suse.com>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2020-11/msg00091.html
10
11 Bug-Description:
12
13 There is a possible race condition that arises when a child process receives
14 a signal trapped by the parent before it can reset the signal dispositions.
15 The child process is not supposed to trap the signal in this circumstance.
16
17 Patch (apply with `patch -p0'):
18
19 *** ../bash-20201118/command.h 2020-08-14 15:04:39.000000000 -0400
20 --- command.h 2020-11-27 15:18:02.000000000 -0500
21 ***************
22 *** 125,128 ****
23 --- 125,129 ----
24 #define SUBSHELL_COPROC 0x40 /* subshell from a coproc pipeline */
25 #define SUBSHELL_RESETTRAP 0x80 /* subshell needs to reset trap strings on first call to trap */
26 + #define SUBSHELL_IGNTRAP 0x100 /* subshell should reset trapped signals from trap_handler */
27
28 /* A structure which represents a word. */
29
30 *** ../bash-20201118/execute_cmd.c 2020-11-23 14:16:48.000000000 -0500
31 --- execute_cmd.c 2020-11-27 16:43:25.000000000 -0500
32 ***************
33 *** 1548,1551 ****
34 --- 1548,1554 ----
35 reset_signal_handlers ();
36 subshell_environment |= SUBSHELL_RESETTRAP;
37 + /* Note that signal handlers have been reset, so we should no longer
38 + reset the handler and resend trapped signals to ourselves. */
39 + subshell_environment &= ~SUBSHELL_IGNTRAP;
40
41 /* We are in a subshell, so forget that we are running a trap handler or
42 ***************
43 *** 4321,4325 ****
44 cmdflags |= CMD_NO_FORK;
45
46 ! subshell_environment = SUBSHELL_FORK; /* XXX */
47 if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
48 subshell_environment |= SUBSHELL_PIPE;
49 --- 4324,4329 ----
50 cmdflags |= CMD_NO_FORK;
51
52 ! /* We redo some of what make_child() does with SUBSHELL_IGNTRAP */
53 ! subshell_environment = SUBSHELL_FORK|SUBSHELL_IGNTRAP; /* XXX */
54 if (pipe_in != NO_PIPE || pipe_out != NO_PIPE)
55 subshell_environment |= SUBSHELL_PIPE;
56 ***************
57 *** 4575,4578 ****
58 --- 4580,4584 ----
59 reset_signal_handlers ();
60 subshell_environment |= SUBSHELL_RESETTRAP;
61 + subshell_environment &= ~SUBSHELL_IGNTRAP;
62
63 if (async)
64 ***************
65 *** 5515,5518 ****
66 --- 5521,5525 ----
67 /* Cancel traps, in trap.c. */
68 restore_original_signals ();
69 + subshell_environment &= ~SUBSHELL_IGNTRAP;
70
71 #if defined (JOB_CONTROL)
72
73 *** ../bash-20201118/jobs.c 2020-08-04 10:17:39.000000000 -0400
74 --- jobs.c 2020-11-27 16:39:56.000000000 -0500
75 ***************
76 *** 2218,2221 ****
77 --- 2218,2223 ----
78 pid_t mypid;
79
80 + subshell_environment |= SUBSHELL_IGNTRAP;
81 +
82 /* If this ends up being changed to modify or use `command' in the
83 child process, go back and change callers who free `command' in
84 diff -rC 2 ../bash-20201118/nojobs.c nojobs.c
85 *** ../bash-20201118/nojobs.c 2020-07-08 10:11:25.000000000 -0400
86 --- nojobs.c 2020-11-27 16:38:36.000000000 -0500
87 ***************
88 *** 576,579 ****
89 --- 576,581 ----
90 #endif
91
92 + subshell_environment |= SUBSHELL_IGNTRAP;
93 +
94 default_tty_job_signals ();
95 }
96
97 *** ../bash-20201118/sig.c 2020-11-23 13:22:17.000000000 -0500
98 --- sig.c 2020-11-28 10:21:43.000000000 -0500
99 ***************
100 *** 56,60 ****
101 #endif
102
103 ! extern void initialize_siglist ();
104
105 #if !defined (JOB_CONTROL)
106 --- 56,61 ----
107 #endif
108
109 ! extern void initialize_siglist PARAMS((void));
110 ! extern void set_original_signal PARAMS((int, SigHandler *));
111
112 #if !defined (JOB_CONTROL)
113 ***************
114 *** 256,259 ****
115 --- 257,267 ----
116 XHANDLER(i) = oact.sa_handler;
117 XSAFLAGS(i) = oact.sa_flags;
118 +
119 + #if 0
120 + set_original_signal (XSIG(i), XHANDLER(i)); /* optimization */
121 + #else
122 + set_original_signal (XSIG(i), act.sa_handler); /* optimization */
123 + #endif
124 +
125 /* Don't do anything with signals that are ignored at shell entry
126 if the shell is not interactive. */
127
128 *** ../bash-20201118/subst.c 2020-11-16 10:33:15.000000000 -0500
129 --- subst.c 2020-11-27 16:07:00.000000000 -0500
130 ***************
131 *** 5952,5955 ****
132 --- 5952,5956 ----
133 /* Cancel traps, in trap.c. */
134 restore_original_signals (); /* XXX - what about special builtins? bash-4.2 */
135 + subshell_environment &= ~SUBSHELL_IGNTRAP;
136 QUIT; /* catch any interrupts we got post-fork */
137 setup_async_signals ();
138 ***************
139 *** 6383,6386 ****
140 --- 6384,6388 ----
141 QUIT; /* catch any interrupts we got post-fork */
142 subshell_environment |= SUBSHELL_RESETTRAP;
143 + subshell_environment &= ~SUBSHELL_IGNTRAP;
144 }
145
146
147 diff -rC 2 ../bash-20201118/trap.c trap.c
148 *** ../bash-20201118/trap.c 2020-11-28 12:04:07.000000000 -0500
149 --- trap.c 2020-11-28 10:22:10.000000000 -0500
150 ***************
151 *** 482,485 ****
152 --- 482,511 ----
153 }
154
155 + /* This means we're in a subshell, but have not yet reset the handler for
156 + trapped signals. We're not supposed to execute the trap in this situation;
157 + we should restore the original signal and resend the signal to ourselves
158 + to preserve the Posix "signal traps that are not being ignored shall be
159 + set to the default action" semantics. */
160 + if ((subshell_environment & SUBSHELL_IGNTRAP) && trap_list[sig] != (char *)IGNORE_SIG)
161 + {
162 + sigset_t mask;
163 +
164 + /* Paranoia */
165 + if (original_signals[sig] == IMPOSSIBLE_TRAP_HANDLER)
166 + original_signals[sig] = SIG_DFL;
167 +
168 + restore_signal (sig);
169 +
170 + /* Make sure we let the signal we just caught through */
171 + sigemptyset (&mask);
172 + sigprocmask (SIG_SETMASK, (sigset_t *)NULL, &mask);
173 + sigdelset (&mask, sig);
174 + sigprocmask (SIG_SETMASK, &mask, (sigset_t *)NULL);
175 +
176 + kill (getpid (), sig);
177 +
178 + SIGRETURN (0);
179 + }
180 +
181 if ((sig >= NSIG) ||
182 (trap_list[sig] == (char *)DEFAULT_SIG) ||
183
184 *** ../bash-5.1/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
185 --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
186 ***************
187 *** 26,30 ****
188 looks for to find the patch level (for the sccs version string). */
189
190 ! #define PATCHLEVEL 11
191
192 #endif /* _PATCHLEVEL_H_ */
193 --- 26,30 ----
194 looks for to find the patch level (for the sccs version string). */
195
196 ! #define PATCHLEVEL 12
197
198 #endif /* _PATCHLEVEL_H_ */