From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756317AbcIAVD4 (ORCPT ); Thu, 1 Sep 2016 17:03:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:44433 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756288AbcIAVDy (ORCPT ); Thu, 1 Sep 2016 17:03:54 -0400 Date: Thu, 1 Sep 2016 21:50:51 +0200 From: Ales Novak To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Andrew Morton , Jiri Kosina Subject: Re: [PATCH] ptrace: clear TIF_SYSCALL_TRACE on ptrace detach Message-ID: <20160901195051.aevh2miogutgobzk@alesak.suse.cz> Mail-Followup-To: Oleg Nesterov , linux-kernel@vger.kernel.org, Andrew Morton , Jiri Kosina References: <1472738076-14610-1-git-send-email-alnovak@suse.cz> <20160901164613.GA13138@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ctntdwwk6pe7ncvz" Content-Disposition: inline In-Reply-To: <20160901164613.GA13138@redhat.com> User-Agent: Mutt/1.6.1-neo (2016-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ctntdwwk6pe7ncvz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > We do not really care, if the tracer dies the tracee can be in the > inconsistent state anyway. >=20 > > --- 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); >=20 > 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. >=20 > 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. >=20 > Oleg. >=20 --=20 Ales Novak SUSE L3 --ctntdwwk6pe7ncvz Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJXyIaXAAoJEGOSdXQ6V/cletAIAKJA8bujmBfT12erwUTn+ADz uAU4vqnIV9/JuF/a4ZmDRLzVn8QScjRhterPX4ONGu4kiTE1ExOgi++WplT9TNXS KR8RFYt1tP0kEgDN9sqSjqp2O//OmkRqtJmuh23Fb3owkXnsHwCQUNB8EQSZEb8Z X7pFVoJAG6WFgX1GL5mTElQtMzUQ65mFqZsm/mZz681/Qr2h4btRkXBs6QiaG24Y 8I2ZepVQJjI7wTTtBhQqOtW/TA1MiJUW7R4R38pBdaYtOnZCQJeuE9E61tnvGn5m aunvCRkWxz7wpAntGX8W6cFbmBWBRheqgBeaJhLtZWvk7MCth+qst8X/nt0UZ7U= =WKn2 -----END PGP SIGNATURE----- --ctntdwwk6pe7ncvz--