diff options
author | Roland McGrath <roland@redhat.com> | 2008-07-09 11:39:29 +0200 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2008-07-16 21:15:17 +0200 |
commit | 380fdd7585a4c2f41b48925eba85c0654b7b858b (patch) | |
tree | 3e405cd6cb0be449671ef28c6275fd7ad6b99295 /arch/x86 | |
parent | x86 ptrace: unify syscall tracing (diff) | |
download | linux-380fdd7585a4c2f41b48925eba85c0654b7b858b.tar.xz linux-380fdd7585a4c2f41b48925eba85c0654b7b858b.zip |
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')
-rw-r--r-- | arch/x86/kernel/ptrace.c | 10 | ||||
-rw-r--r-- | arch/x86/kernel/step.c | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 34e77b16a42a..e37dccce85db 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -1416,6 +1416,16 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs) { long ret = 0; + /* + * 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. If we entered on the slow path, TF was already set. + */ + if (test_thread_flag(TIF_SINGLESTEP)) + regs->flags |= X86_EFLAGS_TF; + /* do the secure computing check first */ secure_computing(regs->orig_ax); 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) 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 * cause us to set TF when returning to user mode. |