summaryrefslogtreecommitdiffstats
path: root/sys/geom/eli/g_eli_integrity.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-10-20 20:50:55 +0000
committerpjd <pjd@FreeBSD.org>2010-10-20 20:50:55 +0000
commitd5e7511690c1ec3e58e7d07bc500b130a8f7c138 (patch)
treece8006cd9fd6c42f39b90dbc9fae069f1e7c0fff /sys/geom/eli/g_eli_integrity.c
parent75395aabbce2558e0ce22875c08b0be5db68df05 (diff)
downloadFreeBSD-src-d5e7511690c1ec3e58e7d07bc500b130a8f7c138.zip
FreeBSD-src-d5e7511690c1ec3e58e7d07bc500b130a8f7c138.tar.gz
Bring in geli suspend/resume functionality (finally).
Before this change if you wanted to suspend your laptop and be sure that your encryption keys are safe, you had to stop all processes that use file system stored on encrypted device, unmount the file system and detach geli provider. This isn't very handy. If you are a lucky user of a laptop where suspend/resume actually works with FreeBSD (I'm not!) you most likely want to suspend your laptop, because you don't want to start everything over again when you turn your laptop back on. And this is where geli suspend/resume steps in. When you execute: # geli suspend -a geli will wait for all in-flight I/O requests, suspend new I/O requests, remove all geli sensitive data from the kernel memory (like encryption keys) and will wait for either 'geli resume' or 'geli detach'. Now with no keys in memory you can suspend your laptop without stopping any processes or unmounting any file systems. When you resume your laptop you have to resume geli devices using 'geli resume' command. You need to provide your passphrase, etc. again so the keys can be restored and suspended I/O requests released. Of course you need to remember that 'geli suspend' won't clear file system cache and other places where data from your geli-encrypted file system might be present. But to get rid of those stopping processes and unmounting file system won't help either - you have to turn your laptop off. Be warned. Also note, that suspending geli device which contains file system with geli utility (or anything used by 'geli resume') is not very good idea, as you won't be able to resume it - when you execute geli(8), the kernel will try to read it and this read I/O request will be suspended.
Diffstat (limited to 'sys/geom/eli/g_eli_integrity.c')
-rw-r--r--sys/geom/eli/g_eli_integrity.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/geom/eli/g_eli_integrity.c b/sys/geom/eli/g_eli_integrity.c
index 0103a32..24586bd 100644
--- a/sys/geom/eli/g_eli_integrity.c
+++ b/sys/geom/eli/g_eli_integrity.c
@@ -129,6 +129,7 @@ g_eli_auth_keygen(struct g_eli_softc *sc, off_t offset, u_char *key)
static int
g_eli_auth_read_done(struct cryptop *crp)
{
+ struct g_eli_softc *sc;
struct bio *bp;
if (crp->crp_etype == EAGAIN) {
@@ -152,8 +153,8 @@ g_eli_auth_read_done(struct cryptop *crp)
*/
if (bp->bio_inbed < bp->bio_children)
return (0);
+ sc = bp->bio_to->geom->softc;
if (bp->bio_error == 0) {
- struct g_eli_softc *sc;
u_int i, lsec, nsec, data_secsize, decr_secsize, encr_secsize;
u_char *srcdata, *dstdata, *auth;
off_t coroff, corsize;
@@ -161,7 +162,6 @@ g_eli_auth_read_done(struct cryptop *crp)
/*
* Verify data integrity based on calculated and read HMACs.
*/
- sc = bp->bio_to->geom->softc;
/* Sectorsize of decrypted provider eg. 4096. */
decr_secsize = bp->bio_to->sectorsize;
/* The real sectorsize of encrypted provider, eg. 512. */
@@ -240,6 +240,7 @@ g_eli_auth_read_done(struct cryptop *crp)
* Read is finished, send it up.
*/
g_io_deliver(bp, bp->bio_error);
+ atomic_subtract_int(&sc->sc_inflight, 1);
return (0);
}
@@ -276,6 +277,7 @@ g_eli_auth_write_done(struct cryptop *crp)
*/
if (bp->bio_inbed < bp->bio_children)
return (0);
+ sc = bp->bio_to->geom->softc;
if (bp->bio_error != 0) {
G_ELI_LOGREQ(0, bp, "Crypto WRITE request failed (error=%d).",
bp->bio_error);
@@ -285,9 +287,9 @@ g_eli_auth_write_done(struct cryptop *crp)
bp->bio_driver1 = NULL;
g_destroy_bio(cbp);
g_io_deliver(bp, bp->bio_error);
+ atomic_subtract_int(&sc->sc_inflight, 1);
return (0);
}
- sc = bp->bio_to->geom->softc;
cp = LIST_FIRST(&sc->sc_geom->consumer);
cbp = bp->bio_driver1;
bp->bio_driver1 = NULL;
OpenPOWER on IntegriCloud