Messages in this thread | | | Subject | Re: [PATCH] x86/ptrace: Remove questionable TS_COMPAT usage in ptrace | From | Pedro Alves <> | Date | Mon, 20 Jun 2016 11:07:56 +0100 |
| |
On 06/18/2016 06:02 PM, Andy Lutomirski wrote:
> Yuck. I should have dug in to the history. Why not just > unconditionally sign-extend eax when set by a 32-bit tracer?
No idea.
> > Do you know how to acquire a copy of erestartsys-trap.c? The old > links appear to be broken.
That's part of the ptrace testsuite project, still in cvs, though the url changed:
$ https://sourceware.org/systemtap/wiki/utrace/tests
$ cvs -d :pserver:anoncvs:anoncvs@sourceware.org:/cvs/systemtap co ptrace-tests
Can't seem to find a cvsweb interface for that.
I think it'd be great to move these to the selftests infrastructure directly in the kernel tree. However, nobody's has ever managed to find energy for that.
> > Also, while I have your attention: when gdb restores old state like > this, does it do it with individual calls to PTRACE_POKEUSER or does > it use SETREGSET or similar to do it all at once? I'm asking because > I have some other code (fsgsbase) that's on hold until I can figure > out how to keep it from breaking gdb if and when gdb writes to fs and > fs_base. >
It depends on which register you're accessing, and on kernel version. But on a recent kernel, it should be using PTRACE_SETREGS / PTRACE_SETREGSET, thus storing a whole register set in one go. (And it's likely we could get rid of PTRACE_POKE fallback paths by now.) To write to the debug registers (dr0-dr7), PTRACE_POKEUSER is always used.
There's code that coordinates with glibc's libthread_db.so that ends up _reading_ fs_base/gs_base, and gdb uses PTRACE_PEEKUSER for that, though there's a pending series that changes it, exposing fs_base/gs_base as just another register in gdb's register cache:
https://www.sourceware.org/ml/gdb-patches/2015-11/msg00076.html https://www.sourceware.org/ml/gdb-patches/2015-11/msg00077.html
Guess that makes fs_base/gs_base user-writable, if the kernel allows it.
Thanks, Pedro Alves
| |