From: Pedro Alves <palves@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Dmitry Vyukov <dvyukov@google.com>
Cc: Alexander Potapenko <glider@google.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Jan Kratochvil <jan.kratochvil@redhat.com>,
Julien Tinnes <jln@google.com>, Kees Cook <keescook@google.com>,
Kostya Serebryany <kcc@google.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>,
Robert Swiecki <swiecki@google.com>,
Roland McGrath <roland@hack.frob.com>,
syzkaller@googlegroups.com, linux-kernel@vger.kernel.org,
"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: [PATCH 0/2] wait/ptrace: always assume __WALL if the child is traced
Date: Thu, 22 Oct 2015 15:40:41 +0100 [thread overview]
Message-ID: <5628F569.4070602@redhat.com> (raw)
In-Reply-To: <20151020171740.GA29290@redhat.com>
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 <dlfcn.h>
+
+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
next prev parent reply other threads:[~2015-10-22 14:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-20 17:17 [PATCH 0/2] wait/ptrace: always assume __WALL if the child is traced Oleg Nesterov
2015-10-20 17:17 ` [PATCH 1/2] " Oleg Nesterov
2015-10-20 22:31 ` Andrew Morton
2015-10-21 3:27 ` Vasily Averin
2015-10-21 17:41 ` Oleg Nesterov
2015-10-21 19:47 ` Andrew Morton
2015-10-21 20:44 ` Oleg Nesterov
2015-10-21 19:59 ` Denys Vlasenko
2015-10-21 20:31 ` Denys Vlasenko
2015-10-21 21:47 ` Oleg Nesterov
2015-10-21 23:27 ` Denys Vlasenko
2015-10-25 15:54 ` Oleg Nesterov
2015-10-26 12:08 ` Pedro Alves
2015-10-28 16:11 ` Oleg Nesterov
2015-10-28 15:43 ` Pedro Alves
2015-10-28 19:02 ` Oleg Nesterov
2015-10-22 13:51 ` Denys Vlasenko
2015-10-20 17:17 ` [PATCH 2/2] wait: allow sys_waitid() to use __WNOTHREAD/__WCLONE/__WALL Oleg Nesterov
2015-10-20 17:36 ` [PATCH 0/2] wait/ptrace: always assume __WALL if the child is traced Oleg Nesterov
2015-10-22 14:40 ` Pedro Alves [this message]
2015-10-25 15:42 ` Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5628F569.4070602@redhat.com \
--to=palves@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dvlasenk@redhat.com \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=gdb@sourceware.org \
--cc=glider@google.com \
--cc=jan.kratochvil@redhat.com \
--cc=jln@google.com \
--cc=kcc@google.com \
--cc=keescook@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=oleg@redhat.com \
--cc=roland@hack.frob.com \
--cc=swiecki@google.com \
--cc=syzkaller@googlegroups.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).