[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201027192009.GQ2628@hirez.programming.kicks-ass.net>
Date: Tue, 27 Oct 2020 20:20:09 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Andy Lutomirski <luto@...nel.org>
Cc: Kyle Huey <me@...ehuey.com>,
open list <linux-kernel@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Robert O'Callahan <rocallahan@...il.com>,
Alexandre Chartre <alexandre.chartre@...cle.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Petr Mladek <pmladek@...e.com>,
Joel Fernandes <joel@...lfernandes.org>,
Steven Rostedt <rostedt@...dmis.org>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Juergen Gross <jgross@...e.com>,
Brian Gerst <brgerst@...il.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Daniel Thompson <daniel.thompson@...aro.org>
Subject: Re: [REGRESSION] x86/debug: After PTRACE_SINGLESTEP DR_STEP is no
longer reported in dr6
On Tue, Oct 27, 2020 at 11:00:52AM -0700, Andy Lutomirski wrote:
> On Tue, Oct 27, 2020 at 1:19 AM Peter Zijlstra <peterz@...radead.org> wrote:
> >
> > 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) ?
>
> I assume you already figured this out, but my specific concern is with
> the get_si_code(dr6) part -- that's sent directly to the task being
> debugged or debugging itself (and, sadly, to ptrace, and who knows
> what debuggers do).
Right, so for a task doing TF on its own, DR_STEP should remain set in
our on-stack dr6 variable, nothing should consume it.
So the get_si_code(dr6) should be identical. So the only difference is
if DR_STEP is visible in ptrace or not.
Powered by blists - more mailing lists