]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
When doing ptrace on amd64-linux, provide values which don't fail the
authorJulian Seward <jseward@acm.org>
Mon, 19 Nov 2007 00:58:18 +0000 (00:58 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 19 Nov 2007 00:58:18 +0000 (00:58 +0000)
kernel's sanity checks for kernel >= 2.6.21.  Fixes #145622.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7183

coregrind/m_debugger.c

index 577d03bae52383c6c42e54039db4c58509b79077..d58f919628c28914506f2e6c63391e2373a54981 100644 (file)
@@ -87,6 +87,21 @@ static Int ptrace_setregs(Int pid, VexGuestArchState* vex)
    regs.r15    = vex->guest_R15;
    regs.eflags = LibVEX_GuestAMD64_get_rflags(vex);
    regs.rip    = vex->guest_RIP;
+   /* Set %{c,d,e,f,s,g}s and %{fs,gs}_base (whatever those are) to
+      values which don't fail the kernel's sanity checks.  I have no
+      idea what these should really be set to.  Anyway, mostly it
+      seems that zero is an allowable value, except for %cs and %ss
+      which have to have their lowest 2 bits be 11.  See putreg() in
+      linux-2.6.23/arch/x86_64/kernel/ptrace.c for the apparently
+      relevant sanity checks.  This fixes #145622. */
+   regs.cs      = 3;
+   regs.ds      = 0;
+   regs.es      = 0;
+   regs.fs      = 0;
+   regs.ss      = 3;
+   regs.gs      = 0;
+   regs.fs_base = 0;
+   regs.gs_base = 0;
    return VG_(ptrace)(VKI_PTRACE_SETREGS, pid, NULL, &regs);
 
 #elif defined(VGP_ppc32_linux)