This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix for PR breakpoints/16297: Fix catch syscall to work with syscall 0
- From: Pedro Alves <palves at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>
- Cc: gdb-patches at sourceware dot org, Gabriel Krisman Bertazi <gabriel at krisman dot be>
- Date: Thu, 19 Dec 2013 16:21:22 +0000
- Subject: Re: [PATCH] Fix for PR breakpoints/16297: Fix catch syscall to work with syscall 0
- Authentication-results: sourceware.org; auth=none
- References: <87fvpu4vgh dot fsf at lestat dot krisman dot be> <m3mwk24v5w dot fsf at redhat dot com> <52AF3DA0 dot 3020406 at redhat dot com> <52AF3F0F dot 3030107 at redhat dot com> <m338lszn95 dot fsf at redhat dot com> <52AF47D5 dot 1040304 at redhat dot com> <m3lhzhqz1j dot fsf at redhat dot com>
On 12/19/2013 03:50 AM, Sergio Durigan Junior wrote:
> @@ -27,6 +29,8 @@ main (void)
>
> chroot (".");
>
> + read (0, NULL, 0);
I think the C implementation (libc or the compiler) is
free to skip actually calling the syscall, given bytes is 0.
Something like creating a pipe, and reading a byte off
of it might be safer. But I won't object to leaving
this as is for now.
> static int chroot_syscall = SYS_chroot;
> +/* The "read" syscall is zero on x86_64. */
> +static int read_syscall = SYS_read;
Future readers who might not be familiar with this bug
probably won't realize that the emphasis should be on
zero, rather than the comment just happening to be
trying to be informative. I'd suggest extending the comment:
+/* GDB had a bug where it couldn't catch syscall number 0. In most
+ Linux architectures, syscall number 0 is restart_syscall, which
+ can't be called from userspace. However, the "read" syscall
+ is zero on x86_64. */
+static int read_syscall = SYS_read;
Otherwise looks fine to me.
Thanks!
--
Pedro Alves