Re: Wanted: simple, safe x86 stack overflow detection



On Wed, Feb 28, 2007 at 09:27:09AM -0500, Chuck Ebbert wrote:
Can we just put a canary in the threadinfo and check it on every
task switch? What are the drawbacks?

Likely already too late then -- if critical state is overwritten
you crashed before. Also a lot of stack intensive codes
relatively large unused holes so it might miss the canary completely

Anyways if you want a crash on context switch in the non
hole case you can probably get it by just rearranging thread_info a bit.
e.g. put preempt_count first. Any corruption of that will lead
to schedule complaining.

Don't think it is worth it though.

I suppose one could have a CONFIG_DEBUG_STACK_OVERFLOW that gets
the stacks from vmalloc which would catch any overflow with its
guard pages. This is you would need to change __pa() to handle
that too because there might be still some drivers that do
DMA on stack addresses. Would be somewhat ugly but doable.

But I have my doubts it is worth it again -- in my experience static
analysis works well enough to trace them down and
there are not that many anyways.

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



Relevant Pages

  • Re: Wanted: simple, safe x86 stack overflow detection
    ... relatively large unused holes so it might miss the canary completely ... Don't think it is worth it though. ... DMA on stack addresses. ... case of memory corruption sounds like an extremely good idea to me. ...
    (Linux-Kernel)
  • Cant use stack below ESP.
    ... Without doing proper homework I have assumed that use of the stack below ESP ... and as a result of this interrupt the program flow ... switches to another code segment (including task switch) that is of equal ... have found that out during debugging session. ...
    (borland.public.delphi.language.basm)
  • Re: RTX-51 Full reentrant stack problem
    ... stack is located in PDATA, yet during a task switch, ... RTX-51thinks the stack is located near the task control block in XDATA ... Not used rtx for a while, but if I recall, to use compact reentrant you will ...
    (comp.arch.embedded)
  • Re: Mid-tournament confrontations?
    ... >confrontation with another player who has me covered by relatively a lot. ... Do you play better as a big stack? ... In a perfect world, chips have ... where I think a big stack may be worth more than two medium stacks. ...
    (rec.gambling.poker)
  • Re: NLHE hand for discussion
    ... Obviously raising here in limit is worth a shot. ... But he also has a betting pattern very similar to a guy ... What we do depends on what the stack size of the cutoff is. ... I think calling is the absolute best play here. ...
    (rec.gambling.poker)