Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1474582

Re: [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach

From Ales Novak <alnovak@suse.cz>
Newsgroups linux.kernel
Subject Re: [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach
Date 2016-09-01 23:10 +0200
Message-ID <scHpg-70l-31@gated-at.bofh.it> (permalink)
References <scAH7-2zZ-19@gated-at.bofh.it> <scDlE-4lf-57@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Sep 01, 2016 at 06:46:13PM +0200, Oleg Nesterov wrote:
> On 09/01, Ales Novak wrote:
> >
> > On ptrace_detach(), 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.
> 
> We do not really care, if the tracer dies the tracee can be in the
> inconsistent state anyway.
> 
> > --- a/kernel/ptrace.c
> > +++ b/kernel/ptrace.c
> > @@ -85,6 +85,7 @@ void __ptrace_unlink(struct task_struct *child)
> >  	task_clear_jobctl_pending(child, JOBCTL_TRAP_MASK);
> >  	task_clear_jobctl_trapping(child);
> >
> > +	clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
> 
> OK, probably this change makes sense anyway, but then you should
> remove another clear_tsk_thread_flag(TIF_SYSCALL_TRACE) in ptrace_detach?

You're right, sorry for not noticing that. Also my changelog was
misleading, I've tried to fix that.

> 
> And I'd suggest to move this clear_tsk_thread_flag() up, before
> spin_lock(siglock). Otherwise it looks as if we should clear this flag
> with ->siglock held.

Good point also.

> 
> Oleg.
> 

-- 
Ales Novak
SUSE L3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach Ales Novak <alnovak@suse.cz> - 2016-09-01 16:00 +0200
  Re: [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach Oleg Nesterov <oleg@redhat.com> - 2016-09-01 18:50 +0200
    Re: [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach Ales Novak <alnovak@suse.cz> - 2016-09-01 23:10 +0200
    [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach Ales Novak <alnovak@suse.cz> - 2016-09-01 23:10 +0200
      Re: [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach Oleg Nesterov <oleg@redhat.com> - 2016-09-02 14:30 +0200

csiph-web