Option with emulation of trampolines doesn't work!
Posted: Mon Oct 13, 2003 6:01 am
Here small program:
/* Two nested functions but one trampoline (for passing the address of nested function) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void caller (void (*trampoline)(void))
{
printf("Attempting to call a trampoline...");
//Jump to our nested function
trampoline();
}
void do_trampoline (void)
{
void nested (void)
{
printf("succeeded\n");
}
//If do trampoline impossible-next line lead to error
caller(nested);
}
int main (int argc, char **argv, char **envp)
{
int i=0;
void inner (void) {
i=1;
}
printf("\n\nTesting trampoline:\n\n");
//First nested function
do_trampoline();
//Second nested function-it modify i
printf("Before trampoline i=%d\n",i);
inner();
printf("After trampoline i=%d\n",i);
return 0;
}
-----------------------------------------------------------------------------
If ./grsec_trampo:
PaX ...
Killed
If then (enabling trampolines emulation):
chpax -m grsec_trampo
./grsec_trampo
PaX...
Killed
(Again).What is wrong? grsecurity-patch for 2.4.19. Looks like trampolines emulation doesn't work yet?
Sorry for bad English.
/* Two nested functions but one trampoline (for passing the address of nested function) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void caller (void (*trampoline)(void))
{
printf("Attempting to call a trampoline...");
//Jump to our nested function
trampoline();
}
void do_trampoline (void)
{
void nested (void)
{
printf("succeeded\n");
}
//If do trampoline impossible-next line lead to error
caller(nested);
}
int main (int argc, char **argv, char **envp)
{
int i=0;
void inner (void) {
i=1;
}
printf("\n\nTesting trampoline:\n\n");
//First nested function
do_trampoline();
//Second nested function-it modify i
printf("Before trampoline i=%d\n",i);
inner();
printf("After trampoline i=%d\n",i);
return 0;
}
-----------------------------------------------------------------------------
If ./grsec_trampo:
PaX ...
Killed
If then (enabling trampolines emulation):
chpax -m grsec_trampo
./grsec_trampo
PaX...
Killed
(Again).What is wrong? grsecurity-patch for 2.4.19. Looks like trampolines emulation doesn't work yet?
Sorry for bad English.