x86_64: ia32 ptrace THREAD_AREA fix

The addr argument to PTRACE_GET_THREAD_AREA and PTRACE_SET_THREAD_AREA is
not a magic constant. It's derived from the segment register values being
used, which are computed originally from the index used with set_thread_area.
The value does not need to match what a native i386 kernel would accept.
It needs to match the segment selectors that can actually be in use in this
32-bit process. The 64-bit ptrace support for PTRACE_GET_THREAD_AREA
(normally used only on 32-bit processes) is correct, but the 32-bit emulation
of ptrace is broken.

Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by Roland McGrath and committed by Thomas Gleixner fd181c72 1a0c3ea6

+2 -8
+2 -8
arch/x86/ia32/ptrace32.c
··· 228 228 return ret; 229 229 } 230 230 231 - #define COMPAT_GDT_ENTRY_TLS_MIN 6 232 - 233 231 asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) 234 232 { 235 233 struct task_struct *child; ··· 246 248 case PTRACE_SYSCALL: 247 249 case PTRACE_OLDSETOPTIONS: 248 250 case PTRACE_SETOPTIONS: 251 + case PTRACE_SET_THREAD_AREA: 252 + case PTRACE_GET_THREAD_AREA: 249 253 return sys_ptrace(request, pid, addr, data); 250 254 251 255 default: ··· 271 271 case PTRACE_SETSIGINFO: 272 272 case PTRACE_GETSIGINFO: 273 273 return ptrace32_siginfo(request, pid, addr, data); 274 - 275 - case PTRACE_SET_THREAD_AREA: 276 - case PTRACE_GET_THREAD_AREA: 277 - return sys_ptrace(request, pid, 278 - addr + GDT_ENTRY_TLS_MIN - COMPAT_GDT_ENTRY_TLS_MIN, 279 - data); 280 274 } 281 275 282 276 child = ptrace_get_task_struct(pid);