public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/17] arm: arch_ptrace clean-up
Date: Tue, 23 Jun 2009 23:55:59 -0700 (PDT)	[thread overview]
Message-ID: <20090624065600.040F24059B@magilla.sf.frob.com> (raw)
In-Reply-To: Russell King's message of  Friday, 19 June 2009 10:13:23 +0100 <20090619091323.GA18246@flint.arm.linux.org.uk>

> It also changes the semantics a bit, and I don't buy the "it doesn't
> matter" comments, especially in the PT_SINGLESTEP case.  Having
> PT_SINGLESTEP set the flag but later fail is not nice behaviour at all,
> it means that, despite the ptrace call failing, the next time that the
> task encounters a signal, it will enter single stepping mode.

The reason my comment says "before it matters" is precisely because I don't
think this scenario is possible.  (And hence that it does not change the
user-visible semantics at all.)  If I'm wrong about that, then all that's
required is to drop the comments about not error-checking and reintroduce:

			ret = -EIO;
			if (!valid_signal(data))
				break;

at the top of both cases that end in "goto common;".  That is the only
error case ptrace_request() can diagnose for those requests.

Here's why I think that my comment:

		 * It's harmless in the error case, since we will have
		 * come back through here or PTRACE_SINGLESTEP again
		 * before it matters.

is correct and thus the check above is superfluous.  

If we are in arch_ptrace() at all, it means we have already been through
ptrace_check_attach() successfully, so the child is in TASK_TRACED.  (Or
else it's simultaneously being woken up by SIGKILL and dying, which is
already required to be harmless to things arch_ptrace() might do.)  Aside
from SIGKILL, nothing else can wake the child from TASK_TRACED but ptrace.
If it's SIGKILL, then no harm done no matter what the state of the
single-step machinery--it never even tries to get back to user mode anyway.

If it's ptrace, then that's what "back through here" means in the comment:
it will be in one of these same cases in arch_ptrace() that calls either
single_step_disable() or single_step_enable().  Again, no harm done,
because the state was reset as desired before resuming in user mode.

I don't know what exactly "task encounters a signal" meant in your
description of a failure mode.  If it means "a signal is sent" (generated),
then this does not wake the task from TASK_TRACED, where we know it is
sitting in this scenario, unless it was SIGKILL.  If it means "a signal is
dequeued and processed" (delivered), then this only happens after the task
has been woken up from TASK_TRACED.  That happens by SIGKILL, in which case
user mode is never seen again (zero steps already < single step), or by
ptrace, in which case it will or won't enter single stepping mode, exactly
as directed by that (second, successful) ptrace call.

Did I misunderstand which scenario you had in mind,
or am I mistaken about how that scenario is ruled out?


Thanks,
Roland

  reply	other threads:[~2009-06-24  6:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-25  0:06 [PATCH 0/17] tracehook & user_regset for ARM Roland McGrath
2009-04-25  0:07 ` [PATCH 01/17] arm: arch_ptrace clean-up Roland McGrath
2009-06-19  9:13   ` Russell King
2009-06-24  6:55     ` Roland McGrath [this message]
2009-04-25  0:08 ` [PATCH 02/17] arm: arch_ptrace indentation Roland McGrath
2009-04-25  0:08 ` [PATCH 03/17] arm: tracehook_report_syscall Roland McGrath
2009-04-25  0:09 ` [PATCH 04/17] arm: tracehook_signal_handler Roland McGrath
2009-04-25  0:09 ` [PATCH 05/17] arm: TIF_NOTIFY_RESUME Roland McGrath
2009-04-25  0:10 ` [PATCH 06/17] arm: user_regset: general regs Roland McGrath
2009-04-25  0:10 ` [PATCH 07/17] arm: user_regset: FPU regs Roland McGrath
2009-04-25  0:11 ` [PATCH 08/17] arm: CORE_DUMP_USE_REGSET Roland McGrath
2009-04-25  0:11 ` [PATCH 09/17] arm: user_regset: VFP regs Roland McGrath
2009-04-25  0:12 ` [PATCH 10/17] arm: user_regset: VFP in core dumps Roland McGrath
2009-04-25  0:12 ` [PATCH 11/17] arm: user_regset: iWMMXt regs Roland McGrath
2009-04-25  0:12 ` [PATCH 12/17] arm: user_regset: iWMMXt in core dumps Roland McGrath
2009-04-27 22:43   ` Paul Mundt
2009-04-28  2:53     ` Roland McGrath
2009-04-25  0:13 ` [PATCH 13/17] arm: user_regset: Crunch regs Roland McGrath
2009-04-25  0:13 ` [PATCH 14/17] arm: user_regset: Crunch in core dumps Roland McGrath
2009-04-25  0:14 ` [PATCH 15/17] arm: user_regset: thread pointer " Roland McGrath
2009-04-25  0:15 ` [PATCH 16/17] arm: asm/syscall.h (unfinished) Roland McGrath
2009-06-19  9:31   ` Russell King
2009-06-24  8:56     ` Roland McGrath
2009-04-25  0:15 ` [PATCH 17/17] arm: HAVE_ARCH_TRACEHOOK Roland McGrath
2009-06-06 14:42 ` [PATCH 0/17] tracehook & user_regset for ARM Christoph Hellwig

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=20090624065600.040F24059B@magilla.sf.frob.com \
    --to=roland@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@arm.linux.org.uk \
    /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