From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C68F0C433DB for ; Mon, 21 Dec 2020 20:06:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86BB622AAA for ; Mon, 21 Dec 2020 20:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726131AbgLUUGB (ORCPT ); Mon, 21 Dec 2020 15:06:01 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:37460 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgLUUGB (ORCPT ); Mon, 21 Dec 2020 15:06:01 -0500 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1krRQl-00CHvM-JI; Mon, 21 Dec 2020 13:05:19 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1krRQk-00GYLe-Jk; Mon, 21 Dec 2020 13:05:19 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Oleg Nesterov Cc: Andrew Morton , Eugene Syromiatnikov , Jan Kratochvil , Linus Torvalds , Mathieu Desnoyers , Michael Kerrisk , Pedro Alves , Simon Marchi , linux-kernel@vger.kernel.org References: <20201217142931.GA8865@redhat.com> <875z50roia.fsf@x220.int.ebiederm.org> <20201218141032.GA20989@redhat.com> Date: Mon, 21 Dec 2020 14:04:37 -0600 In-Reply-To: <20201218141032.GA20989@redhat.com> (Oleg Nesterov's message of "Fri, 18 Dec 2020 15:10:33 +0100") Message-ID: <87y2hrj57u.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1krRQk-00GYLe-Jk;;;mid=<87y2hrj57u.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/s8ZZXLXlj6CFHb1K5Bn01iz7SJDxMFzc= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [RFC PATCH] ptrace: make ptrace() fail if the tracee changed its pid unexpectedly X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Oleg Nesterov writes: > On 12/17, Eric W. Biederman wrote: >> >> Oleg Nesterov writes: >> >> > Suppose we have 2 threads, the group-leader L and a sub-theread T, >> > both parked in ptrace_stop(). Debugger tries to resume both threads >> > and does >> > >> > ptrace(PTRACE_CONT, T); >> > ptrace(PTRACE_CONT, L); >> > >> > If the sub-thread T execs in between, the 2nd PTRACE_CONT doesn not >> > resume the old leader L, it resumes the post-exec thread T which was >> > actually now stopped in PTHREAD_EVENT_EXEC. In this case the >> > PTHREAD_EVENT_EXEC event is lost, and the tracer can't know that the >> > tracee changed its pid. >> >> The change seems sensible. I don't expect this is common but it looks >> painful to deal with if it happens. > > Yes, this is not a bug, but gdb can't handle this case without some help > from the kernel. >> I admit this a threaded PTRACE_EVENT_EXEC is the only event we are >> likely to miss but still. > > Yes, this is the only event debugger can miss even if it uses wait() > correctly. I think that is my confusion with the patch. The uniqueness of this case is not described well. Eric