diff options
author | Ales Novak <alnovak@suse.cz> | 2016-10-11 16:53:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-11 18:06:32 -0400 |
commit | 0a5bf409d3eefc1ca64cedf0bc1c0673164cacc1 (patch) | |
tree | 21c48f939afc592ecd4273ec956d8a17bf4ff1e8 | |
parent | 086e774a57fba4695f14383c0818994c0b31da7c (diff) |
ptrace: clear TIF_SYSCALL_TRACE on ptrace detach
On __ptrace_detach(), called from do_exit()->exit_notify()->
forget_original_parent()->exit_ptrace(), the TIF_SYSCALL_TRACE in
thread->flags of the tracee is not cleared up. This results in the
tracehook_report_syscall_* being called (though there's no longer a tracer
listening to that) upon its further syscalls.
Example scenario - attach "strace" to a running process and kill it (the
strace) with SIGKILL. You'll see that the syscall trace hooks are still
being called.
The clearing of this flag should be moved from ptrace_detach() to
__ptrace_detach().
Link: http://lkml.kernel.org/r/1472759493-20554-1-git-send-email-alnovak@suse.cz
Signed-off-by: Ales Novak <alnovak@suse.cz>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | kernel/ptrace.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 1d3b7665d0be..2a99027312a6 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -73,6 +73,8 @@ void __ptrace_unlink(struct task_struct *child) | |||
73 | { | 73 | { |
74 | BUG_ON(!child->ptrace); | 74 | BUG_ON(!child->ptrace); |
75 | 75 | ||
76 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | ||
77 | |||
76 | child->parent = child->real_parent; | 78 | child->parent = child->real_parent; |
77 | list_del_init(&child->ptrace_entry); | 79 | list_del_init(&child->ptrace_entry); |
78 | 80 | ||
@@ -489,7 +491,6 @@ static int ptrace_detach(struct task_struct *child, unsigned int data) | |||
489 | 491 | ||
490 | /* Architecture-specific hardware disable .. */ | 492 | /* Architecture-specific hardware disable .. */ |
491 | ptrace_disable(child); | 493 | ptrace_disable(child); |
492 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | ||
493 | 494 | ||
494 | write_lock_irq(&tasklist_lock); | 495 | write_lock_irq(&tasklist_lock); |
495 | /* | 496 | /* |