From: Julian Seward Date: Mon, 19 Nov 2007 00:58:18 +0000 (+0000) Subject: When doing ptrace on amd64-linux, provide values which don't fail the X-Git-Tag: svn/VALGRIND_3_3_0~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6ab39f17075ec40c9e76c5e6ce551ef55af4ded;p=thirdparty%2Fvalgrind.git When doing ptrace on amd64-linux, provide values which don't fail the kernel's sanity checks for kernel >= 2.6.21. Fixes #145622. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7183 --- diff --git a/coregrind/m_debugger.c b/coregrind/m_debugger.c index 577d03bae5..d58f919628 100644 --- a/coregrind/m_debugger.c +++ b/coregrind/m_debugger.c @@ -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, ®s); #elif defined(VGP_ppc32_linux)