views:

66

answers:

2

I am currently testing the kernel back tracing mechanism ( like dump_stack and frame_unwind ). I want to know whether the kernel back tracing mechanism can still give the back trace if the kernel stack got corrupted. If not, then what would be the output in that case. Please suggest me a way so that I can corrupt the kernel stack by writing a function ( which i will embed between some kernel execution path ) or a module.

A: 

How about this:

void overflow_stack() {
    int p[1];
    int i;

    for(i = 0; i < 1024; i++) {
        p[i] = i;
    }
}
Sun Jian
+1  A: 

Another one:

#define VALUE 1
#define HUGESIZE 50
void overflow()
{
    char buffer[0];
    printk("Overflowing stack.. \n");
    memset(buffer, VALUE, HUGESIZE);
}
Bandan