Messages in this thread | | | Date | Tue, 27 Oct 2020 09:19:32 +0100 | From | Peter Zijlstra <> | Subject | Re: [REGRESSION] x86/debug: After PTRACE_SINGLESTEP DR_STEP is no longer reported in dr6 |
| |
On Mon, Oct 26, 2020 at 04:30:32PM -0700, Andy Lutomirski wrote:
> > @@ -935,6 +936,26 @@ static __always_inline void exc_debug_user(struct pt_regs *regs, > > irqentry_enter_from_user_mode(regs); > > instrumentation_begin(); > > > > + /* > > + * Clear the virtual DR6 value, ptrace routines will set bits here for > > + * things we want signals for. > > + */ > > + current->thread.virtual_dr6 = 0; > > + > > + /* > > + * If PTRACE requested SINGLE(BLOCK)STEP, make sure to reflect that in > > + * the ptrace visible DR6 copy. > > + */ > > + if (test_thread_flag(TIF_BLOCKSTEP) || test_thread_flag(TIF_SINGLESTEP)) > > + current->thread.virtual_dr6 |= (dr6 & DR_STEP); > > I'm guessing that this would fail a much simpler test, though: have a > program use PUSHF to set TF and then read out DR6 from the SIGTRAP. I > can whip up such a test if you like.
Kyle also mentioned it. The reason I didn't do that is because ptrace() didn't set the TF, so why should it see it in ptrace_get_debugreg(6) ?
> Is there any compelling reason not to just drop the condition and do: > > current->thread.virtual_dr6 |= (dr6 & DR_STEP); > > unconditionally? This DR6 cause, along with ICEBP, have the > regrettable distinctions of being the only causes that a user program > can trigger all on its own without informing the kernel first. This > means that we can't fully separate the concept of "user mode is > single-stepping itself" from "ptrace or something else is causing the > kernel to single step a program."
As per the other reply; TF and INT1 should work just fine. virtual_dr6 has nothing to do with that.
| |