---打印进程占用虚拟地址空间出错!
时间:2009-12-26
来源:互联网
大家好!
代码是我在Lupa上拷贝过来的,原本是在下面条件编译部分只有:
(http://www.lupaworld.com/26540/viewspace-137650.html)
p = find_task_by_vpid( pid );
并且lupa上讲是可以工作的。
但是我在2.6.31下编译不过,就加了条件编译以便使用新的的函数。
编译过来以后,就sudo insmod mem.ko pid=3647 测试结果kernel打印出错(看如下log),之后系统没死,但是也不能rmmod mem 了。
我看了表面代码结构的定义是没问题的,请大家帮助。
[ 429.133080] My module worked!
[ 429.133092] BUG: unable to handle kernel NULL pointer dereference at 000001e4
[ 429.133096] IP: [<f80cd01f>] memtest_init+0x1f/0x52 [mem]
[ 429.133102] *pde = 280cf067 *pte = 00000000
[ 429.133105] Oops: 0000 [#1] SMP
[ 429.133108] last sysfs file: /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
[ 429.133111] Modules linked in: mem(+) binfmt_misc vboxnetadp vboxnetflt vboxdrv tun snd_hda_codec_realtek snd_hda_intel snd_hda_codec iptable_filter snd_hwdep snd_pcm_oss snd_mixer_oss snd_pcm ip_tables x_tables snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer ppdev snd_seq_device parport_pc snd soundcore snd_page_alloc lp parport usbhid fbcon tileblit font bitblit softcursor i915 drm i2c_algo_bit 8139too 8139cp r8169 mii intel_agp agpgart video output
[ 429.133145]
[ 429.133148] Pid: 2788, comm: insmod Not tainted (2.6.31-17-generic #54-Ubuntu) G41M-ES2L
[ 429.133151] EIP: 0060:[<f80cd01f>] EFLAGS: 00010246 CPU: 0
[ 429.133154] EIP is at memtest_init+0x1f/0x52 [mem]
[ 429.133156] EAX: 00000000 EBX: fffffffc ECX: ffffffdc EDX: 00000000
[ 429.133158] ESI: f80b73c0 EDI: 00000000 EBP: e81b9f5c ESP: e81b9f4c
[ 429.133160] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 429.133162] Process insmod (pid: 2788, ti=e81b8000 task=e977cb60 task.ti=e81b8000)
[ 429.133164] Stack:
[ 429.133166] f80b7052 00000000 e81b9f78 fffffffc e81b9f88 c010112c f80b73c0 c0750a50
[ 429.133171] <0> fffffffc f80b73c0 003f8ff4 f80cd000 fffffffc f80b73c0 003f8ff4 e81b9fac
[ 429.133178] <0> c0173711 f5ff08f8 e977cb60 f5ff08c0 00000004 09b52018 09b52018 00004000
[ 429.133184] Call Trace:
[ 429.133190] [<c010112c>] ? do_one_initcall+0x2c/0x190
[ 429.133193] [<f80cd000>] ? memtest_init+0x0/0x52 [mem]
[ 429.133198] [<c0173711>] ? sys_init_module+0xb1/0x1f0
[ 429.133201] [<c010336c>] ? syscall_call+0x7/0xb
[ 429.133203] Code: <8b> 80 e4 01 00 00 8b 18 eb 1d 8b 43 08 89 44 24 08 8b 43 04 c7 04
[ 429.133218] EIP: [<f80cd01f>] memtest_init+0x1f/0x52 [mem] SS:ESP 0068:e81b9f4c
[ 429.133223] CR2: 00000000000001e4
[ 429.133225] ---[ end trace d6cfe8147efa4d76 ]---
代码是我在Lupa上拷贝过来的,原本是在下面条件编译部分只有:
(http://www.lupaworld.com/26540/viewspace-137650.html)
p = find_task_by_vpid( pid );
并且lupa上讲是可以工作的。
但是我在2.6.31下编译不过,就加了条件编译以便使用新的的函数。
编译过来以后,就sudo insmod mem.ko pid=3647 测试结果kernel打印出错(看如下log),之后系统没死,但是也不能rmmod mem 了。
我看了表面代码结构的定义是没问题的,请大家帮助。
[ 429.133080] My module worked!
[ 429.133092] BUG: unable to handle kernel NULL pointer dereference at 000001e4
[ 429.133096] IP: [<f80cd01f>] memtest_init+0x1f/0x52 [mem]
[ 429.133102] *pde = 280cf067 *pte = 00000000
[ 429.133105] Oops: 0000 [#1] SMP
[ 429.133108] last sysfs file: /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
[ 429.133111] Modules linked in: mem(+) binfmt_misc vboxnetadp vboxnetflt vboxdrv tun snd_hda_codec_realtek snd_hda_intel snd_hda_codec iptable_filter snd_hwdep snd_pcm_oss snd_mixer_oss snd_pcm ip_tables x_tables snd_seq_dummy snd_seq_oss snd_seq_midi snd_rawmidi snd_seq_midi_event snd_seq snd_timer ppdev snd_seq_device parport_pc snd soundcore snd_page_alloc lp parport usbhid fbcon tileblit font bitblit softcursor i915 drm i2c_algo_bit 8139too 8139cp r8169 mii intel_agp agpgart video output
[ 429.133145]
[ 429.133148] Pid: 2788, comm: insmod Not tainted (2.6.31-17-generic #54-Ubuntu) G41M-ES2L
[ 429.133151] EIP: 0060:[<f80cd01f>] EFLAGS: 00010246 CPU: 0
[ 429.133154] EIP is at memtest_init+0x1f/0x52 [mem]
[ 429.133156] EAX: 00000000 EBX: fffffffc ECX: ffffffdc EDX: 00000000
[ 429.133158] ESI: f80b73c0 EDI: 00000000 EBP: e81b9f5c ESP: e81b9f4c
[ 429.133160] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 429.133162] Process insmod (pid: 2788, ti=e81b8000 task=e977cb60 task.ti=e81b8000)
[ 429.133164] Stack:
[ 429.133166] f80b7052 00000000 e81b9f78 fffffffc e81b9f88 c010112c f80b73c0 c0750a50
[ 429.133171] <0> fffffffc f80b73c0 003f8ff4 f80cd000 fffffffc f80b73c0 003f8ff4 e81b9fac
[ 429.133178] <0> c0173711 f5ff08f8 e977cb60 f5ff08c0 00000004 09b52018 09b52018 00004000
[ 429.133184] Call Trace:
[ 429.133190] [<c010112c>] ? do_one_initcall+0x2c/0x190
[ 429.133193] [<f80cd000>] ? memtest_init+0x0/0x52 [mem]
[ 429.133198] [<c0173711>] ? sys_init_module+0xb1/0x1f0
[ 429.133201] [<c010336c>] ? syscall_call+0x7/0xb
[ 429.133203] Code: <8b> 80 e4 01 00 00 8b 18 eb 1d 8b 43 08 89 44 24 08 8b 43 04 c7 04
[ 429.133218] EIP: [<f80cd01f>] memtest_init+0x1f/0x52 [mem] SS:ESP 0068:e81b9f4c
[ 429.133223] CR2: 00000000000001e4
[ 429.133225] ---[ end trace d6cfe8147efa4d76 ]---
代码:
/*mem.c*/ #include <linux/module.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/version.h> static int pid; module_param(pid,int,0644); static int __init memtest_init(void) { struct task_struct *p; struct vm_area_struct *temp; printk("My module worked!\n"); // p = find_task_by_vpid(pid); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) p = find_task_by_pid( pid ); #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) p = find_task_by_vpid( pid ); #else p = pid_task((struct pid *)&pid, PIDTYPE_PID ); #endif temp = p->mm->mmap; while(temp) { printk("start:%p\tend:%p\n", (unsigned long *)temp->vm_start, (unsigned long *)temp->vm_end); temp = temp->vm_next; } return 0; } static void __exit memtest_exit(void) { printk("Unloading my module.\n"); return; } module_init(memtest_init); module_exit(memtest_exit); MODULE_LICENSE("GPL");
作者: bzhao123 发布时间: 2009-12-26
我自己搞好了,自己是最好的好的老师!
代码:
/*mem.c*/ #include <linux/module.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/sched.h> #include <linux/version.h> #include <linux/pid.h> static int pid_no; module_param(pid_no,int,0644); static int __init memtest_init(void) { struct task_struct *p; struct pid_sturct *pid; struct vm_area_struct *temp; printk("My module worked!\n"); // p = find_task_by_vpid(pid); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) p = find_task_by_pid( pid_no ); #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) p = find_task_by_vpid( pid_no ); #else pid=find_vpid(pid_no); p = pid_task(pid, PIDTYPE_PID ); #endif #if 1 temp = p->mm->mmap; while(temp) { printk("start:%p\tend:%p\n", (unsigned long *)temp->vm_start, (unsigned long *)temp->vm_end); temp = temp->vm_next; } #endif return 0; } static void __exit memtest_exit(void) { printk("Unloading my module.\n"); return; } module_init(memtest_init); module_exit(memtest_exit); MODULE_LICENSE("GPL");
作者: bzhao123 发布时间: 2009-12-26
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28