[PATCH] x86-64 TIF flags for debug regs and io bitmap in ctxsw
[sfrench/cifs-2.6.git] / arch / x86_64 / ia32 / ptrace32.c
index a590b7a0d92d46f009b1eab519fa5effe7185279..72bf92a9d37502ce8f33b521371a1e98cfc5ee4a 100644 (file)
@@ -117,6 +117,10 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
                        if ((0x5454 >> ((val >> (16 + 4*i)) & 0xf)) & 1)
                               return -EIO;
                child->thread.debugreg7 = val; 
+               if (val)
+                       set_tsk_thread_flag(child, TIF_DEBUG);
+               else
+                       clear_tsk_thread_flag(child, TIF_DEBUG);
                break; 
                    
        default:
@@ -202,17 +206,24 @@ static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
 {
        int ret;
        compat_siginfo_t *si32 = (compat_siginfo_t *)compat_ptr(data);
+       siginfo_t ssi; 
        siginfo_t *si = compat_alloc_user_space(sizeof(siginfo_t));
        if (request == PTRACE_SETSIGINFO) {
-               ret = copy_siginfo_from_user32(si, si32);
+               memset(&ssi, 0, sizeof(siginfo_t));
+               ret = copy_siginfo_from_user32(&ssi, si32);
                if (ret)
                        return ret;
+               if (copy_to_user(si, &ssi, sizeof(siginfo_t)))
+                       return -EFAULT;
        }
        ret = sys_ptrace(request, pid, addr, (unsigned long)si);
        if (ret)
                return ret;
-       if (request == PTRACE_GETSIGINFO)
-               ret = copy_siginfo_to_user32(si32, si);
+       if (request == PTRACE_GETSIGINFO) {
+               if (copy_from_user(&ssi, si, sizeof(siginfo_t)))
+                       return -EFAULT;
+               ret = copy_siginfo_to_user32(si32, &ssi);
+       }
        return ret;
 }