From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935350AbcIAQq5 (ORCPT ); Thu, 1 Sep 2016 12:46:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60160 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935274AbcIAQqs (ORCPT ); Thu, 1 Sep 2016 12:46:48 -0400 Date: Thu, 1 Sep 2016 18:46:13 +0200 From: Oleg Nesterov To: Ales Novak Cc: linux-kernel@vger.kernel.org, Andrew Morton , Jiri Kosina Subject: Re: [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach Message-ID: <20160901164613.GA13138@redhat.com> References: <1472738076-14610-1-git-send-email-alnovak@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1472738076-14610-1-git-send-email-alnovak@suse.cz> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 01 Sep 2016 16:46:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? 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. Oleg.