x86_64: Fix compat emulation of PTRACE_GET/SET_THREAD_AREA
authorAndi Kleen <ak@suse.de>
Wed, 17 Oct 2007 16:04:34 +0000 (18:04 +0200)
committerThomas Gleixner <tglx@inhelltoy.tec.linutronix.de>
Wed, 17 Oct 2007 18:15:34 +0000 (20:15 +0200)
Since the 64bit kernel has different indexes for this TLS segments
the address needs to be adjusted in the ptrace 32bit emulation.

[ tglx: arch/x86 adaptation ]

Reported-by: Amnon Shiloh
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/ia32/ptrace32.c

index 4a233ad6269cce1f2e7408af2137f9e8e92ba39a..f52770ef0ee3efea18ca5b44ebbee95117e42f91 100644 (file)
@@ -228,6 +228,8 @@ static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
        return ret;
 }
 
+#define COMPAT_GDT_ENTRY_TLS_MIN 6
+
 asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
 {
        struct task_struct *child;
@@ -246,8 +248,6 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
        case PTRACE_SYSCALL:
        case PTRACE_OLDSETOPTIONS:
        case PTRACE_SETOPTIONS:
-       case PTRACE_SET_THREAD_AREA:
-       case PTRACE_GET_THREAD_AREA:
                return sys_ptrace(request, pid, addr, data); 
 
        default:
@@ -271,6 +271,12 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
        case PTRACE_SETSIGINFO:
        case PTRACE_GETSIGINFO:
                return ptrace32_siginfo(request, pid, addr, data);
+
+       case PTRACE_SET_THREAD_AREA:
+       case PTRACE_GET_THREAD_AREA:
+               return sys_ptrace(request, pid,
+                       addr + GDT_ENTRY_TLS_MIN - COMPAT_GDT_ENTRY_TLS_MIN,
+                       data);
        }
 
        child = ptrace_get_task_struct(pid);