aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/step.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-07-09 05:39:29 -0400
committerRoland McGrath <roland@redhat.com>2008-07-16 15:15:17 -0400
commit380fdd7585a4c2f41b48925eba85c0654b7b858b (patch)
tree3e405cd6cb0be449671ef28c6275fd7ad6b99295 /arch/x86/kernel/step.c
parentd4d67150165df8bf1cc05e532f6efca96f907cab (diff)
x86 ptrace: user-sets-TF nits
This closes some arcane holes in single-step handling that can arise only when user programs set TF directly (via popf or sigreturn) and then use vDSO (syscall/sysenter) system call entry. In those entry paths, the clear_TF_reenable case hits and we must check TIF_SINGLESTEP to be sure our bookkeeping stays correct wrt the user's view of TF. Signed-off-by: Roland McGrath <roland@redhat.com>
Diffstat (limited to 'arch/x86/kernel/step.c')
-rw-r--r--arch/x86/kernel/step.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
index 0d2cb363ea75..e8b9863ef8c4 100644
--- a/arch/x86/kernel/step.c
+++ b/arch/x86/kernel/step.c
@@ -108,6 +108,19 @@ static int enable_single_step(struct task_struct *child)
108 unsigned long oflags; 108 unsigned long oflags;
109 109
110 /* 110 /*
111 * If we stepped into a sysenter/syscall insn, it trapped in
112 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
113 * If user-mode had set TF itself, then it's still clear from
114 * do_debug() and we need to set it again to restore the user
115 * state so we don't wrongly set TIF_FORCED_TF below.
116 * If enable_single_step() was used last and that is what
117 * set TIF_SINGLESTEP, then both TF and TIF_FORCED_TF are
118 * already set and our bookkeeping is fine.
119 */
120 if (unlikely(test_tsk_thread_flag(child, TIF_SINGLESTEP)))
121 regs->flags |= X86_EFLAGS_TF;
122
123 /*
111 * Always set TIF_SINGLESTEP - this guarantees that 124 * Always set TIF_SINGLESTEP - this guarantees that
112 * we single-step system calls etc.. This will also 125 * we single-step system calls etc.. This will also
113 * cause us to set TF when returning to user mode. 126 * cause us to set TF when returning to user mode.