问题描述
这是在学校的作业,我需要使用系统调用来确定系统上的进程的大小。我的代码如下:
this is for an assignment at school, where I need to determine the size of the processes on the system using a system call. My code is as follows:
...
struct task_struct *p;
struct vm_area_struct *v;
struct mm_struct *m;
read_lock(&tasklist_lock);
for_each_process(p) {
printk("%ld\n", p->pid);
m = p->mm;
v = m->mmap;
long start = v->vm_start;
printk("vm_start is %ld\n", start);
}
read_unlock(&tasklist_lock);
...
当我运行一个调用此系统调用的用户级程序时,我得到的输出是:
When I run a user level program that calls this system call, the output that I get is:
1
vm_start是134512640
2
1
vm_start is 134512640
2
EIP:0073:[< 0806e352>] CPU:0未污染ESP:007b:0f7ecf04 EFLAGS:00010246
未污染
EAX:00000000 EBX:0fc587c0 ECX:081fbb58 EDX:00000000
ESI:bf88efe0 EDI:0f482284 EBP:0f7ecf10 DS:007b ES:007b
081f9bc0:[< 08069ae8>] show_regs + 0xb4 / 0xb9
081f9bec:[< 080587ac>] segv + 0x225 / 0x23d
081f9c8c:[< 08058582>] segv_handler + 0x4f / 0x54
081f9cac:[< 08067453>] sig_handler_common_skas + 0xb7 / 0xd4
081f9cd4:[< 08064748>] sig_handler + 0x34 / 0x44
081f9cec:[< 080648b5>] handle_signal + 0x4c / 0x7a >
081f9d0c:[< 08066227>] hard_handler + 0xf / 0x14
081f9d1c:[< 00776420>] 0x776420
内核崩溃 - 未同步:addr 0x0,内核模式故障0x806e352
EIP:0073:[< 400ea0f2>] CPU:0未感染ESP: 007b:bf88ef9c EFLAGS:00000246
无污染
EAX:ffffffda EBX:00000000 ECX:bf88efc8 EDX:080483c8
ESI:00000000 EDI:bf88efe0 EBP:bf88f038 DS:007b ES:007b
081f9b28:[< 08069ae8>] show_regs + 0xb4 / 0xb9
081f9b54:[< 08058a1a>] panic_exit + 0x25 / 0x3f
081f9b68:[< 08084f54>] notifier_call_chain + 0x21 / 0x46
081f9b88:[< 08084fef]] __atomic_notifier_call_chain + 0x17 / 0x19
081f9ba4:[] atomic_notifier_call_chain + 0x15 / 0x17
081f9bc0:[< 0807039a>] panic + 0x52 / 0xd8
081f9be0:[< 080587ba>] segv + 0x233 / 0x23d
081f9c8c:[< 08058582>] segv_handler + 0x4f / 0x54
081f9cac:[< 08067453>] sig_handler_common_skas + 0xb7 / 0xd4
081f9cd4:[] sig_handler + 0x34 / 0x44
081f9cec:[< 080648b5>] handle_signal + 0x4c / 0x7a
081f9d0c:[< 08066227>] hard_handler + 0xf / 0x14
081f9d1c:[< 00776420>] 0x776420
EIP: 0073:[<0806e352>] CPU: 0 Not tainted ESP: 007b:0f7ecf04 EFLAGS: 00010246 Not tainted
EAX: 00000000 EBX: 0fc587c0 ECX: 081fbb58 EDX: 00000000
ESI: bf88efe0 EDI: 0f482284 EBP: 0f7ecf10 DS: 007b ES: 007b
081f9bc0: [<08069ae8>] show_regs+0xb4/0xb9
081f9bec: [<080587ac>] segv+0x225/0x23d
081f9c8c: [<08058582>] segv_handler+0x4f/0x54
081f9cac: [<08067453>] sig_handler_common_skas+0xb7/0xd4
081f9cd4: [<08064748>] sig_handler+0x34/0x44
081f9cec: [<080648b5>] handle_signal+0x4c/0x7a
081f9d0c: [<08066227>] hard_handler+0xf/0x14
081f9d1c: [<00776420>] 0x776420
Kernel panic - not syncing: Kernel mode fault at addr 0x0, ip 0x806e352
EIP: 0073:[<400ea0f2>] CPU: 0 Not tainted ESP: 007b:bf88ef9c EFLAGS: 00000246 Not tainted
EAX: ffffffda EBX: 00000000 ECX: bf88efc8 EDX: 080483c8
ESI: 00000000 EDI: bf88efe0 EBP: bf88f038 DS: 007b ES: 007b
081f9b28: [<08069ae8>] show_regs+0xb4/0xb9
081f9b54: [<08058a1a>] panic_exit+0x25/0x3f
081f9b68: [<08084f54>] notifier_call_chain+0x21/0x46
081f9b88: [<08084fef>] __atomic_notifier_call_chain+0x17/0x19
081f9ba4: [<08085006>] atomic_notifier_call_chain+0x15/0x17
081f9bc0: [<0807039a>] panic+0x52/0xd8
081f9be0: [<080587ba>] segv+0x233/0x23d
081f9c8c: [<08058582>] segv_handler+0x4f/0x54
081f9cac: [<08067453>] sig_handler_common_skas+0xb7/0xd4
081f9cd4: [<08064748>] sig_handler+0x34/0x44
081f9cec: [<080648b5>] handle_signal+0x4c/0x7a
081f9d0c: [<08066227>] hard_handler+0xf/0x14
081f9d1c: [<00776420>] 0x776420
第一个进程(pid = 1)给了我vm_start没有任何问题,但是当我尝试访问第二个进程时,内核崩溃。任何人都可以告诉我什么问题,也许如何解决它呢?非常感谢!
The first process (pid = 1) gave me the vm_start without any problems, but when I try to access the second process, the kernel crashes. Can anyone tell me what's wrong, and maybe how to fix it as well? Thanks a lot!
(对不起格式化错误....)
(sorry for the bad formatting....)
推荐答案
某些内核线程可能没有 mm
fill - check
p> mm
for NULL
。
Some kernel threads might not have mm
filled - check p->mm
for NULL
.
这篇关于Linux内核编程:试图获取vm_area_struct-> vm_start崩溃内核的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!