From 39fe3547681a2661901f82da6095fb6d6eaa3894 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 30 Jan 2008 13:30:58 +0100 Subject: [PATCH] --- yaml --- r: 79903 b: refs/heads/master c: ce90f340855d7a9b3bec24f0fe49a76904242387 h: refs/heads/master i: 79901: adf0186625ea04bc0911f099a5603c818a4b2b99 79899: 2641fa3f950f0e62c76f587e38d798d7d4105189 79895: d7423e0aba5869f4a3c33c8b468a594161dff92e 79887: 6a88b378621070cc2571b18a4615abdae09a9001 79871: 60968cb354e81a85c9ff1e67f8f4ebfa901ee4cd v: v3 --- [refs] | 2 +- trunk/arch/x86/kernel/ptrace_64.c | 36 +++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index ced7d7ce2f9c..53f529a1ae63 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9e714bed644cb463489b9250774a4b0fb352cabc +refs/heads/master: ce90f340855d7a9b3bec24f0fe49a76904242387 diff --git a/trunk/arch/x86/kernel/ptrace_64.c b/trunk/arch/x86/kernel/ptrace_64.c index 2427548f2a01..5979dbe8e0a2 100644 --- a/trunk/arch/x86/kernel/ptrace_64.c +++ b/trunk/arch/x86/kernel/ptrace_64.c @@ -67,21 +67,29 @@ static int putreg(struct task_struct *child, if (value && (value & 3) != 3) return -EIO; child->thread.fsindex = value & 0xffff; + if (child == current) + loadsegment(fs, child->thread.fsindex); return 0; case offsetof(struct user_regs_struct,gs): if (value && (value & 3) != 3) return -EIO; child->thread.gsindex = value & 0xffff; + if (child == current) + load_gs_index(child->thread.gsindex); return 0; case offsetof(struct user_regs_struct,ds): if (value && (value & 3) != 3) return -EIO; child->thread.ds = value & 0xffff; + if (child == current) + loadsegment(ds, child->thread.ds); return 0; case offsetof(struct user_regs_struct,es): if (value && (value & 3) != 3) return -EIO; child->thread.es = value & 0xffff; + if (child == current) + loadsegment(es, child->thread.es); return 0; case offsetof(struct user_regs_struct,ss): if ((value & 3) != 3) @@ -135,14 +143,32 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno) { struct pt_regs *regs = task_pt_regs(child); unsigned long val; + unsigned int seg; switch (regno) { case offsetof(struct user_regs_struct, fs): + if (child == current) { + /* Older gas can't assemble movq %?s,%r?? */ + asm("movl %%fs,%0" : "=r" (seg)); + return seg; + } return child->thread.fsindex; case offsetof(struct user_regs_struct, gs): + if (child == current) { + asm("movl %%gs,%0" : "=r" (seg)); + return seg; + } return child->thread.gsindex; case offsetof(struct user_regs_struct, ds): + if (child == current) { + asm("movl %%ds,%0" : "=r" (seg)); + return seg; + } return child->thread.ds; case offsetof(struct user_regs_struct, es): + if (child == current) { + asm("movl %%es,%0" : "=r" (seg)); + return seg; + } return child->thread.es; case offsetof(struct user_regs_struct, fs_base): /* @@ -152,7 +178,10 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno) */ if (child->thread.fs != 0) return child->thread.fs; - if (child->thread.fsindex != FS_TLS_SEL) + seg = child->thread.fsindex; + if (child == current) + asm("movl %%fs,%0" : "=r" (seg)); + if (seg != FS_TLS_SEL) return 0; return get_desc_base(&child->thread.tls_array[FS_TLS]); case offsetof(struct user_regs_struct, gs_base): @@ -161,7 +190,10 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno) */ if (child->thread.gs != 0) return child->thread.gs; - if (child->thread.gsindex != GS_TLS_SEL) + seg = child->thread.gsindex; + if (child == current) + asm("movl %%gs,%0" : "=r" (seg)); + if (seg != GS_TLS_SEL) return 0; return get_desc_base(&child->thread.tls_array[GS_TLS]); case offsetof(struct user_regs_struct, flags):