linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ted Unangst <tedu@stanford.edu>
To: Ingo Oeser <ingo.oeser@informatik.tu-chemnitz.de>
Cc: linux-mm@kvack.org
Subject: Re: help for swap encryption
Date: Sat, 18 Aug 2001 15:22:57 -0700 (PDT)	[thread overview]
Message-ID: <Pine.GSO.4.31.0108181436010.5751-100000@cardinal0.Stanford.EDU> (raw)
In-Reply-To: <20010818195312.I9870@nightmaster.csn.tu-chemnitz.de>

On Sat, 18 Aug 2001, Ingo Oeser wrote:

[complaint about filesystem code]
> No. address_space_operations is the interface.

Rik initially told me to come in at rw_swap_page_base().  but the real
work is done by calling brw_page(rw, page, dev, zones, block_size).  which
lives in fs/buffer.c.  but all the pages coming and going to the disk go
through here, so this is where i want to hook in.

address_space_operations:writepage -> swap_writepage -> rw_swap_page ->
rw_swap_page_base().  pretty much wrappers.  until it calls submit_bh
which i couldn't find source for.  but by now we're way out of the mm/
code, and i don't want to mess with it.


> > well, hopefully, it won't be too much trouble to help me.  i know you're
> > busy.  :)  someone else?
>
> I have spend some time thinking about this. We have the
> address_space_operations for this. You can encrypt/decrypt while
> your page is locked for IO and set a flag on your page. So you
> decrypt or zero on readpage and encrypt on writepage.
>
> Later you just read/write with the "inherited" function from the
> swap_aops (in mm/swap_stat.c). How does that sound?

rw_swap_page might be a little cleaner.  it's the "gateway" as far as i
can tell.  last function to touch the page going out, and first to touch
it coming in.

> Another problem is, that you need to encrypt/decrypt IN PLACE,
> which is not possible with the current cryptoapi, or have to
> copy data around in PAGEs (which costs performance).

i was going to use my own crypto routines, at first, just to make it work.
but this is the real problem i see coming up.  where (in memory) do we do
these operations?  in place would be easiest, but it means not keeping the
page in swap cache.  if we move it somewhere else, that somewhere else
needs RAM too.  dynamic allocation won't work because if we're swapping
out, we probably don't have much memory to spare.  so we need to
preallocate a buffer.  i fear this will lead to ungodly performance.
imagine swapping in with a buffer of X.  read X pages, then you have to
stop until they decrypt.  then read X more.

> If you encrypt in place, then you cannot allow two instances. You
> have to require a readpage after every writepage of the same
> page. But this shouldn't happen that often...

is it possible to keep pages from going in the swap cache?  in practice,
if we just sent the page to disk, aren't we going to free it anyway and
use it for some other purpose?

btw:  this should be obvious, but i'm missing it.  i have a page struct
that i pass to encrypt_page(page).  how do i access the memory with
pointers?  at some point, i need to acces the page as a big array.

thanks for help.  (please excuse VM naivity.  :))

ted




--
"The contagious people of Washington have stood firm against diversity
during this long period of increment weather."
      - M. Barry Mayor of Washington, DC

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

      reply	other threads:[~2001-08-18 22:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.GSO.4.31.0108161312050.29454-100000@cardinal0.Stanford.EDU>
2001-08-17  2:09 ` Rik van Riel
2001-08-17  3:37   ` Ted Unangst
2001-08-18 17:53     ` Ingo Oeser
2001-08-18 22:22       ` Ted Unangst [this message]

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=Pine.GSO.4.31.0108181436010.5751-100000@cardinal0.Stanford.EDU \
    --to=tedu@stanford.edu \
    --cc=ingo.oeser@informatik.tu-chemnitz.de \
    --cc=linux-mm@kvack.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox