Re: [suse-amd64] oops in current->journal-info in ext3 and reiserfs
Hi Andi, I am trying to use the following macro to detect stack overflow in some of the functions which showed a high value in the objdump command you mentioned, But somehow i am not able to hit the condition yet, i wonder if this macro is somehow broken. #define thread_check_stack() { \ register unsigned long _sp_; \ register unsigned long _ebp_; \ unsigned long address; \ struct task_struct *p = current; \ __asm__("movq %%rsp, %0" : "=r" (_sp_)); \ __asm__("movq %%rbp, %0" : "=r" (_ebp_)); \ address = (unsigned long )p->journal_info ; \ if ( _sp_ <= address ) { \ printk(KERN_ALERT "!!!! %s:%d : stack shoots in to task struct here sp: %016lx jinfo %016lx!!\n", \ __FILE__, __LINE__, _sp_, address );\ drop_to_debugger(); \ }\ if ( address ) { \ if ( address < PAGE_SIZE ) { \ printk(KERN_ALERT "!!!! %s:%d : Journal Info appears to be corrupted here\n", \ __FILE__, __LINE__ );\ printk(" at virtual address %016lx\n",address);\ drop_to_debugger(); \ }\ }\ address = (unsigned long )p->fs ; \ if ( address < PAGE_SIZE ) { \ printk(KERN_ALERT "!!!! %s:%d : task->fs appears to be here\n", \ __FILE__, __LINE__ );\ printk(" at virtual address %016lx\n",address);\ drop_to_debugger(); \ }\ if (in_interrupt()) { \ printk(KERN_ERR "!!!! %s:%d : In interrupt \n", \ __FILE__, __LINE__ );\ if( ((_sp_ & ~(PAGE_MASK << 1)) - sizeof(struct task_struct)) < 256) { \ printk(KERN_ERR "!!!! %s:%d : total intr stack size exceeded: %lu\n", \ __FILE__, __LINE__, \ ((_sp_ & ~(PAGE_MASK << 1)) - sizeof(struct task_struct))); \ drop_to_debugger(); \ } \ } \ else { \ if( ((_sp_ & ~(PAGE_MASK << 1)) - sizeof(struct task_struct)) < 1200) { \ printk(KERN_ERR "!!!! %s:%d : total stack size exceeded: %lu\n", \ __FILE__, __LINE__, \ ((_sp_ & ~(PAGE_MASK << 1)) - sizeof(struct task_struct))); \ drop_to_debugger(); \ } \ } \ if( (_ebp_ > _sp_) && \ ((_ebp_ - _sp_) > 400) ) { \ printk(KERN_ERR "!!!! %s:%d : total stack size exceeded: %lu\n", \ __FILE__, __LINE__, \ } \ } Thanks in advance for any help, Satya
From: Andi Kleen
To: "adelphia user" CC: suse-amd64@suse.com Subject: Re: [suse-amd64] oops in current->journal-info in ext3 and reiserfs Date: Mon, 21 Jun 2004 17:24:56 +0200 On Mon, 21 Jun 2004 18:33:31 +0530 "adelphia user"
wrote: Yes we use our own filesystem module. Apart from this i also see oops due to invalid address etc. I suspect our module is overwriting in to the stack, probably causing corruption. Is there a way to increase the stack size? I
Nope, you have to fix your module. In 2.6 kernels (like in 9.1) there is ~2k more stack, but even with that it it's better to fix it.
One way to start is to do objdump -S module.o | egrep '>:|sub.*sp' and fix any function that uses more than ~200bytes stack frame.
Usually you can do that by using kmalloc() to allocate space for a big stack variable.
-Andi
-- Check the List-Unsubscribe header to unsubscribe For additional commands, email: suse-amd64-help@suse.com
_________________________________________________________________ Pay Cash on delivery on lakhs of products. http://go.msnserver.com/IN/50757.asp Only on Baazee.com
On Tue, 22 Jun 2004 07:31:23 +0530
"adelphia user"
Hi Andi,
I am trying to use the following macro to detect stack overflow in some of the functions which showed a high value in the objdump command you mentioned, But somehow i am not able to hit the condition yet, i wonder if this macro is somehow broken.
#define thread_check_stack() { \ register unsigned long _sp_; \ register unsigned long _ebp_; \ unsigned long address; \ struct task_struct *p = current; \ __asm__("movq %%rsp, %0" : "=r" (_sp_)); \ __asm__("movq %%rbp, %0" : "=r" (_ebp_)); \ address = (unsigned long )p->journal_info ; \
p->journal_info is a pointer, try &p->journal_info But better would be (char *)(current + 1) + 128 or somesuch. ftp://ftp.x86-64.org/pub/linux/debug/stackcheck-1 has also an older stack check patch that can be applied to the kernel. It should catch everything. -Andi
participants (2)
-
adelphia user
-
Andi Kleen