stack overflow
From: Breno
Date: Fri Sep 12 2003 - 16:56:49 EST
Hi ... this is my idea to check a stack overflow. What do you think ?
#define STACK_LIMIT (1024*8192)/PAGE_SIZE
int check_stack_overflow(struct task_struct *tsk)
{
unsigned long stack_size,stack_addr,stack_ptr;
int i;
if(tsk->mm != NULL)
{
stack_addr = tsk->mm->start_stack;
stack_ptr = tsk->thread.esp;
for(i=0; i < stack_ptr; i++)
stack_addr++;
stack_size = (stack_addr - stack_ptr)/PAGE_SIZE;
if(stack_size > ( STACK_LIMIT - 1))
{
printk(KERN_CRIT"Process %s : pid %d -
Can cause stack
overflow\n",tsk->comm,tsk->pid);
return 0;
}
}
return 0;
}
att,
Breno
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/