Ich schreibe ein Kernelmodul, das Teile des virtuellen Speichers eines Prozesses liest. Ich versuche, die Methode access_process_vm im Kernel zu verwenden, aber es liest immer 0 Bytes.Understanding_process_vm Linux Kernel?
target = get_pid_task(find_get_pid(target_pid),PIDTYPE_PID);
if (target == NULL) {
printk(KERN_ALERT "no such task %d\n",target_pid);
return -1;
}
printk(KERN_INFO "opened task with pid %d\n",target->pid);
len = vm_end-vm_start;
buf = kmalloc(len ,GFP_KERNEL);
if (!buf) {
printk(KERN_ALERT "unable to allocate memory\n");
return -1;
}
printk(KERN_INFO "allocated memory\n");
bytes = access_process_vm(target,addr,buf,len,FOLL_FORCE);
if (bytes != len) {
printk(KERN_ALERT "could only read %d of %ld bytes\n",bytes,len);
kfree(buf);
return -1;
}
printk(KERN_INFO "read %d bytes successfully\n",bytes);
Was mache ich falsch?