title: Source code example from "Linux kernel programming"
body: <p>was reading Robert Love's book, chapter 5 on syscalls, and found this simple example a bit questionable:</p>
  
  <pre><code>asmlinkage long sys_silly_copy(unsigned long *src, unsigned long *dst, unsigned long len)
  {
     unsigned long buf;
  
     if (copy_from_user(&amp;buf, src, len))
       return -EFAULT;
  
     ...
  }
  </code></pre>
  
  <p>As we see 'buf' is object of type 'unsigned long' and defined on the kernel stack, i.e. its initial value is likely garbage. Anyway is it valid to copy 'len' bytes in the stack where buf is, i.e. it could overwrite something useful? Perhaps this is fine only for this particular example?</p>