]> git.proxmox.com Git - lxc.git/blame - debian/patches/fixes/0008-fix-signal-sending-in-lxc.init.patch
bump version to 3.0.0-3
[lxc.git] / debian / patches / fixes / 0008-fix-signal-sending-in-lxc.init.patch
CommitLineData
99be5c8c
WB
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Tycho Andersen <tycho@tycho.ws>
3Date: Wed, 4 Apr 2018 17:45:29 -0600
4Subject: [PATCH] fix signal sending in lxc.init
5
6The problem here is that these two clauses were ordered backwards: we first
7check if the signal came from not the init pid, and if it did, then we give
8a notice and return. The comment notes that this is intended to protect
9against SIGCHLD, but we don't in fact know if the signal is a SIGCHLD yet,
10because that's tested in the next hunk.
11
12The symptom is that if I e.g. send SIGTERM from the outside world to the
13container init, it ignores it and gives this notice. If we re-order these
14clauses, it forwards non SIGCHLD signals, and ignores SIGCHLD signals from
15things that aren't the real container process.
16
17Signed-off-by: Tycho Andersen <tycho@tycho.ws>
18---
19 src/lxc/start.c | 12 ++++++------
20 1 file changed, 6 insertions(+), 6 deletions(-)
21
22diff --git a/src/lxc/start.c b/src/lxc/start.c
23index ae13aae9..1982270e 100644
24--- a/src/lxc/start.c
25+++ b/src/lxc/start.c
26@@ -380,6 +380,12 @@ static int signal_handler(int fd, uint32_t events, void *data,
27 return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
28 }
29
30+ if (siginfo.ssi_signo != SIGCHLD) {
31+ kill(hdlr->pid, siginfo.ssi_signo);
32+ INFO("Forwarded signal %d to pid %d", siginfo.ssi_signo, hdlr->pid);
33+ return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
34+ }
35+
36 /* More robustness, protect ourself from a SIGCHLD sent
37 * by a process different from the container init.
38 */
39@@ -389,12 +395,6 @@ static int signal_handler(int fd, uint32_t events, void *data,
40 return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
41 }
42
43- if (siginfo.ssi_signo != SIGCHLD) {
44- kill(hdlr->pid, siginfo.ssi_signo);
45- INFO("Forwarded signal %d to pid %d", siginfo.ssi_signo, hdlr->pid);
46- return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
47- }
48-
49 if (siginfo.ssi_code == CLD_STOPPED) {
50 INFO("Container init process was stopped");
51 return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
52--
532.11.0
54