Kernel Module Oops! TRICKY PROBLEM!

Submitted by developer
on October 7, 2008 - 12:07pm

hi everybody,

I am developing a modules that launches a thread in its init function. The modules works correctly If i load it and remove it only two times. The THIRD time i load it, it crashes at insmod process. This is the dmesg of the error. Does any one have any idea about such errors????

[ 246.160367] Pid: 6685, comm: insmod Not tainted (2.6.24-custom #1)
[ 246.160372] EIP: 0060:[] EFLAGS: 00010006 CPU: 0
[ 246.160387] EIP is at __kmalloc_track_caller+0x64/0x110
[ 246.160392] EAX: 00000000 EBX: 00626174 ECX: c040c0b0 EDX: 000000d0
[ 246.160397] ESI: 00000286 EDI: c040c0b0 EBP: c1407508 ESP: d66e7e84
[ 246.160403] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[ 246.160409] Process insmod (pid: 6685, ti=d66e6000 task=da8d3700 task.ti=d66e6000)
[ 246.160414] Stack: e0c12900 c0150282 c0151e78 000000d0 000000d0 da8ca800 da8ca9e8 00000008
[ 246.160425] c0178fd9 e0c7c205 da8ca974 da8ca800 da8ca9e8 e0c12900 c0151e78 00000000
[ 246.160437] 00000000 d66e7f64 00000000 e0c125e0 00000000 d64f7f20 e0c67358 e0c67354
[ 246.160448] Call Trace:
[ 246.160457] [] module_add_modinfo_attrs+0x62/0x80
[ 246.160472] [] sys_init_module+0x1968/0x19c0
[ 246.160488] [] kstrdup+0x39/0x70
[ 246.160507] [] sys_init_module+0x1968/0x19c0
[ 246.160559] [] _atomic_dec_and_lock+0x47/0x70
[ 246.160588] [] mntput_no_expire+0x13/0x70
[ 246.160614] [] sysenter_past_esp+0x6b/0xa9
[ 246.160644] =======================
[ 246.160648] Code: 1f 84 00 00 00 00 00 89 c6 fa 0f 1f 84 00 00 00 00 00 90 64 a1 08 90 46 c0 8b 6c 87 70 8b 5d 00 85 db 0f 84 8a 00 00 00 8b 45 0c <8b> 04 83 89 45 00 89 f0 50 9d 0f 1f 84 00 00 00 00 00 66 83 7c
[ 246.160699] EIP: [] __kmalloc_track_caller+0x64/0x110 SS:ESP 0068:d66e7e84
[ 246.160711] ---[ end trace d93bbc0d7866a380 ]---
[ 251.333291] BUG: unable to handle kernel paging request at virtual address 00626174
[ 251.333308] printing eip: c018e7e4 *pde = 00000000
[ 251.333317] Oops: 0000 [#2] SMP
[ 251.333323] Modules linked in: tiny_serial ttyvei symbol ipv6 af_packet radeon drm rfcomm l2cap bluetooth uinput thinkpad_acpi nvram ppdev speedstep_smi speedstep_lib cpufreq_ondemand cpufreq_userspace cpufreq_conservative cpufreq_stats freq_table cpufreq_powersave sbs container sbshc dock iptable_filter ip_tables x_tables lp pcmcia battery ac irtty_sir sir_dev nsc_ircc irda parport_pc parport crc_ccitt evdev video output psmouse yenta_socket serio_raw hostap_pci hostap rsrc_nonstatic ieee80211_crypt pcmcia_core button pcspkr shpchp iTCO_wdt intel_agp agpgart pci_hotplug iTCO_vendor_support ext3 jbd mbcache sg sr_mod cdrom sd_mod usbhid hid floppy ata_piix pata_acpi ata_generic libata scsi_mod e100 mii uhci_hcd usbcore thermal processor fan fuse
[ 251.333417]
[ 251.333423] Pid: 5179, comm: hald Tainted: G D (2.6.24-custom #1)
[ 251.333429] EIP: 0060:[] EFLAGS: 00010006 CPU: 0
[ 251.333442] EIP is at __kmalloc+0x64/0x110
[ 251.333447] EAX: 00000000 EBX: 00626174 ECX: c040c0b0 EDX: c0243148
[ 251.333452] ESI: 00000286 EDI: c040c0b0 EBP: c1407508 ESP: dc645e00
[ 251.333457] DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[ 251.333463] Process hald (pid: 5179, ti=dc644000 task=dcce8b80 task.ti=dc644000)
[ 251.333468] Stack: 00000007 d60f9060 000080d0 dcc14b28 00000004 dc645e8c d7c089b0 c0243148
[ 251.333480] e0a6ced2 e0a6ced2 dc9ce5d8 00000008 00000001 00000000 00000000 dcc14b28
[ 251.333491] d7c089b0 00000000 d7c089b0 c02431ac 00000004 0000001c 00000004 d9274600
[ 251.333502] Call Trace:
[ 251.333517] [] acpi_ns_internalize_name+0x53/0x86
[ 251.333545] [] acpi_ns_get_node+0x31/0x93
[ 251.333561] [] get_unused_fd_flags+0x52/0xd0
[ 251.333585] [] acpi_ns_evaluate+0x2e/0xf0
[ 251.333601] [] acpi_evaluate_object+0x11b/0x1c0
[ 251.333618] [] acpi_battery_get_state+0x65/0xd1 [battery]
[ 251.333644] [] acpi_battery_get_property+0x1a/0x155 [battery]
[ 251.333658] [] power_supply_show_property+0x3e/0x140
[ 251.333677] [] power_supply_show_property+0x0/0x140
[ 251.333689] [] dev_attr_show+0x1d/0x30
[ 251.333704] [] sysfs_read_file+0x67/0xe0
[ 251.333726] [] sysfs_read_file+0x0/0xe0
[ 251.333735] [] vfs_read+0xb7/0x170
[ 251.333751] [] sys_read+0x41/0x70
[ 251.333765] [] sysenter_past_esp+0x6b/0xa9
[ 251.333785] [] atm_dev_register+0x120/0x200
[ 251.333807] =======================
[ 251.333810] Code: 1f 84 00 00 00 00 00 89 c6 fa 0f 1f 84 00 00 00 00 00 90 64 a1 08 90 46 c0 8b 6c 87 70 8b 5d 00 85 db 0f 84 8a 00 00 00 8b 45 0c <8b> 04 83 89 45 00 89 f0 50 9d 0f 1f 84 00 00 00 00 00 66 83 7c
[ 251.333861] EIP: [] __kmalloc+0x64/0x110 SS:ESP 0068:dc645e00
[ 251.333872] ---[ end trace d93bbc0d7866a380 ]---

most likely reason is not

paul fox (not verified)
on
October 7, 2008 - 1:34pm

most likely reason is not freeing memory properly. i would
add some debug code to count or validate any memory you use;
also watch for interrupts firing after your module is removed
and corrupting the kernel.

did it ever work? can you backtrack? can you cut out most of the code and get to a stable point to work out where the error strikes?

hi Paul, I have checked all

Anonymous (not verified)
on
October 8, 2008 - 1:39am

hi Paul,

I have checked all the memory allocations and everything seems ok. The module runs sometimes without crashing but in other cases, it crashes (segmentation fault). If you still have any suggestion, am glad to listen.

thanksss

overflow

strcmp
on
October 8, 2008 - 2:20pm

do you write past the bounds of the allocated memory (like the -1-st or n-th element in an array) and allocate all memory with the correct size? how about (if a = kmalloc(sizeof*a); is the normal case) a = kmalloc(sizeof*b); or a = kmalloc(sizeof a); ? do you use memory after freeing it? do you free memory you inserted onto global lists with a register_*() function or so? if t hcode runs in user space as well, you can use a memory debugger. have you compiled and run a kernel with memory debugging options?

thxxxxx guysss, it was a

Anonymous (not verified)
on
October 9, 2008 - 5:49am

thxxxxx guysss, it was a memory problem overflow!!!

Thanks for the help

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.