From 2adeb6f9525d2444277c10a14e613b9ee536d291 Mon Sep 17 00:00:00 2001 From: Rodrigo Campos Date: Mon, 6 Feb 2023 16:43:40 +0100 Subject: [PATCH] nsexec: Remove bogus kill to stage_2_pid stage_2_pid is not yet assigned, so this kills the PID -1, but as the sane_kill() wrapper is just a nop in that case. Just remove these calls to kill stage_2_pid before it is cloned/assigned. I've checked by executing the error paths that no binary is left by mistake. Signed-off-by: Rodrigo Campos --- libcontainer/nsenter/nsexec.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libcontainer/nsenter/nsexec.c b/libcontainer/nsenter/nsexec.c index b12f2355c..829dcc863 100644 --- a/libcontainer/nsenter/nsexec.c +++ b/libcontainer/nsenter/nsexec.c @@ -1034,7 +1034,6 @@ void nsexec(void) /* Get the stage-2 pid. */ if (read(syncfd, &stage2_pid, sizeof(stage2_pid)) != sizeof(stage2_pid)) { sane_kill(stage1_pid, SIGKILL); - sane_kill(stage2_pid, SIGKILL); bail("failed to sync with stage-1: read(stage2_pid)"); } @@ -1231,23 +1230,17 @@ void nsexec(void) /* Ask our parent to send the mount sources fds. */ if (config.mountsources) { s = SYNC_MOUNTSOURCES_PLS; - if (write(syncfd, &s, sizeof(s)) != sizeof(s)) { - sane_kill(stage2_pid, SIGKILL); + if (write(syncfd, &s, sizeof(s)) != sizeof(s)) bail("failed to sync with parent: write(SYNC_MOUNTSOURCES_PLS)"); - } /* Receive and install all mount sources fds. */ receive_mountsources(syncfd); /* Parent finished to send the mount sources fds. */ - if (read(syncfd, &s, sizeof(s)) != sizeof(s)) { - sane_kill(stage2_pid, SIGKILL); + if (read(syncfd, &s, sizeof(s)) != sizeof(s)) bail("failed to sync with parent: read(SYNC_MOUNTSOURCES_ACK)"); - } - if (s != SYNC_MOUNTSOURCES_ACK) { - sane_kill(stage2_pid, SIGKILL); + if (s != SYNC_MOUNTSOURCES_ACK) bail("failed to sync with parent: SYNC_MOUNTSOURCES_ACK: got %u", s); - } } /*