[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Safe stack overflow




Am 24.02.2014 um 22:02 schrieb Miro Kropáček <miro.kropacek@gmail.com>:


On Mon, Feb 24, 2014 at 9:57 PM, Jo Even Skarstein <joska@online.no> wrote:
Ok, you mean to put the stack at the very beginning of the TPA to
trigger a memory violation when the stack overflows? If so, that's an
interesting idea. You'll get stack checking for free.
That was exactly the idea. We're so used to the fact that the stack has to be "above" the program area but there's actually nothing which would stop us to put it "below". Two things have to be changed: Pexec() and the crt0 startup code (Mshrink() handling), if I'm not mistaken. Should be pretty easy, I could even do it but I'd like to hear other people's opinion first.


Hmmm. I don’t get it.

The article talks about putting the stack into the very beginning of memory to trigger a fault on stack pointer underflow.

This won’t work on m68k in my opinion.

If you have a machine with VBR, you could move exception vectors out of the way which AFAIK wouldn’t help much since the stack pointer would just wrap around on m68k.

You could of course use memory protection to protect the stack, but that probably would only need slight changes to your program, not necessarily to MiNT: just put the stack into a malloc’d region and make sure you don’t own adjacent memory below.