Merge branch 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / arch / x86 / kernel / ptrace.c
index 1f92958d81658558723b0e99c4cc5e507e5e83b4..8eb1e58de043176759f544ba4425b2e86df5aee4 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/rcupdate.h>
 #include <linux/export.h>
 #include <linux/context_tracking.h>
+#include <linux/nospec.h>
 
 #include <linux/uaccess.h>
 #include <asm/pgtable.h>
@@ -368,22 +369,12 @@ static int putreg(struct task_struct *child,
        case offsetof(struct user_regs_struct,fs_base):
                if (value >= TASK_SIZE_MAX)
                        return -EIO;
-               /*
-                * When changing the FS base, use do_arch_prctl_64()
-                * to set the index to zero and to set the base
-                * as requested.
-                */
-               if (child->thread.fsbase != value)
-                       return do_arch_prctl_64(child, ARCH_SET_FS, value);
+               x86_fsbase_write_task(child, value);
                return 0;
        case offsetof(struct user_regs_struct,gs_base):
-               /*
-                * Exactly the same here as the %fs handling above.
-                */
                if (value >= TASK_SIZE_MAX)
                        return -EIO;
-               if (child->thread.gsbase != value)
-                       return do_arch_prctl_64(child, ARCH_SET_GS, value);
+               x86_gsbase_write_task(child, value);
                return 0;
 #endif
        }
@@ -616,7 +607,8 @@ static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
        unsigned long val = 0;
 
        if (n < HBP_NUM) {
-               struct perf_event *bp = thread->ptrace_bps[n];
+               int index = array_index_nospec(n, HBP_NUM);
+               struct perf_event *bp = thread->ptrace_bps[index];
 
                if (bp)
                        val = bp->hw.info.address;
@@ -718,9 +710,6 @@ static int ioperm_get(struct task_struct *target,
 void ptrace_disable(struct task_struct *child)
 {
        user_disable_single_step(child);
-#ifdef TIF_SYSCALL_EMU
-       clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
-#endif
 }
 
 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION