|
我用NETLINK实现内核进程与用户进程的通信,在内核模块的接受信息函数里,有下面代码:
struct sk_buff *skb;
while((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL)
{
struct nlmsghdr *nlh = NULL;
nlh = (struct nlmsghdr*)skb->data;
if(nlh== NULL)
{
printk("\n------receive ok!nlh== NULL-----\n");
}
else
{
printk("\n-----receive ok!nlh != NULL-----\n");
printk("\n\nnlmsg_type-----OK---%d----\n\n",nlh->nlmsg_pid);
}
}
我一旦访问struct nlmsghdr *nlh的内容(nlh->nlmsg_pid),
用户程序端就会出现 段错误!
下面是cat /var/log/messages的部分内容:
Apr 4 15:19:35 linux-yeiw kernel: 退出OK!---------------------------------------
Apr 4 15:19:35 linux-yeiw kernel: 创建OK!---------------------------------------
Apr 4 15:19:38 linux-yeiw kernel:
Apr 4 15:19:38 linux-yeiw kernel: -----receive ok!nlh != NULL-----
Apr 4 15:19:38 linux-yeiw kernel: BUG: unable to handle kernel NULL pointer dereference at virtual address 0000053c
Apr 4 15:19:38 linux-yeiw kernel: printing eip:
Apr 4 15:19:38 linux-yeiw kernel: f8ea202e
Apr 4 15:19:38 linux-yeiw kernel: *pde = 00000000
Apr 4 15:19:38 linux-yeiw kernel: Oops: 0000 [#15]
Apr 4 15:19:38 linux-yeiw kernel: SMP
Apr 4 15:19:38 linux-yeiw kernel: last sysfs file: /devices/pci0000:00/0000:00:00.0/irq
Apr 4 15:19:38 linux-yeiw kernel: Modules linked in: kern snd_pcm_oss snd_mixer_oss snd_seq snd_seq_device iptable_filter ip_tables ip6table_filter ip6_tables x_tables ipv6 cpufreq_conservative cpufreq_userspace cpufreq_powersave acpi_cpufreq speedstep_lib microcode firmware_class apparmor nls_iso8859_1 nls_cp936 vfat fat fuse loop dm_mod r8169 rtc_cmos snd_hda_intel rtc_core snd_pcm i2c_i801 button snd_timer i2c_core snd intel_agp iTCO_wdt soundcore rtc_lib iTCO_vendor_support parport_pc parport agpgart snd_page_alloc sg sd_mod ehci_hcd uhci_hcd usbcore edd ext3 mbcache jbd fan ata_piix libata scsi_mod thermal processor
Apr 4 15:19:38 linux-yeiw kernel: CPU: 0
Apr 4 15:19:38 linux-yeiw kernel: EIP: 0060:[<f8ea202e>] Tainted: G N VLI
Apr 4 15:19:38 linux-yeiw kernel: EFLAGS: 00210292 (2.6.22.5-31-default #1)
Apr 4 15:19:38 linux-yeiw kernel: EIP is at kernel_receive+0x2e/0x54 [kern]
Apr 4 15:19:38 linux-yeiw kernel: eax: 00000028 ebx: 00000530 ecx: 00200082 edx: 00200000
Apr 4 15:19:38 linux-yeiw kernel: esi: dff4dc6c edi: d0b61f58 ebp: dfe73e00 esp: d0b61d68
Apr 4 15:19:38 linux-yeiw kernel: ds: 007b es: 007b fs: 00d8 gs: 0033 ss: 0068
Apr 4 15:19:38 linux-yeiw kernel: Process user (pid: 11775, ti=d0b60000 task=f0a59ab0 task.ti=d0b60000)
Apr 4 15:19:38 linux-yeiw kernel: Stack: f8ea211e 7fffffff dff4dc00 00000410 c0282ce6 00000410 dff4dc00 c0281c9e
Apr 4 15:19:38 linux-yeiw kernel: f71b9b80 00000000 c0282cc8 00000000 dfdefe00 d0b61f3c d0131e00 00000000
Apr 4 15:19:38 linux-yeiw kernel: 00000000 d0b61e68 00002dff 000003e8 00000064 00000000 dfdef800 00000000
Apr 4 15:19:38 linux-yeiw kernel: Call Trace:
Apr 4 15:19:38 linux-yeiw kernel: [<c0282ce6>] netlink_data_ready+0x12/0x4c
Apr 4 15:19:38 linux-yeiw kernel: [<c0281c9e>] netlink_sendskb+0x19/0x30
Apr 4 15:19:38 linux-yeiw kernel: [<c0282cc8>] netlink_sendmsg+0x26d/0x279
Apr 4 15:19:38 linux-yeiw kernel: [<c0265f97>] sock_sendmsg+0xd0/0xeb
Apr 4 15:19:38 linux-yeiw kernel: [<c01341b9>] autoremove_wake_function+0x0/0x33
Apr 4 15:19:38 linux-yeiw kernel: [<c015d7de>] do_wp_page+0x471/0x4bd
Apr 4 15:19:38 linux-yeiw kernel: [<c01571c1>] __alloc_pages+0x60/0x2d6
Apr 4 15:19:38 linux-yeiw kernel: [<c016238e>] find_mergeable_anon_vma+0xa3/0xb2
Apr 4 15:19:38 linux-yeiw kernel: [<c01d0c8f>] copy_from_user+0x23/0x4f
Apr 4 15:19:38 linux-yeiw kernel: [<c0266901>] sys_sendto+0x115/0x135
Apr 4 15:19:38 linux-yeiw kernel: [<c02687c5>] sock_init_data+0x83/0x187
Apr 4 15:19:38 linux-yeiw kernel: [<c0281a5b>] __netlink_create+0x75/0x8c
Apr 4 15:19:38 linux-yeiw kernel: [<c0192dae>] inotify_d_instantiate+0x41/0x67
Apr 4 15:19:38 linux-yeiw kernel: [<c017eb60>] d_alloc+0x14b/0x17e
Apr 4 15:19:38 linux-yeiw kernel: [<c016147b>] __vma_link+0x44/0x4f
Apr 4 15:19:38 linux-yeiw kernel: [<c02672f6>] sys_socketcall+0x17b/0x261
Apr 4 15:19:38 linux-yeiw kernel: [<c0104ea2>] syscall_call+0x7/0xb
Apr 4 15:19:38 linux-yeiw kernel: =======================
Apr 4 15:19:38 linux-yeiw kernel: Code: ec 08 8d 70 6c eb 37 8b 98 a8 00 00 00 85 db 75 0e c7 04 24 fb 20 ea f8 e8 79 24 28 c7 eb 1f c7 04 24 1e 21 ea f8 e8 6b 24 28 c7 <8b> 43 0c c7 04 24 41 21 ea f8 89 44 24 04 e8 58 24 28 c7 89 f0
Apr 4 15:19:38 linux-yeiw kernel: EIP: [<f8ea202e>] kernel_receive+0x2e/0x54 [kern] SS:ESP 0068:d0b61d68
Apr 4 15:19:49 linux-yeiw sudo: adang : TTY=pts/1 ; PWD=/home/adang/Desktop/biyesheji/kern_user ; USER=root ; COMMAND=/bin/cat /var/log/messages
请问这是什么原因导致的?如何解决? |
|