是这样的,我写了个内核态下的程序,加了多线程,在insmod的时候是可以的,运行的也正常,但是在rmmod的时候出现如下的错误
- C/C++ code
[ 2422.743889] BUG: unable to handle kernel NULL pointer dereference at 00000074[ 2422.743893] IP: [<e09d8889>] comp_time+0xc9/0x100 [robot_jack2][ 2422.743947] *pde = 1bf19067 *pte = 00000000 [ 2422.743954] Oops: 0000 [#3] SMP [ 2422.743961] Modules linked in: [color=#99CC00]robot_jack2(O-) robot_jack(O-)[/color] sunrpc ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 nf_conntrack_ipv4 nf_defrag_ipv4 ip6table_filter xt_state ip6_tables nf_conntrack snd_ens1371 gameport snd_rawmidi snd_ac97_codec ac97_bus snd_seq snd_seq_device snd_pcm snd_timer ppdev microcode parport_pc snd parport vmw_balloon i2c_piix4 soundcore snd_page_alloc i2c_core pcnet32 mii mptspi mptscsih mptbase scsi_transport_spi [last unloaded: mperf][ 2422.743986] [ 2422.743990] Pid: 2418, comm: thread_over_tim Tainted: G D O 2.6.42.3-2.fc15.i686 #1 VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform[ 2422.743998] EIP: 0060:[<e09d8889>] EFLAGS: 00010296 CPU: 0[ 2422.744001] EIP is at [color=#FF0000]comp_time[/color]+0xc9/0x100 [robot_jack2][ 2422.744003] EAX: dfac1601 EBX: 00000000 ECX: 80200009 EDX: 8020000a[ 2422.744005] ESI: dfac1d00 EDI: e09d8980 EBP: dc05ffac ESP: dc05ff98[ 2422.744007] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068[ 2422.744010] Process thread_over_tim (pid: 2418, ti=dc05e000 task=ddaa3ed0 task.ti=dc05e000)[ 2422.744012] Stack:[ 2422.744013] e09d91b9 4f42fffe 000ee1c7 dcba3eb0 00000000 dc05ffb8 e09d89ad e09d920d[ 2422.744019] dc05ffe4 c046c4fd 00000000 00000000 00000000 00000000 dc05ffd0 dc05ffd0[ 2422.744023] 00000000 c046c490 dcba3eb0 00000000 c09494be 00000000 00000000 00000000[ 2422.744028] Call Trace:[ 2422.744032] [<e09d89ad>] [color=#FF0000]thread_over_time[/color]+0x2d/0x50 [robot_jack2][ 2422.744046] [<c046c4fd>] kthread+0x6d/0x80[ 2422.744049] [<c046c490>] ? kthread_worker_fn+0x140/0x140[ 2422.744060] [<c09494be>] kernel_thread_helper+0x6/0x10[ 2422.744062] Code: 9d e0 e8 90 07 f6 df 3b 1d 9c a1 9d e0 74 29 c7 04 24 b9 91 9d e0 e8 7c 07 f6 df 8b 43 6c 89 46 6c 89 d8 e8 ca 4e b4 df 8b 5e 6c <0f> b7 43 74 38 c4 74 a0 fe 43 74 eb 9b c7 04 24 a0 91 9d e0 e8 [ 2422.744088] EIP: [<e09d8889>] comp_time+0xc9/0x100 [robot_jack2] SS:ESP 0068:dc05ff98[ 2422.744092] CR2: 0000000000000074[ 2422.744095] ---[ end trace 4920f7c4786833f1 ]---[ 2428.140675] ----------play end---------[ 2428.140743] end thread 2. ret = 0[ 2428.140780] BUG: unable to handle kernel NULL pointer dereference at (null)[ 2428.140784] IP: [<c0473201>] exit_creds+0x11/0x90[ 2428.140796] *pde = 00000000 [ 2428.140799] Oops: 0000 [#4] SMP [ 2428.140802] Modules linked in: robot_jack2(O-) robot_jack(O-) sunrpc ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 nf_conntrack_ipv4 nf_defrag_ipv4 ip6table_filter xt_state ip6_tables nf_conntrack snd_ens1371 gameport snd_rawmidi snd_ac97_codec ac97_bus snd_seq snd_seq_device snd_pcm snd_timer ppdev microcode parport_pc snd parport vmw_balloon i2c_piix4 soundcore snd_page_alloc i2c_core pcnet32 mii mptspi mptscsih mptbase scsi_transport_spi [last unloaded: mperf][ 2428.140844] [ 2428.140848] Pid: 2430, comm: rmmod Tainted: G D O 2.6.42.3-2.fc15.i686 #1 VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform[ 2428.140913] EIP: 0060:[<c0473201>] EFLAGS: 00010206 CPU: 0[ 2428.140916] EIP is at exit_creds+0x11/0x90[ 2428.140918] EAX: 00000000 EBX: ddaa3ed0 ECX: 00000052 EDX: 00000000[ 2428.140920] ESI: 00000000 EDI: 00000000 EBP: dc053f0c ESP: dc053f08[ 2428.140922] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068[ 2428.140925] Process rmmod (pid: 2430, ti=dc052000 task=dcbbf110 task.ti=dc052000)[ 2428.140927] Stack:[ 2428.140928] ddaa3ed0 dc053f1c c044c3b6 ddaa3ed0 00000000 dc053f34 c046c5f7 00000000[ 2428.140933] e09da020 00000000 00000000 dc053f44 e09d8b04 e09d9398 00000000 dc053fac[ 2428.140938] c0485d75 e09da020 00000880 dc053f58 00000000 bfc3d190 6f626f72 616a5f74[ 2428.140943] Call Trace:[ 2428.140948] [<c044c3b6>] __put_task_struct+0x36/0xf0[ 2428.140951] [<c046c5f7>] kthread_stop+0xe7/0xf0[ 2428.140956] [<e09d8b04>] main_exit+0x70/0x56c [robot_jack2][ 2428.140961] [<c0485d75>] sys_delete_module+0x135/0x230[ 2428.140965] [<c040d992>] ? syscall_trace_enter+0x172/0x1d0[ 2428.140968] [<c040da5f>] ? syscall_trace_leave+0x6f/0xd0[ 2428.140973] [<c0942074>] syscall_call+0x7/0xb[ 2428.140974] Code: f5 fe ff ff e9 c2 fe ff ff 0f 0b 0f 0b 8d b6 00 00 00 00 8d bc 27 00 00 00 00 55 89 e5 53 3e 8d 74 26 00 89 c3 8b 80 dc 02 00 00 <8b> 00 8b 83 d8 02 00 00 c7 83 d8 02 00 00 00 00 00 00 3e ff 08 [ 2428.141001] EIP: [<c0473201>] exit_creds+0x11/0x90 SS:ESP 0068:dc053f08[ 2428.141004] CR2: 0000000000000000[ 2428.141008] ---[ end trace 4920f7c4786833f2 ]---