linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Simon.Richter@hogyros.de (Simon Richter)
To: linux-arm-kernel@lists.infradead.org
Subject: ptrace(PTRACE_PEEKUSER, ..., PT_TEXT_ADDR, ...)
Date: Fri, 20 Aug 2010 14:41:28 +0200	[thread overview]
Message-ID: <20100820124118.GC6950@richter> (raw)

Hi,

when patching gdbserver to work on MMUless ARM systems I found that
there are two definitions for the magic values for PT_TEXT_ADDR (and the
related fields) in different Linux versions. uClinux 2.4 kernels use
values starting from 0xc4 (the same as the Coldfire port), while 2.6
based kernels use magic numbers starting from 0x10000, which were
introduced in 68b7f7153fa58df710924fbb79722717d2d16094 .

As has been pointed out by Andreas Schwab from SuSE, the code
responsible for returning the text segment address is never reached
because the lines immediately before the code added in the commit
already filter these out and return -EIO.

So apparently the new values have never really been in use (so I
wouldn't consider them part of the kernel interface), and the old values
now point to something else (because VFP registers were added to struct
user).

The "new" values are published in <asm/ptrace.h>, and according to a
quick search on koders.com, no one but gdb even mentions that name; gdb
only does so in gdbserver/linux-low.c, where the entire block that
retrieves the offsets is conditional, and as <sys/ptrace.h> does not
pull in <asm/ptrace.h> and gdbserver only includes the former, hence the
current mechanism is unused on ARM, and debugging on MMUless systems is
broken.

How should this be resolved?

Option 1 would be to exempt the magic values from the size check in
arch/arm/kernel/ptrace.c. That would probably introduce the least
breakage, should libc ever decide to include <asm/ptrace.h> from
<sys/ptrace.h> and someone else use the new libc headers with old kernel
headers.

Option 2 is to move the values to the user page. This way, the special
case in ptrace.c could go away, however it would make the values
writeable via ptrace(), which would probably be undesirable.

Additionally, we could introduce a warning if anyone uses 0xc4, 0xc8 or
0xcc as offsets without also reading at 0xc0 before; this way, people
using the "old" interface can be told to upgrade.

Opinions?

   Simon

             reply	other threads:[~2010-08-20 12:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-20 12:41 Simon Richter [this message]
2010-09-01  7:17 ` ptrace(PTRACE_PEEKUSER, ..., PT_TEXT_ADDR, ...) Russell King - ARM Linux
2010-09-01  8:01   ` Simon Richter

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=20100820124118.GC6950@richter \
    --to=simon.richter@hogyros.de \
    --cc=linux-arm-kernel@lists.infradead.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).