From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: [patch 3/3] attach-fail-reasons: SELinux deny_ptrace
Date: Tue, 06 Mar 2012 08:35:00 -0000 [thread overview]
Message-ID: <201203060835.q268ZSZY010637@glazunov.sibelius.xs4all.nl> (raw)
In-Reply-To: <20120306061739.GC24004@host2.jankratochvil.net> (message from Jan Kratochvil on Tue, 6 Mar 2012 07:17:39 +0100)
> Date: Tue, 6 Mar 2012 07:17:39 +0100
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
>
> Hi,
>
> and here is the last bit for new SELinux 'deny_ptrace':
> https://bugzilla.redhat.com/show_bug.cgi?id=786878
>
> As even PTRACE_TRACEME fails in such case it needs to install hook for even
> that event.
A few comments inline below...
> --- a/gdb/gdbserver/linux-low.c
> +++ b/gdb/gdbserver/linux-low.c
> @@ -550,6 +550,25 @@ add_lwp (ptid_t ptid)
> return lwp;
> }
>
> +/* Execute PTRACE_TRACEME with error checking. */
> +
> +static void
> +linux_traceme (const char *program)
> +{
> + int save_errno;
> +
> + errno = 0;
> + if (ptrace (PTRACE_TRACEME, 0, NULL, NULL) == 0)
> + return;
Setting errno to zero here is pointless isn't it?
> + save_errno = errno;
> + linux_ptrace_create_warnings ();
> + fprintf (stderr, _("Cannot trace created process %s: %s.\n"), program,
> + strerror (save_errno));
> + fflush (stderr);
> + _exit (0177);
> +}
> --- a/gdb/inf-ptrace.c
> +++ b/gdb/inf-ptrace.c
> @@ -105,7 +105,15 @@ static void
> inf_ptrace_me (void)
> {
> /* "Trace me, Dr. Memory!" */
> + errno = 0;
> ptrace (PT_TRACE_ME, 0, (PTRACE_TYPE_ARG3)0, 0);
> + if (errno != 0)
> + {
> + fprintf_unfiltered (gdb_stderr, _("Cannot create process: %s\n"),
"Cannot trace process: %s"?
> + safe_strerror (errno));
> + gdb_flush (gdb_stderr);
> + _exit (0177);
> + }
> }
next prev parent reply other threads:[~2012-03-06 8:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-06 6:18 Jan Kratochvil
2012-03-06 8:35 ` Mark Kettenis [this message]
2012-03-06 8:42 ` Jan Kratochvil
2012-03-06 19:29 ` Tom Tromey
2012-03-08 6:53 ` [suspend] " Jan Kratochvil
2012-03-08 16:43 ` Tom Tromey
2012-03-08 16:46 ` Jan Kratochvil
2012-03-08 17:50 ` Tom Tromey
2012-03-08 16:51 ` Pedro Alves
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=201203060835.q268ZSZY010637@glazunov.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
/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