From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64931 invoked by alias); 22 Oct 2015 14:40:49 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 64917 invoked by uid 89); 22 Oct 2015 14:40:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 22 Oct 2015 14:40:47 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 6732A2654; Thu, 22 Oct 2015 14:40:46 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9MEef3Z030880; Thu, 22 Oct 2015 10:40:42 -0400 Message-ID: <5628F569.4070602@redhat.com> Date: Thu, 22 Oct 2015 14:40:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Oleg Nesterov , Andrew Morton , Dmitry Vyukov CC: Alexander Potapenko , Denys Vlasenko , Eric Dumazet , Jan Kratochvil , Julien Tinnes , Kees Cook , Kostya Serebryany , Linus Torvalds , "Michael Kerrisk (man-pages)" , Robert Swiecki , Roland McGrath , syzkaller@googlegroups.com, linux-kernel@vger.kernel.org, "gdb@sourceware.org" Subject: Re: [PATCH 0/2] wait/ptrace: always assume __WALL if the child is traced References: <20151020171740.GA29290@redhat.com> In-Reply-To: <20151020171740.GA29290@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-10/txt/msg00091.txt.bz2 On 10/20/2015 06:17 PM, Oleg Nesterov wrote: > Jan, Pedro, could you please confirm this won't break gdb? I tried > to look into gdb-7.1, and at first glance gdb uses __WCLONE only > because __WALL doesn't work on older kernels, iow it seems to me > that gdb actually wants __WALL so this change should be fine. Right, gdb actually wants __WALL, but it doesn't use it to keep compatibility with kernels that predate it. gdb nowadays has an __WALL emulation waitpid wrapper (alternates __WCLONE+WNOHANG with 0+WNOHANG, blocks on sigsuspend/SIGCHLD): https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/nat/linux-waitpid.c;h=cbcdd95afa9c664993542b0b3851e79fbae4e1df;hb=HEAD#l77 Though it's not used everywhere. Some older code in the ptrace backend open codes the "try __WCLONE, then try !__WCLONE." dance. Seems like __WALL was added in Linux 2.4; gdb could probably assume it's available nowadays... In any case, to make sure existing gdb binaries would still work with your kernel change, I ran GDB's testsuite with this: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/gdb/nat/linux-waitpid.c b/gdb/nat/linux-waitpid.c index cbcdd95..864ba2e 100644 --- a/gdb/nat/linux-waitpid.c +++ b/gdb/nat/linux-waitpid.c @@ -149,3 +149,17 @@ my_waitpid (int pid, int *status, int flags) errno = out_errno; return ret; } + +#include + +pid_t +waitpid (pid_t pid, int *status, int options) +{ + static pid_t (*waitpid2) (pid_t pid, int *status, int options) = NULL; + + if (waitpid2 == NULL) + waitpid2 = dlsym (RTLD_NEXT, "waitpid"); + + options |= __WALL; + return waitpid2 (pid, status, options); +} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ and got no regressions. So seems like all would be well from GDB's perspective. Thanks, Pedro Alves