]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/x86/kernel/step.c
x86 ptrace: user-sets-TF nits
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / step.c
index 0d2cb363ea752a721cf62372c19c8e89423b3756..e8b9863ef8c4f8d09f10344d868450711add7ee5 100644 (file)
@@ -107,6 +107,19 @@ static int enable_single_step(struct task_struct *child)
        struct pt_regs *regs = task_pt_regs(child);
        unsigned long oflags;
 
+       /*
+        * If we stepped into a sysenter/syscall insn, it trapped in
+        * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
+        * If user-mode had set TF itself, then it's still clear from
+        * do_debug() and we need to set it again to restore the user
+        * state so we don't wrongly set TIF_FORCED_TF below.
+        * If enable_single_step() was used last and that is what
+        * set TIF_SINGLESTEP, then both TF and TIF_FORCED_TF are
+        * already set and our bookkeeping is fine.
+        */
+       if (unlikely(test_tsk_thread_flag(child, TIF_SINGLESTEP)))
+               regs->flags |= X86_EFLAGS_TF;
+
        /*
         * Always set TIF_SINGLESTEP - this guarantees that
         * we single-step system calls etc..  This will also