Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting args from kprobe not finding regs->rdi x86_64
    primarykey
    data
    text
    <p>I'm writing a kernel module under Scientific Linux 6.3 x86_64 and I'm looking to use kprobes. In this module, I need access to the first argument of a function on return, so jprobes are out.</p> <p>I found this very helpful post: <a href="https://stackoverflow.com/questions/10563635/getting-function-arguments-using-kprobes">Getting function arguments using kprobes</a></p> <p>However, when I try accessing <code>regs-&gt;rdi</code> inside my probe, the compiler complains with</p> <pre><code>error: ‘struct pt_regs’ has no member named ‘rdi’ </code></pre> <p>During my module initialization, I run this check with no problems:</p> <pre><code>#ifndef CONFIG_X86_64 printk(KERN_ALERT "Error: this module only supports x86_64!\n"); return -EINVAL; #endif </code></pre> <p>Is there anything else I should be looking at? <code>uname -r</code> returns <code>2.6.32-279.14.1.el6.x86_64.debug</code></p> <p>Here is a MWE:</p> <pre><code>#include &lt;linux/module.h&gt; #include &lt;linux/kernel.h&gt; #include &lt;linux/kprobes.h&gt; #include &lt;linux/blkdev.h&gt; static int kprobe_test(struct kprobe *p, struct pt_regs *regs) { printk(KERN_INFO "rdi: %p\n", regs-&gt;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(&amp;myprobe); return 0; } void cleanup_module(void) { unregister_kprobe(&amp;myprobe); } </code></pre> <p>Which results in:</p> <pre><code>... /home/user/kmod/kprobe_64_mwe/kprobe_mwe.c:7: error: ‘struct pt_regs’ has no member named ‘rdi’ ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload