Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 从kprobe获取参数未找到注册表->;rdi x86_64_Linux_Kernel_Kprobe - Fatal编程技术网

Linux 从kprobe获取参数未找到注册表->;rdi x86_64

Linux 从kprobe获取参数未找到注册表->;rdi x86_64,linux,kernel,kprobe,Linux,Kernel,Kprobe,我正在Scientific Linux 6.3 x86_64下编写一个内核模块,我希望使用kprobes。在这个模块中,我需要在返回时访问函数的第一个参数,因此jprobes不可用 我发现这个帖子非常有用: 但是,当我尝试在探测器内部访问regs->rdi时,编译器会抱怨 error: ‘struct pt_regs’ has no member named ‘rdi’ 在模块初始化期间,我运行此检查时没有出现任何问题: #ifndef CONFIG_X86_64 printk(KERN_A

我正在Scientific Linux 6.3 x86_64下编写一个内核模块,我希望使用kprobes。在这个模块中,我需要在返回时访问函数的第一个参数,因此jprobes不可用

我发现这个帖子非常有用:

但是,当我尝试在探测器内部访问
regs->rdi
时,编译器会抱怨

error: ‘struct pt_regs’ has no member named ‘rdi’
在模块初始化期间,我运行此检查时没有出现任何问题:

#ifndef CONFIG_X86_64
 printk(KERN_ALERT "Error: this module only supports x86_64!\n");
 return -EINVAL;
#endif
还有什么我应该看的吗?
uname-r
返回
2.6.32-279.14.1.el6.x86\u 64.debug

这里是一个MWE:

#include <linux/module.h> 
#include <linux/kernel.h>
#include <linux/kprobes.h>
#include <linux/blkdev.h>

static int kprobe_test(struct kprobe *p, struct pt_regs *regs) {
  printk(KERN_INFO "rdi: %p\n", regs->rdi);
  return 0;
}

static struct kprobe myprobe = {
  .pre_handler = NULL,
  .post_handler = kprobe_test,
  .fault_handler = NULL,
  .addr = (kprobe_opcode_t *) generic_make_request,
};

int init_module(void) {
  register_kprobe(&myprobe);
  return 0;
}

void cleanup_module(void) {
  unregister_kprobe(&myprobe);
}

定义
\uuuu内核时,
pt\u reg
的定义会更改。试着改用
di

明白了,我正在浏览ptrace.h,但从来没有真正想到过。非常感谢!
...
/home/user/kmod/kprobe_64_mwe/kprobe_mwe.c:7: error: ‘struct pt_regs’ has no member named ‘rdi’
...