diff options
| author | Oleg Nesterov <[email protected]> | 2009-09-23 22:56:44 +0000 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2009-09-24 14:20:59 +0000 |
| commit | a7f0765edfd53aed09cb7b0e15863688b39447de (patch) | |
| tree | c89adfe418f9988ad4044e0f22827458bdf6b155 /security/selinux/hooks.c | |
| parent | memcg: show swap usage in stat file (diff) | |
| download | kernel-a7f0765edfd53aed09cb7b0e15863688b39447de.tar.gz kernel-a7f0765edfd53aed09cb7b0e15863688b39447de.zip | |
ptrace: __ptrace_detach: do __wake_up_parent() if we reap the tracee
The bug is old, it wasn't cause by recent changes.
Test case:
static void *tfunc(void *arg)
{
int pid = (long)arg;
assert(ptrace(PTRACE_ATTACH, pid, NULL, NULL) == 0);
kill(pid, SIGKILL);
sleep(1);
return NULL;
}
int main(void)
{
pthread_t th;
long pid = fork();
if (!pid)
pause();
signal(SIGCHLD, SIG_IGN);
assert(pthread_create(&th, NULL, tfunc, (void*)pid) == 0);
int r = waitpid(-1, NULL, __WNOTHREAD);
printf("waitpid: %d %m\n", r);
return 0;
}
Before the patch this program hangs, after this patch waitpid() correctly
fails with errno == -ECHILD.
The problem is, __ptrace_detach() reaps the EXIT_ZOMBIE tracee if its
->real_parent is our sub-thread and we ignore SIGCHLD. But in this case
we should wake up other threads which can sleep in do_wait().
Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Roland McGrath <[email protected]>
Cc: Vitaly Mayatskikh <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'security/selinux/hooks.c')
0 files changed, 0 insertions, 0 deletions
