Re: [patch 15/14] x86/dumpstack/64: Speedup in_exception_stack()
From: Andy Lutomirski
Date: Wed Apr 03 2019 - 20:03:34 EST
On Wed, Apr 3, 2019 at 12:42 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> On Wed, 3 Apr 2019, Thomas Gleixner wrote:
> > On Tue, 2 Apr 2019, Andy Lutomirski wrote:
> > > > On Apr 2, 2019, at 1:29 PM, Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> > > >>> How about a much better fix: make the DB stack be the same size as all
> > > >>> the others and just have 4 of them (DB0, DB1, DB2, and DB3. After all,
> > > >>> overflowing from one debug stack into another is just as much of a bug as
> > > >>> overflowing into a different IST stack.
> > > >>
> > > >> That makes sense.
> > > >
> > > > Except that we just have two not four.
> > > >
> > > > It needs some tweaking of the ist_shift stuff in entry_64.S but that's not
> > > > rocket science. Famous last words....
> > > >
> > >
> > > The ist_shift mess should probably be in C, but thatâs a big can of
> > > worms. That being said, why do we have it at all? Once upon a time, weâd
> > > do ICEBP from user mode (or a legit breakpoint), then send a signal and
> > > hit a data breakpoint, and weâd recurse. But we donât run user debug
> > > handlers on the IST stack at all anymore.
> > >
> > > Maybe we can convince ourselves itâs safe?
> >
> > Maybe. Need to think about it for a while.
>
> What about kprobes. It has nasty reentrancy stuff as well...
>
Hmm. We used to have #BP on the same stack, and I bet there were
plenty of ways to get #DB and #BP inside each other.
I bet the best solution is to set dr7 to 0 before we do anything
complicated in do_debug() (at least if we got there from kernel mode).
But we should probably make this a whole separate project after your
series is done.