[LIP] Insmod Rmmod Insmod crash.

"suresh kumar" <suresh_vin-/iAzse42w/[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
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


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.