From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20945 invoked by alias); 16 Feb 2011 19:38:57 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 20928 invoked by uid 22791); 16 Feb 2011 19:38:56 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Date: Wed, 16 Feb 2011 19:38:00 -0000 From: Oleg Nesterov To: Jan Kratochvil Cc: Roland McGrath , Project Archer Subject: Re: ptrace improvement: PTRACE_O_INHERIT Message-ID: <20110216193044.GA15576@redhat.com> References: <20110210195212.GA3868@redhat.com> <20110211192423.78FFC1802A2@magilla.sf.frob.com> <20110211203755.GA5367@redhat.com> <20110212005855.E764C1814A4@magilla.sf.frob.com> <20110212190253.GA31866@redhat.com> <20110214193052.3EC8D1814BA@magilla.sf.frob.com> <20110214193812.GA20765@redhat.com> <20110215003551.BC1EA1802A2@magilla.sf.frob.com> <20110215130805.GA30742@redhat.com> <20110215214333.GA18086@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110215214333.GA18086@host1.dyn.jankratochvil.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-SW-Source: 2011-q1/txt/msg00062.txt.bz2 On 02/15, Jan Kratochvil wrote: > > On Tue, 15 Feb 2011 14:08:05 +0100, Oleg Nesterov wrote: > > > Suppose that debugger uses PTRACE_O_INHERIT and then it decides to detach > > gracefully. It should detach per-thread, but how? /proc is very unconvenient. > > Even if we traced all threads, we do not trace them all after we detach > > the first thread, and that thread can clone the new threads after detach. > > Maybe it is obvious but it has not been heard yet. > With PTRACE_O_THREAD_INHERIT the debugger no longer has to enumerate threads > for ptrace operations - except for attach+detach. > > Could PTRACE_ATTACH_NOSTOP+PTRACE_DETACH_NOSTOP? act on the whole PID at once > if PTRACE_O_THREAD_INHERIT is applied - already during PTRACE_ATTACH_NOSTOP? > It is a bit overloading the *_NOSTOP meaning but it is a new PTRACE_* op. Yes, I thought about PTRACE_ATTACH_TG / PTRACE_DETACH_TG too. This is nontrivial to implement. We should obviously avoid the races with clone(). Now that cred_guard_mutex is per-process, this is probably possible... But I can't understand how we can check __ptrace_may_access() for each thread. We should refactor this code, task_lock() is needed to pin ->mm, and ->mm should be the same. Anyway, looks possible. Oleg.