Re: [PATCH] RFC x86_64 more accurate KSTK_ESP implementation

From: Stefani Seibold
Date: Sun Nov 08 2009 - 07:52:05 EST


Am Sonntag, den 08.11.2009, 12:35 +0100 schrieb Ingo Molnar:
> * Stefani Seibold <stefani@xxxxxxxxxxx> wrote:
>
> > +
> > + if (((stkp < stk) || (stkp >= stk + THREAD_SIZE))
> > + && regs->ip < PAGE_OFFSET)
> > + percpu_write(old_rsp, stkp);
> > +}
>
> that check for regs->ip looks imprecise - why dont you use the
> user_mode_vm()?
>
> It's true that the value itself is statistical, but still we dont want
> to leak a kernel-space regs->sp reason - it's an information leak.
>

Good idea. Much better ;-)


> > --- linux-2.6.32-rc5.old/arch/x86/kernel/irq_64.c 2009-10-16 02:41:50.000000000 +0200
> > +++ linux-2.6.32-rc5.new/arch/x86/kernel/irq_64.c 2009-11-04 22:29:55.762951577 +0100
> > @@ -53,6 +53,7 @@
> > struct irq_desc *desc;
> >
> > stack_overflow_check(regs);
> > + update_usersp(regs);
> >
> >
> > desc = irq_to_desc(irq);
> > if (unlikely(!desc))
> > --- linux-2.6.32-rc5.old/arch/x86/kernel/apic/apic.c 2009-10-16 02:41:50.000000000 +0200
> > +++ linux-2.6.32-rc5.new/arch/x86/kernel/apic/apic.c 2009-11-04 23:12:32.805086991 +0100
> > @@ -831,6 +831,9 @@
> > {
> > struct pt_regs *old_regs = set_irq_regs(regs);
> >
> > +#ifndef CONFIG_X86_32
> > + update_usersp(regs);
> > +#endif
>
> Cleanliness: please eliminate this #ifdef by defining update_usersp() on
> 32-bit as well, as an empty inline function.
>
> But, i dont like this patch because it adds overhead to the IRQ
> fastpath.
>

Agree, but i saw no other way.

> I'd suggest a competely different method: why dont you use an IPI to
> sample the SP whenever someone wants to read it from /proc and we see
> that the task is running on a CPU right now?
>

Sounds like a challenge, i like the idea. I will have a look on it...

Stefani


--
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/