Bug 29231 - need a way to produce trampolines not on the stack
Summary: need a way to produce trampolines not on the stack
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.2
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-25 23:21 UTC by Debian GCC Maintainers
Modified: 2009-01-01 21:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2006-09-25 23:21:30 UTC
[forwarded from http://bugs.debian.org/382746]

reported for 4.1 SVN 20060608,

  Matthias

__trampoline_setup in /lib/libgcc_s.so.1 puts code on the stack.

This contributes to insecurity on powerpc.

A half-way fix is to mmap a page for this evil crud.
This still violates good practice, needing the OS to
allow either write+execute or a dangerous transition
from write to execute. It'd be an improvement though.
Doing write+execute may be better, allowing the OS
to locate the page within a segment (256 MiB chunk
on PowerPC) which already has executable pages.

A better method would be to supply a page full of
trampoline functions in libgcc. Each function would:

1. examine its own address
2. map from the page of code to a page of data
3. use that data to implement the trampoline

Trampoline setup would thus involve filling in the
data and choosing the matching function to use.

Once libgcc stops putting code on the stack, gcc
needs to mark all executables as not requiring an
executable stack.
Comment 1 Andrew Pinski 2006-09-25 23:53:49 UTC
Really there is no way to fix this without compiler help.
Comment 2 Geoff Keating 2006-09-26 00:44:45 UTC
If you tried the page-of-functions idea, what would you do if you'd used all the functions on the page and needed another one?
Comment 3 Albert Cahalan 2006-09-26 04:06:36 UTC
(In reply to comment #2)
> If you tried the page-of-functions idea, what would you do if you'd used all
> the functions on the page and needed another one?
> 

You'd do the same as if you'd used up all the stack space.
The existing method doesn't handle running out of room,
and I don't see why the requirements would be any different
for this method.
Comment 4 Andrew Pinski 2009-01-01 21:22:58 UTC
This is why the PowerOpen ABI is good, it does not require stack based trampolines.