Discussion:
[LIP] Insmod Rmmod Insmod crash.
suresh kumar
2004-02-07 05:30:10 UTC
Permalink
Hi,
I have written a module that crashes after insmod followed by rmmod followed by insmod. I am using kgdb and the crash is as below. When I do rmmod I am not freeing the memory that is I have allocated during the insmod. I want to know if it is because of that or it is because of wrong programming in registering netfilter hooks as the trace is showing that. I am also pasing few lines as how I am registering. Kindly help me. I feel that there is some thing to do with the priority of the hook.

Trace:
Myfunction init function success
the value 0the value 0
Program received signal SIGSEGV, Segmentation fault.
nf_register_hook (reg=0xc4877860) at netfilter.c:68
68 if (reg->priority < ((struct nf_hook_ops *)i)->priority)(gdb) c
Continuing.
Can't send signals to this remote system. SIGSEGV not sent.
<1>Unable to handle kernel paging request at virtual address c4888874
printing eip:
c0202680
Program received signal SIGTRAP, Trace/breakpoint trap.
nf_register_hook (reg=0xc4877860) at netfilter.c:68
68 if (reg->priority < ((struct nf_hook_ops *)i)->priority)(gdb) c
Continuing.
ipseckern
CPU: 0
EIP: 0010:[<c0202680>] Tainted: PF
EFLAGS: 00010206

EIP is at nf_register_hook [kernel] 0x30 (2.4.18-14custom)
eax: c03def60 ebx: c4877860 ecx: 80000000 edx: c4888860
esi: 00000000 edi: 00000000 ebp: c14adef0 esp: c14adeec
ds: 0018 es: 0018 ss: 0018
Process insmod (pid: 1386, stackpage=c14ad000)
Stack: ffffffea c14adf10 c4858502 c4877860 00000000 c14adf10 c48584e0 00000000
00000000 c14adfbc c011daa6 c4851060 4051b068 0002d7a0 c4872ccc 00000000
4053a874 0001f86c 00000060 00000060 00000009 c0ba71e0 c0362000 c0595000
Call Trace: [<c4858502>] init_module [mymodule] 0x6a (0xc14adef4))
[<c4877860>] fsnethook_ops [mymodule] 0x0 (0xc14adef8))
[<c48584e0>] init_module [mymodule] 0x48 (0xc14adf04))
[<c011daa6>] sys_init_module [kernel] 0x526 (0xc14adf14))
[<c4851060>] MyEncode [mymodule] 0x0 (0xc14adf18))
[<c4872ccc>] __ksymtab [ipseckern] 0x0 (0xc14adf24))
[<c4851060>] MyEncode [mymodule] 0x0 (0xc14adf58))
[<c010932f>] system_call [kernel] 0x33 (0xc14adfc0))


code piece:
static struct nf_hook_ops nethook_ops[] = {
{{ NULL, NULL} ,nethook_my_function1, PF_INET,
NF_IP_PRE_ROUTING, NF_IP_PRI_FIRST},

{{ NULL, NULL} ,nethook_my_function2, PF_INET,
NF_IP_POST_ROUTING, NF_IP_PRI_FIRST},
};

int
init_module(void)
{
/*pre routing and then post routing*/

nf_register_hook( &nethook_ops[0]);

nf_register_hook( &nvoidethook_ops[1]);

return 0;
}
clean_module(void)
{
/* Unregistering pre and post hooks*/
nf_unregister_hook( &nethook_ops[0]);

nf_unregister_hook( &nethook_ops[1]);

return;
}





V.V Suresh Kumar
--
______________________________________________
IndiaInfo Mail - the free e-mail service with a difference! www.indiainfo.com
Check out our value-added Premium features, such as an extra 20MB for mail storage, POP3, e-mail forwarding, and ads-free mailboxes!

Powered by Outblaze
Suresh Ramasubramanian
2004-02-07 20:42:35 UTC
Permalink
Post by suresh kumar
Hi,
I have written a module that crashes after insmod followed by rmmod followed by insmod. I am using kgdb and the crash is as below. When I do rmmod I am not freeing the memory that is I have allocated during the insmod. I want to know if it is because of that or it is because of wrong programming in registering netfilter hooks as the trace is showing that. I am also pasing few lines as how I am registering. Kindly help me. I feel that there is some thing to do with the priority of the hook.
This might explain why ...

http://lkml.org/lkml/2004/1/27/32
Post by suresh kumar
SIGSEGV has to be actually delivered to an application for it to die. A user
has a choice of correcting a bug on the fly and let the application continue
without segfaulting. It can tell gdb to continue the debugee without a
signal. It doesn't apply in case of kernel, so it's not a bug. Kernel anyway
"delivers" the signal, that is, continues with a panic once kgdb returns. We
don't offer a user the choice of correcting a segfault on the fly.
Arun Sharma
2004-02-08 05:16:02 UTC
Permalink
Post by suresh kumar
nf_register_hook (reg=0xc4877860) at netfilter.c:68
68 if (reg->priority < ((struct nf_hook_ops *)i)->priority)
<1>Unable to handle kernel paging request at virtual address c4888874
Are you sure your clean_module() is getting called ? It looks like you
didn't unregister the earlier (rmmod'ed) filter cleanly.

-Arun

Loading...