All of lore.kernel.org
 help / color / mirror / Atom feed
From: freeman.zhang1992@gmail.com (Freeman Zhang)
To: kernelnewbies@lists.kernelnewbies.org
Subject: filesystem encryption problem.
Date: Sun, 12 Jul 2015 22:38:53 +0800	[thread overview]
Message-ID: <55A27BFD.2010009@gmail.com> (raw)
In-Reply-To: <CAOGmKrbXH1VgB-RhwY9vwonAz9NRt2ktHyePZU-rq04XXJChLQ@mail.gmail.com>

-------- Original Message --------
> hello
> I am working on adding a simple encryption to file contents in ext4 driver
> (for learning purposes) I added simple XOR encryption to aio_read and
> aio_write functions and it worked until I faced this problem:
> 
> when I open a file in encrypted filesystem using VIM text editor and when I
> try to save it it gives me this error:
> 
>>> pointer block id wrong
>>> can not find line 1
> 
> and it just corrupts the entire file!
> 
> this is my aio_write function:
> 
> aio_write_enc(struct kiocb *iocb, const struct iovec *iov,
>         unsigned long nr_segs, loff_t pos)
> {
>     size_t i;
>     ssize_t ret;
>     char *data=vmalloc(sizeof(char)*iov->iov_len);
>     copy_from_user(data,iov->iov_base,iov->iov_len);
> 
>     for(i=0;i<iov->iov_len;i++)
>     {
>         data[i]^=5;
>     }
>     struct iovec iov_enc= { .iov_base = iov->iov_base, .iov_len =
> iov->iov_len };
> 
>     copy_to_user(iov_enc.iov_base,data,iov->iov_len);
>     ret=ext4_file_write(iocb,&iov_enc,nr_segs,pos);
>     vfree(data);
>     return ret;
> }
> 
> this just changes the data and then calls original function.
> 
> is there anything wrong with this function? can anyone help me?
> 
> 
> 
Hi Amir,

I'm not quite sure about what's wrong with your function, but here are
two suggestions I got from the list when I did similar things:

1. wrapfs
2. ecryptfs

I think you should check these two stackable filesystems if you haven't.

Hope this can help a little bit!

Freeman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150712/a9929b1d/attachment.bin 

  reply	other threads:[~2015-07-12 14:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-12 10:20 filesystem encryption problem Amir Hezarkhani
2015-07-12 14:38 ` Freeman Zhang [this message]
2015-07-12 15:03   ` Rohan Puri
2015-07-12 16:50     ` Amir Hezarkhani
2015-07-12 17:30       ` Rohan Puri
     [not found]         ` <CAOGmKrYiOBLtbyYv7odNirbtrTkF8ZWAtMd+Xo=MRNLxUiS7zA@mail.gmail.com>
     [not found]           ` <CALJfu6Mce-LggXFd4y1Cvjf84SNuDSQ4ciiU10M8vunby8Z2fw@mail.gmail.com>
     [not found]             ` <CAOGmKraQDuEKrBUKy0d2LphZPo3aEDZEMCamBGrcgKkZhqJUNA@mail.gmail.com>
2015-07-13 16:46               ` Rohan Puri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55A27BFD.2010009@gmail.com \
    --to=freeman.zhang1992@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.