title: Write Error: bad address on writing encrypted data to wrapper filesystem
body: <p>I am implementing a simple caeser cipher on <a href="http://wrapfs.filesystems.org/" rel="nofollow">WrapFS</a> to store encrypted data and decrypt while reading. For that purpose I made minor changes to <code>wrapfs_read() and wrapfs_write()</code> functions provided in the source code to encrypt and decypt the data. My decryption is working fine, but due to my encryption code I am getting an error on write as follows <code>bash: echo: write error: bad address</code>. Any help regarding handling it would be really appreciated.</p>
  
  <pre><code>void caeser_encrypt(char __user *encrypted, size_t count)
  {
      int i;
      for(i=0;i&lt;(unsigned int)count;i++)
          encrypted[i]=encrypted[i]+3;
      printk(KERN_INFO "%s",encrypted);
      return;
  }
  
  static ssize_t wrapfs_write(struct file *file, const char __user *buf,
                  size_t count, loff_t *ppos)
  {
      int err = 0;
      struct file *lower_file;
      struct dentry *dentry = file-&gt;f_path.dentry;
      char *encrypted = NULL;
  
      lower_file = wrapfs_lower_file(file);
  
  /*Added by me*/
      encrypted=kmalloc(sizeof(buf),GFP_USER);
      memcpy(encrypted,buf,count);
      printk(KERN_INFO "%d %d",(int)sizeof(buf), (int)count);
      caeser_encrypt(encrypted,count);
      err = vfs_write(lower_file, encrypted, count, ppos);
  /*Added by me*/
  
      //err = vfs_write(lower_file, buf, count, ppos);
      /* update our inode times+sizes upon a successful lower write */
      if (err &gt;= 0) {
          fsstack_copy_inode_size(dentry-&gt;d_inode,
                      lower_file-&gt;f_path.dentry-&gt;d_inode);
          fsstack_copy_attr_times(dentry-&gt;d_inode,
                      lower_file-&gt;f_path.dentry-&gt;d_inode);
      }
  
  /*Added by me*/
      kfree(encrypted);
      return err;
  }
  </code></pre>