|
|
Subscribe / Log in / New account

Preventing stack guard-page hopping

Preventing stack guard-page hopping

Posted Jun 20, 2017 15:08 UTC (Tue) by nybble41 (subscriber, #55106)
In reply to: Preventing stack guard-page hopping by nix
Parent article: Preventing stack guard-page hopping

> you write your C program in continuation-passing style, with GCed data in functions that never return but only call on to others that do the same, and then when you want to do a GC your collector copies the relevant data into a new "stack" on the heap and alloca()s to it

That is... diabolical. Genius, but diabolical. A similar concept employed by Chicken Scheme is to start out the same way, using CPS and allocating on the C stack, but then after copying the live data to the heap just perform a longjmp() to unwind back to a trampoline function at the top of the original stack. That seems slightly saner than abusing alloca() to set the stack pointer.


to post comments

Preventing stack guard-page hopping

Posted Jun 21, 2017 11:26 UTC (Wed) by nix (subscriber, #2304) [Link] (1 responses)

Chicken Scheme actually uses the same scheme (derived directly from the paper). :) I guess they shifted from alloca() to longjmp() at some point, probably some compatibility problem which would make my head melt to think about.

Preventing stack guard-page hopping

Posted Jun 21, 2017 14:41 UTC (Wed) by zblaxell (subscriber, #26385) [Link]

> they shifted from alloca() to longjmp() at some point, probably some compatibility problem...

...like some eager tools maintainer implementing alloca() parameter sanity checks, perhaps? ;)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds