]> git.ipfire.org Git - thirdparty/shadow.git/commit
Improve child error handling 440/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 14 Nov 2021 11:01:32 +0000 (12:01 +0100)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 14 Nov 2021 11:01:32 +0000 (12:01 +0100)
commit624d57c08caceed306212d24c2147f6273f3fc4b
tree89ca1dc1778f97537168318ba60994056228811c
parent387da46d73524c9fea48f5a949eb5220d40440e6
Improve child error handling

Always set SIGCHLD handler to default, even if the caller of vipw has
set SIGCHLD to ignore. If SIGCHLD is ignored no zombie processes would
be created, which in turn could mean that kill is called with an already
recycled pid.

Proof of Concept:

1. Compile nochld:
 --
 #include <signal.h>
 #include <unistd.h>
 int main(void) {
 char *argv[] = { "vipw", NULL };
 signal(SIGCHLD, SIG_IGN);
 execvp("vipw", argv);
 return 1;
 }
 --
2. Run nochld
3. Suspend child vi, which suspends vipw too:
`kill -STOP childpid`
4. Kill vi:
`kill -9 childpid`
5. You can see with ps that childpid is no zombie but disappeared
6. Bring vipw back into foreground
`fg`

The kill call sends SIGCONT to "childpid" which in turn could have been
already recycled for another process.

This is definitely not a vulnerability. It would take super user
operations, at which point an attacker would have already elevated
permissions.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
src/vipw.c