lkml.org 
[lkml]   [1996]   [Dec]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Stack overflows.
Date

Bernd Schmidt <crux@pool.informatik.rwth-aachen.de> writes:
>
> [trampoline code on the stack ]
> Why does GNU libc use them, then? Shouldn't this be fixed?
>
It's not that easy.

Suppose you have

foo(something) {
int baz;
bar() {
...something and baz ...
}

... grumble(bar);
}

If you don't use nested functions you need to either change the interface
of grumble() to pass all the parameters necessary for bar(), which is
impossible (sometimes it's frozen in POSIX / current usage / whatever), or
you need to use global variables (which gets you in serious trouble with
multithreaded code).

The problem with not doing the trampolines on the stack is that you need to
allocate the space for the trampoline code _somewhere_. This means that
you'll need to be able to free it again. This is difficult (think about
longjmp()). You could use an alloca() version which doesn't use the stack,
but then you'll need to have some way to make the data space alloca()
returns executable. Ugh -- IMHO, I'd rather mark the stack as executable
than (bits scattered throughout) my whole malloc arena.

--
Everything was fine until they invented four-letter words:
WORK
HARD WORK
VERY HARD WORK
--
Matthias Urlichs \ noris network GmbH / Xlink-POP Nürnberg
Schleiermacherstraße 12 \ Linux+Internet / EMail: urlichs@noris.de
90491 Nürnberg (Germany) \ Consulting+Programming+Networking+etc'ing
PGP: 1024/4F578875 1B 89 E2 1C 43 EA 80 44 15 D2 29 CF C6 C7 E0 DE
Click <A HREF="http://info.noris.de/~smurf/finger">here</A>. 42

\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.078 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site