title: register_kprobe is returning -2
body: <p>I am trying to hook some kernel function for learning purpose, I wrote the simple kernel module below, but for some reasons, the <code>register_kprobe</code> always returns -2. I didn't find nothing about what it says what this error means and have no idea how to continue. At first I thought it is because <code>list_add</code> is an inline function, so I tried replacing it with <code>kvm_create_vm</code> and got the same result. Then I checked the <code>/proc/kallsyms</code> and found that both don't appear there. <s>So I chose <code>kvm_alloc</code> which is exported, and still I get error -2.</s> I also tried <code>alloc_uid</code> but this worked just fine.</p>
  
  <p>My question: What kind of functions can be hooked with <code>kprobes</code>?</p>
  
  <pre class="lang-c prettyprint-override"><code>#undef __KERNEL__
  #define __KERNEL__
  
  #undef MODULE
  #define MODULE
  
  #include &lt;linux/module.h&gt;
  #include &lt;linux/kernel.h&gt;
  #include &lt;linux/kprobes.h&gt;
  #include &lt;linux/ptrace.h&gt;
  
  MODULE_LICENSE("GPL");
  
  static int pre(struct kprobe *kp, struct pt_regs *regs){
      printk(KERN_INFO "It is working!\n");
      return 0;
  }
  
  static struct kprobe kp = {
      .symbol_name = "list_add",
      .pre_handler = pre,
      .post_handler = NULL,
      .fault_handler = NULL
  };
  
  int init_module(void){
      printk(KERN_INFO "Hi\n");
      printk(KERN_INFO "register_kprobe: %d\n" , register_kprobe(&amp;kp));
      return 0;
  }
  
  void cleanup_module(void){
      unregister_kprobe(&amp;kp);
      printk(KERN_INFO "Bye\n");
  }
  </code></pre>
  
  <h3>Edit</h3>
  
  <p>The line I stroked through was the main reason I got confused. I miss spelled <code>kvm_alloc</code>, it should be <code>kvmalloc</code> without the underscore. And this function got hooked just fine.</p>