Re: [PATCH 3/5] uprobes: Fix UPROBE_SKIP_SSTEP checks inhandle_swbp()

From: Oleg Nesterov
Date: Mon Sep 24 2012 - 16:07:04 EST


Srikar, sorry for delay, somehow I missed this email.

And I am still confused...

On 09/20, Srikar Dronamraju wrote:
>
> * Oleg Nesterov <oleg@xxxxxxxxxx> [2012-09-18 18:07:38]:
>
> > > > I compiled this program
> > > >
> > > > int main(void)
> > > > {
> > > > asm volatile (".word 0x1f0f");
> > > > return 0;
> > > > }
> > > >
> > > > and objdump reports:
> > > >
> > > > 000000000040047c <main>:
> > > > 40047c: 0f 1f 31 nopl (%rcx)
> > >
> > > Current uprobes code wouldnt skip the above insn because it has 31
> > > following it.
> >
> > See above.
> >
> > And again, could you explain which insn has 1f0f (at the end or not) ?
> > IOW, what we are trying to skip?
>
> Again its 0f1f and not 1f0f

The first byte is 0x0f, the next is 0x1f, so 0x1f0f looks correct,
but this doesn't matter.

Anyway,

> for example
> 0f 1f 40 00

OK, thanks, objdump reports "nopl 0x0(%rax)", looks fine.

But. I do not see how __skip_sstep() can handle this case correctly.
Not only it should update regs->ip afaics, it should also account 2
extra bytes _after_ 0f 1f.

> 0f 1f 44 00 00

OK, nopl 0x0(%rax,%rax,1), but in this case we need to skip 3
extra bytes.


I am starting to think this code is broken and we should simply remove
all checks except 0x66 and 0x90. In this case we do not even need to
update regs->ip.

Otherwise this code needs to know the insn's length.

Right?

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/