From: Roland McGrath <roland@redhat.com>
To: Linus Torvalds <torvalds@transmeta.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] allow ptrace and /proc/PID/mem to read fixmap pages
Date: Sat, 26 Apr 2003 16:46:21 -0700 [thread overview]
Message-ID: <200304262346.h3QNkL129881@magilla.sf.frob.com> (raw)
It's a problem now that ptrace and /proc/PID/mem pretend the vsyscall page
does not exist, and won't let you read it from the inferior. In fact you
can read it from yourself, but programs like a debugger should not have to
know about such magic addresses. I think access_process_vm ought to give
you access to all of the process's adddress space.
This patch is i386-specific and should probably be done another way, but
it's what I am using now. It works and is well-tested.
Thanks,
Roland
--- stock-2.5.68/kernel/ptrace.c Sat Apr 19 19:51:21 2003
+++ linux-2.5.68/kernel/ptrace.c Wed Apr 23 12:39:52 2003
@@ -201,6 +201,25 @@ int access_process_vm(struct task_struct
up_read(&mm->mmap_sem);
mmput(mm);
+#ifdef FIXADDR_START
+ while (len > 0 && addr < FIXADDR_TOP && addr >= FIXADDR_START) {
+ unsigned long pg = addr & PAGE_MASK;
+ int bytes = (len < pg + PAGE_SIZE - addr
+ ? len : pg + PAGE_SIZE - addr);
+ pte_t *pte = pte_offset_kernel(pmd_offset(pgd_offset_k(pg),
+ pg), pg);
+ if (!pte_read(*pte) || (write && !pte_write(*pte)))
+ break;
+ if (write)
+ memcpy((void *)addr, buf, bytes);
+ else
+ memcpy(buf, (const void *)addr, bytes);
+ len -= bytes;
+ buf += bytes;
+ addr += bytes;
+ }
+#endif
+
return buf - old_buf;
}
next reply other threads:[~2003-04-26 23:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-26 23:46 Roland McGrath [this message]
2003-04-26 23:59 ` [PATCH] allow ptrace and /proc/PID/mem to read fixmap pages Jamie Lokier
2003-04-27 1:04 ` Linus Torvalds
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=200304262346.h3QNkL129881@magilla.sf.frob.com \
--to=roland@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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;
as well as URLs for NNTP newsgroup(s).