title: System call interception in linux-kernel module (kernel 3.5)
body: <p>I need to replace a standard system call (e.g. SYS_mkdir) with my own implementation.</p>
  
  <p>As I read in some sources, including <a href="https://stackoverflow.com/questions/12613301/loadable-kernel-module-programming-and-system-call-interception">this question</a> on Stackoverflow, the <code>sys_call_table</code> is not exported symbol since kernel version <code>2.6</code>.</p>
  
  <p>I tried the following code:</p>
  
  <pre><code>    #include &lt;linux/module.h&gt; 
      #include &lt;linux/kernel.h&gt; 
      #include &lt;linux/unistd.h&gt; 
      #include &lt;asm/syscall.h&gt; 
  
      int (*orig_mkdir)(const char *path); 
  
      ....
  
      int init_module(void) 
      { 
              orig_mkdir=sys_call_table[__NR_mkdir]; 
              sys_call_table[__NR_mkdir]=own_mkdir;  
              printk("sys_mkdir replaced\n"); 
              return(0); 
      } 
  
      ....
  </code></pre>
  
  <p>Unfortunately I receive compiler error:</p>
  
  <pre><code> error: assignment of read-only location ‘sys_call_table[83]’
  </code></pre>
  
  <p>How can I replace the system call?</p>
  
  <p><strong>EDIT:</strong> Is there any solution without kernel patching?</p>