Skip to contentSkip to conversation

crypto for LVM2

PATCH In review Ben Slusky 4 participants 5 messages May 3, 2004 – May 4, 2004

Subsystems (2)
lore
Share & tools
lore

Ben Slusky

author
#0 lore raw

PATCH 1/1 crypto for LVM2

Hello LVM people,

I'd like to submit for discussion this patch (against version 2.00.08), which adds the ability to create and manipulate encrypted volumes, using the dm-crypt target that was merged into kernel 2.6.4.

From the user's perspective, there are now two more options to lvcreate:
-e or --encryption, to specify the cipher; and -E or --keysize, to specify the key size (in bits). These options can also be used with lvchange, as can the -k or --changekey option, which will prompt the user for a new key.

The encryption key is not stored with the metadata, as that would kinda defeat the purpose of encryption. LVM will ask for it when it's needed. That turns out to be about often enough, IMHO.

Other points to note:

* LVM accepts the key as a raw hexadecimal string. That's not pretty but it keeps LVM out of the key management business, which I believe is a Good Thing. For your basic encryption with a passphrase, I recommend using hashalot[1]: hashalot -x sha512 |lvcreate ... should do the trick.

* If you try to create an encrypted and striped volume, lvcreate will inform you that this isn't possible. The necessary support for compound volumes just isn't there. I assume that's somewhere down the line in the development plan?

Questions? Comments? Flames?
-
-Ben

[1] <URL:http://www.paranoiacs.org/~sluskyb/hacks/hashalot/>

Signature · 4 lines
Ben Slusky                      | "O Lord, make my enemies
[email protected]          |  ridiculous."
[email protected]              |               -Voltaire
PGP keyID ADA44B3B      
configure +1 -1
diff -pruN LVM2.2.00.08/configure LVM2.2.00.08+crypto/configure
@@ -1997,7 +1997,7 @@ fi
 
 fi
 
-for ac_func in mkdir rmdir uname
+for ac_func in mkdir rmdir uname mlock sysconf
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
 echo "configure:2004: checking for $ac_func" >&5
configure.in +1 -1
diff -pruN LVM2.2.00.08/configure.in LVM2.2.00.08+crypto/configure.in
@@ -130,7 +130,7 @@ dnl Checks for library functions.
 AC_PROG_GCC_TRADITIONAL
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(mkdir rmdir uname)
+AC_CHECK_FUNCS(mkdir rmdir uname mlock sysconf)
 
 dnl check for termcap (Shamelessly copied from parted 1.4.17)
 if test x$READLINE = xyes; then
include/.symlinks +2 -0
diff -pruN LVM2.2.00.08/include/.symlinks LVM2.2.00.08+crypto/include/.symlinks
@@ -4,6 +4,7 @@
 ../lib/commands/toolcontext.h
 ../lib/config/config.h
 ../lib/config/defaults.h
+../lib/crypto/crypto.h
 ../lib/datastruct/bitset.h
 ../lib/datastruct/btree.h
 ../lib/datastruct/hash.h
@@ -31,6 +32,7 @@
 ../lib/misc/crc.h
 ../lib/misc/lib.h
 ../lib/misc/lvm-file.h
+../lib/misc/lvm-mlock.h
 ../lib/misc/lvm-string.h
 ../lib/misc/sharedlib.h
 ../lib/regex/matcher.h
lib/Makefile.in +2 -0
diff -pruN LVM2.2.00.08/lib/Makefile.in LVM2.2.00.08+crypto/lib/Makefile.in
@@ -17,6 +17,7 @@ SOURCES=\
 	cache/lvmcache.c \
 	commands/toolcontext.c \
 	config/config.c \
+	crypto/crypto.c \
 	datastruct/bitset.c \
 	datastruct/btree.c \
 	datastruct/hash.c \
@@ -49,6 +50,7 @@ SOURCES=\
 	metadata/snapshot_manip.c \
 	misc/crc.c \
 	misc/lvm-file.c \
+	misc/lvm-mlock.c \
 	misc/lvm-string.c \
 	mm/memlock.c \
 	mm/pool.c \
lib/activate/dev_manager.c +23 -0
diff -pruN LVM2.2.00.08/lib/activate/dev_manager.c LVM2.2.00.08+crypto/lib/activate/dev_manager.c
@@ -13,6 +13,8 @@
 #include "fs.h"
 #include "defaults.h"
 #include "toolcontext.h"
+#include "crypto.h"
+#include "lvm-mlock.h"
 
 #include <libdevmapper.h>
 #include <limits.h>
@@ -805,6 +807,27 @@ static int _emit_target_line(struct dev_
 			goto error;
 		w = tw;
 		break;
+	case SEG_CRYPTO:
+		if (segment_cipher(seg)) {
+			target = "crypt";
+
+			if (lvm_mlock(params, paramsize) < 0) {
+				perror("mlock");
+				log_warn("_emit_target: Couldn't lock memory: "
+					 "mlock(2) failed");
+			}
+
+			if ((tw = lvm_snprintf(params, paramsize, "%s %s %" PRIu64 " ",
+					       segment_cipher(seg),
+					       get_lv_key(seg->lv), 0ULL)) < 0)
+				goto error;
+			w = tw;
+		} else {
+			log_error("_emit_target: Internal error: SEG_CRYPTO "
+				  "with no cipher");
+			return 0;
+		}
+		break;
 	}
 
 	for (s = start_area; s < areas; s++, w += tw) {
lib/crypto/crypto.c +93 -0

93 lines not on this page · raw message

lib/crypto/crypto.h +14 -0
diff -pruN LVM2.2.00.08/lib/crypto/crypto.h LVM2.2.00.08+crypto/lib/crypto/crypto.h
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2004 Ben Slusky <[email protected]>
+ *
+ * This file is released under the LGPL.
+ */
+
+#ifndef _LVM_CRYPTO_H
+#define _LVM_CRYPTO_H
+
+#include "metadata.h"
+
+const char *get_lv_key(const struct logical_volume *lv);
+
+#endif
lib/display/display.c +8 -1
diff -pruN LVM2.2.00.08/lib/display/display.c LVM2.2.00.08+crypto/lib/display/display.c
@@ -43,7 +43,8 @@ static struct {
 	{
 	SEG_STRIPED, "striped"}, {
 	SEG_MIRRORED, "mirror"}, {
-	SEG_SNAPSHOT, "snapshot"}
+	SEG_SNAPSHOT, "snapshot"}, {
+	SEG_CRYPTO, "encrypted"}
 };
 
 static int _num_policies = sizeof(_policies) / sizeof(*_policies);
@@ -556,6 +557,12 @@ int lvdisplay_segments(struct logical_vo
 			_display_stripe(seg, 1, "    ");
 			log_print(" ");
 			break;
+		case SEG_CRYPTO:
+			_display_stripe(seg, 0, "  ");
+			log_print("  Cipher\t\t%s (%u-bit)", segment_cipher(seg),
+				  8 * segment_keysize(seg));
+			log_print(" ");
+			break;
 		}
 	}
 
lib/format1/format1.c +5 -0
diff -pruN LVM2.2.00.08/lib/format1/format1.c LVM2.2.00.08+crypto/lib/format1/format1.c
@@ -352,6 +352,11 @@ static int _lv_setup(struct format_insta
 				       SIZE_SHORT));
 		return 0;
 	}
+	if (lv->cipher) {
+		log_error("encrypted volumes are not allowed in LVM1 "
+			  "volume groups");
+		return 0;
+	}
 
 	return 1;
 }
lib/format_text/export.c +5 -0
diff -pruN LVM2.2.00.08/lib/format_text/export.c LVM2.2.00.08+crypto/lib/format_text/export.c
@@ -395,6 +395,7 @@ static int _print_segment(struct formatt
 
 	case SEG_MIRRORED:
 	case SEG_STRIPED:
+	case SEG_CRYPTO:
 		type = (seg->type == SEG_MIRRORED) ? "mirror" : "stripe";
 		_outf(f, "%s_count = %u%s", type, seg->area_count,
 		      (seg->area_count == 1) ? "\t# linear" : "");
@@ -566,6 +567,10 @@ static int _print_lvs(struct formatter *
 			_outf(f, "major = %d", lv->major);
 		if (lv->minor >= 0)
 			_outf(f, "minor = %d", lv->minor);
+		if (lv->cipher) {
+			_outf(f, "cipher_name = \"%s\"", lv->cipher);
+			_outf(f, "key_size = %u", lv->keysize);
+		}
 		_outf(f, "segment_count = %u", _count_segments(lv));
 		f->nl(f);
 
lib/format_text/import_vsn1.c +19 -1
diff -pruN LVM2.2.00.08/lib/format_text/import_vsn1.c LVM2.2.00.08+crypto/lib/format_text/import_vsn1.c
@@ -254,7 +254,7 @@ static int _read_segment(struct pool *me
 		segtype = get_segtype_from_string(cv->v.str);
 	}
 
-	if (segtype == SEG_STRIPED) {
+	if (segtype == SEG_STRIPED || segtype == SEG_CRYPTO) {
 		if (!_read_int32(sn, "stripe_count", &area_count)) {
 			log_error("Couldn't read 'stripe_count' for "
 				  "segment '%s'.", sn->key);
@@ -337,6 +337,7 @@ static int _read_segment(struct pool *me
 		break;
 
 	case SEG_STRIPED:
+	case SEG_CRYPTO:
 		if ((area_count != 1) &&
 		    !_read_int32(sn, "stripe_size", &seg->stripe_size)) {
 			log_error("Couldn't read stripe_size for segment '%s'.",
@@ -543,6 +544,23 @@ static int _read_lvnames(struct format_i
 	if (!_read_int32(lvn, "read_ahead", &lv->read_ahead))
 		lv->read_ahead = 0;
 
+	if ((cn = find_config_node(lvn, "cipher_name", '/'))) {
+		struct config_value *cv = cn->v;
+		if (!cv || !cv->v.str) {
+			log_error("cipher_name must be a string.");
+			return 0;
+		}
+
+		lv->cipher = pool_strdup(mem, cv->v.str);
+
+		if (!_read_int32(lvn, "key_size", &lv->keysize)) {
+			log_error("Couldn't find key size for "
+				  "encrypted logical volume.");
+			return 0;
+		}
+		
+	}
+
 	list_init(&lv->segments);
 
 	lv->vg = vg;
lib/metadata/lv_manip.c +11 -1
diff -pruN LVM2.2.00.08/lib/metadata/lv_manip.c LVM2.2.00.08+crypto/lib/metadata/lv_manip.c
@@ -195,7 +195,7 @@ static int _alloc_linear_area(struct log
 	}
 
 	seg->lv = lv;
-	seg->type = SEG_STRIPED;
+	seg->type = (segment_cipher(seg) ? SEG_CRYPTO : SEG_STRIPED);
 	seg->le = *ix;
 	seg->len = count;
 	seg->area_len = count;
@@ -540,6 +540,8 @@ struct logical_volume *lv_create(struct 
 				 uint32_t stripes,
 				 uint32_t stripe_size,
 				 uint32_t extents,
+				 const char *cipher_name,
+				 uint32_t key_size,
 				 struct volume_group *vg,
 				 struct list *allocatable_pvs)
 {
@@ -571,6 +573,14 @@ struct logical_volume *lv_create(struct 
 
 	lv->size = (uint64_t) extents *vg->extent_size;
 	lv->le_count = extents;
+	if (cipher_name) {
+		if (!(lv->cipher = pool_strdup(vg->cmd->mem, cipher_name))) {
+			stack;
+			return NULL;
+		}
+
+		lv->keysize = key_size;
+	}
 
 	if (!_allocate(vg, lv, allocatable_pvs, 0u, stripes, stripe_size,
 		       NULL, 0u, 0u)) {
lib/metadata/metadata.h +15 -1
diff -pruN LVM2.2.00.08/lib/metadata/metadata.h LVM2.2.00.08+crypto/lib/metadata/metadata.h
@@ -65,7 +65,8 @@ typedef enum {
 typedef enum {
 	SEG_STRIPED,
 	SEG_SNAPSHOT,
-	SEG_MIRRORED
+	SEG_MIRRORED,
+	SEG_CRYPTO
 } segment_type_t;
 
 typedef enum {
@@ -229,9 +230,20 @@ struct logical_volume {
 	uint64_t size;
 	uint32_t le_count;
 
+	char *cipher;
+	uint32_t keysize;
+
 	struct list segments;
 };
 
+static inline const char *segment_cipher(const struct lv_segment *s) {
+	return s->lv->cipher;
+}
+
+static inline uint32_t segment_keysize(const struct lv_segment *s) {
+	return s->lv->keysize;
+}
+
 struct snapshot {
 	struct id id;
 
@@ -392,6 +404,8 @@ struct logical_volume *lv_create(struct 
 				 uint32_t stripes,
 				 uint32_t stripe_size,
 				 uint32_t extents,
+				 const char *cipher_name,
+				 uint32_t key_size,
 				 struct volume_group *vg,
 				 struct list *allocatable_pvs);
 
lib/misc/lvm-mlock.c +31 -0
diff -pruN LVM2.2.00.08/lib/misc/lvm-mlock.c LVM2.2.00.08+crypto/lib/misc/lvm-mlock.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2004 Ben Slusky <[email protected]>
+ *
+ * This file is released under the LGPL.
+ */
+
+#include "lvm-mlock.h"
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+int lvm_mlock(const void *addr, size_t len) {
+	const void *newaddr;
+	size_t newlen;
+	long pagesize = sysconf(_SC_PAGESIZE);
+
+	if (pagesize != -1) {
+		/* round addr down */
+		newaddr = (const void *)(((size_t) addr / pagesize) * pagesize);
+		/* round len up */
+		newlen = ((len + pagesize - 1) / pagesize) * pagesize;
+	} else {
+		perror("sysconf");
+		/* pray that we can pass any old address to mlock() */
+		newaddr = addr;
+		newlen = len;
+	}
+
+	return mlock(newaddr, newlen);
+}
lib/misc/lvm-mlock.h +21 -0
diff -pruN LVM2.2.00.08/lib/misc/lvm-mlock.h LVM2.2.00.08+crypto/lib/misc/lvm-mlock.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2004 Ben Slusky <[email protected]>
+ *
+ * This file is released under the LGPL.
+ */
+
+#ifndef _LVM_MLOCK_H
+#define _LVM_MLOCK_H
+
+#include <unistd.h>
+
+/*
+ * POSIX allows an implementation of mlock to require that the given address
+ * is aligned to a page boundary. Linux' implementation is more forgiving, but
+ * others may not be. lvm_mlock rounds the address down and the length up to a
+ * page boundary.
+ */
+
+int lvm_mlock(const void *addr, size_t len);
+
+#endif
man/lvchange.8 +23 -1
diff -pruN LVM2.2.00.08/man/lvchange.8 LVM2.2.00.08+crypto/man/lvchange.8
@@ -4,8 +4,10 @@ lvchange \- change attributes of a logic
 .SH SYNOPSIS
 .B lvchange
 [\-A/\-\-autobackup y/n] [\-a/\-\-available y/n]
-[\-C/\-\-contiguous y/n] [\-d/\-\-debug] [\-h/\-?/\-\-help]
+[\-C/\-\-contiguous y/n] [\-d/\-\-debug]
+[\-e/\-\-encryption cipher] [\-E/\-\-keysize #bits] [\-h/\-?/\-\-help]
 [\-\-ignorelockingfailure]
+[\-k/\-\-changekey] 
 [\-M/\-\-persistent y/n] [\-\-minor minor]
 [\-P/\-\-partial y/n]
 [\-p/\-\-permission r/w] [\-r/\-\-readahead ReadAheadSectors]
@@ -29,6 +31,21 @@ logical volumes. It's only possible to c
 logical volume's allocation policy to contiguous, if all of the
 allocated physical extents are already contiguous.
 .TP
+.I \-e, \-\-encryption cipher
+Set the cipher used to encrypt the data in the logical volume.
+See \fBNOTES\fP below.
+.TP
+.I \-E, \-\-keylength nbits
+Set the key length (in bits) used to encrypt the data in the logical
+volume.
+See \fBNOTES\fP below.
+.TP
+.I \-k, \-\-changekey
+Change the encryption key for a logical volume. The key will be
+read from standard input, and should be given as a string of
+hexadecimal digits.
+See \fBNOTES\fP below.
+.TP
 .I \-\-minor minor
 Set the minor number.
 .TP
@@ -44,6 +61,11 @@ Not used by device-mapper.
 .SH Examples
 "lvchange -x n vg00/lvol1" prevents the allocation of any physical
 extents on logical volume lvol1 in volume group vg00.
+.SH NOTES
+Changing the encryption settings (cipher, key, and/or key size) of
+a volume will \fB*NOT*\fP re-encrypt the data on that volume. If the
+encryption settings do not match the settings that were used
+to write the data, then the data will be \fB*inaccessible*\fP.
 .SH SEE ALSO
 .BR lvm (8), 
 .BR lvcreate (8)
man/lvcreate.8 +8 -1
diff -pruN LVM2.2.00.08/man/lvcreate.8 LVM2.2.00.08+crypto/man/lvcreate.8
@@ -4,7 +4,7 @@ lvcreate \- create a logical volume in a
 .SH SYNOPSIS
 .B lvcreate
 [\-A/\-\-autobackup y/n] [\-C/\-\-contiguous y/n] [\-d/\-\-debug]
-[\-h/\-?/\-\-help]
+[\-e/\-\-encryption cipher] [\-E/\-\-keysize #bits] [\-h/\-?/\-\-help]
 [\-i/\-\-stripes Stripes [\-I/\-\-stripesize StripeSize]]
 {\-l/\-\-extents LogicalExtentsNumber |
  \-L/\-\-size LogicalVolumeSize[kKmMgGtT]}
@@ -47,6 +47,13 @@ Sets or resets the contiguous allocation
 logical volumes. Default is no contiguous allocation based
 on a next free principle.
 .TP
+.I \-e, \-\-encryption cipher
+Set the cipher used to encrypt the data in the logical volume.
+.TP
+.I \-E, \-\-keylength nbits
+Set the key length (in bits) used to encrypt the data in the logical
+volume.
+.TP
 .I \-i, \-\-stripes Stripes
 Gives the number of stripes.
 This is equal to the number of physical volumes to scatter
tools/args.h +3 -0
diff -pruN LVM2.2.00.08/tools/args.h LVM2.2.00.08+crypto/tools/args.h
@@ -47,7 +47,9 @@ arg(columns_ARG, 'C', "columns", NULL)
 arg(contiguous_ARG, 'C', "contiguous", yes_no_arg)
 arg(debug_ARG, 'd', "debug", NULL)
 arg(disk_ARG, 'D', "disk", NULL)
+arg(encryption_ARG, 'e', "encryption", string_arg)
 arg(exported_ARG, 'e', "exported", NULL)
+arg(keysize_ARG, 'E', "keysize", int_arg)
 arg(physicalextent_ARG, 'E', "physicalextent", NULL)
 arg(file_ARG, 'f', "file", string_arg)
 arg(force_ARG, 'f', "force", NULL)
@@ -58,6 +60,7 @@ arg(stripesize_ARG, 'I', "stripesize", s
 arg(stripes_ARG, 'i', "stripes", int_arg)
 arg(interval_ARG, 'i', "interval", int_arg)
 arg(iop_version_ARG, 'i', "iop_version", NULL)
+arg(changekey_ARG, 'k', "changekey", NULL)
 arg(logicalvolume_ARG, 'l', "logicalvolume", int_arg)
 arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", int_arg)
 arg(extents_ARG, 'l', "extents", int_arg_with_sign)
tools/commands.h +15 -6
diff -pruN LVM2.2.00.08/tools/commands.h LVM2.2.00.08+crypto/tools/commands.h
@@ -58,9 +58,12 @@ xx(lvchange,
    "\t[-a|--available y|n]\n"
    "\t[-C|--contiguous y|n]\n"
    "\t[-d|--debug]\n"
+   "\t[-e|--encryption cipher]\n"
+   "\t[-E|--keysize #bits]\n"
    "\t[-f|--force]\n"
    "\t[-h|--help]\n"
    "\t[--ignorelockingfailure]\n"
+   "\t[-k|--changekey] " "\n"
    "\t[-M|--persistent y|n] [--major major] [--minor minor]\n"
    "\t[-P|--partial] " "\n"
    "\t[-p|--permission r|rw]\n"
@@ -70,9 +73,10 @@ xx(lvchange,
    "\t[--version]" "\n"
    "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
 
-   autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
-   ignorelockingfailure_ARG, major_ARG, minor_ARG, partial_ARG, permission_ARG,
-   persistent_ARG, readahead_ARG, test_ARG)
+   autobackup_ARG, available_ARG, changekey_ARG, contiguous_ARG,
+   encryption_ARG, force_ARG, ignorelockingfailure_ARG, keysize_ARG,
+   major_ARG, minor_ARG, partial_ARG, permission_ARG, persistent_ARG,
+   readahead_ARG, test_ARG)
 
 xx(lvcreate,
    "Create a logical volume",
@@ -80,6 +84,8 @@ xx(lvcreate,
    "\t[-A|--autobackup {y|n}]\n"
    "\t[-C|--contiguous {y|n}]\n"
    "\t[-d|--debug]\n"
+   "\t[-e|--encryption cipher]\n"
+   "\t[-E|--keysize #bits]\n"
    "\t[-h|-?|--help]\n"
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
    "\t{-l|--extents LogicalExtentsNumber |\n"
@@ -98,6 +104,8 @@ xx(lvcreate,
    "\t[-c|--chunksize]\n"
    "\t[-A|--autobackup {y|n}]\n"
    "\t[-C|--contiguous {y|n}]\n"
+   "\t[-e|--encryption cipher]\n"
+   "\t[-E|--keysize #bits]\n"
    "\t[-d|--debug]\n"
    "\t[-h|-?|--help]\n"
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
@@ -112,9 +120,10 @@ xx(lvcreate,
    "\t[--version]\n"
    "\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
 
-   autobackup_ARG, chunksize_ARG, contiguous_ARG, extents_ARG, major_ARG, minor_ARG, 
-   name_ARG, permission_ARG, persistent_ARG, readahead_ARG, size_ARG,
-   snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, zero_ARG)
+   autobackup_ARG, chunksize_ARG, contiguous_ARG, encryption_ARG,
+   extents_ARG, keysize_ARG, major_ARG, minor_ARG, name_ARG,
+   permission_ARG, persistent_ARG, readahead_ARG, size_ARG, snapshot_ARG,
+   stripes_ARG, stripesize_ARG, test_ARG, zero_ARG)
 
 xx(lvdisplay,
    "Display information about a logical volume",
tools/lvchange.c +176 -2

196 lines not on this page · raw message

tools/lvcreate.c +21 -1
diff -pruN LVM2.2.00.08/tools/lvcreate.c LVM2.2.00.08+crypto/tools/lvcreate.c
@@ -32,6 +32,9 @@ struct lvcreate_params {
 	uint32_t permission;
 	uint32_t read_ahead;
 
+	const char *encryption;
+	uint32_t keysize;
+
 	int pv_count;
 	char **pvs;
 };
@@ -250,6 +253,18 @@ static int _read_params(struct lvcreate_
 		}
 	}
 
+	if (arg_count(cmd, encryption_ARG) && arg_count(cmd, stripes_ARG)) {
+		log_error("-e and -i are incompatible");
+		return 0;
+	}
+
+	if ((arg_count(cmd, encryption_ARG) && !arg_count(cmd, keysize_ARG)) ||
+	    (arg_count(cmd, keysize_ARG) && !arg_count(cmd, encryption_ARG))) {
+		log_error("Must specify encryption key size with cipher, "
+			  "and vice versa");
+		return 0;
+	}
+
 	if (!_read_name_params(lp, cmd, &argc, &argv) ||
 	    !_read_size_params(lp, cmd, &argc, &argv) ||
 	    !_read_stripe_params(lp, cmd, &argc, &argv))
@@ -304,6 +319,11 @@ static int _read_params(struct lvcreate_
 		}
 	}
 
+	if (arg_count(cmd, encryption_ARG))
+		lp->encryption = arg_value(cmd, encryption_ARG);
+	if (arg_count(cmd, keysize_ARG))
+		lp->keysize = arg_uint_value(cmd, keysize_ARG, 0) / 8;
+
 	lp->pv_count = argc;
 	lp->pvs = argv;
 
@@ -459,7 +479,7 @@ static int _lvcreate(struct cmd_context 
 
 	if (!(lv = lv_create(vg->fid, lp->lv_name, status, alloc,
 			     lp->stripes, lp->stripe_size, lp->extents,
-			     vg, pvh)))
+			     lp->encryption, lp->keysize, vg, pvh)))
 		return 0;
 
 	if (lp->read_ahead) {
#1 lore raw

On Mon, 2004-05-03 19:20:20 -0400, Ben Slusky <[email protected]> wrote in message <[email protected]>:

Quoted 4 lines

I'd like to submit for discussion this patch (against version 2.00.08), which adds the ability to create and manipulate encrypted volumes, using the dm-crypt target that was merged into kernel 2.6.4.

I'm basically running this (md devices as PVs, which form one VG, which contains a number of LVs).

Most of the LVs are encrypted using dm-crypt. It's easy - I've just written a small script to to the dmsetup stuff and mount the newly available (encrypted) LVs. This way, the box boots up fine and is useable. If I want to make those additional (encrypted) LVs available, I may just call that script and supply the password.

So I don't think it's really neccessary to place this functionality into the lvm2 tools; especially, this could possibly block the boot-up process (that's bad on a box which has a dozen unencrypted volumes which would already work fine)...

MfG, JBG

Signature · 4 lines
   Jan-Benedict Glaw       [email protected]    . +49-172-7608481
   "Eine Freie Meinung in  einem Freien Kopf    | Gegen Zensur | Gegen Krieg
    fuer einen Freien Staat voll Freier Bürger" | im Internet! |   im Irak!
   ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
#2 lore raw
Quoted 2 lines · Jan-Benedict Glaw

So I don't think it's really neccessary to place this functionality into the lvm2 tools;

Nothing's necessary of course, but the best idea is to offer people choices and then they can choose what's best for their own particular circumstances.

e.g. someone's encrypted data could be in a separate VG, activated manually after booting by inserting a read-only floppy/CD containing the VG metadata (optionally also containing the encryption key) - and removing that disk after activation.

Alasdair

Signature · 1 line
[email protected]
#3 lore raw
In reply to Ben Slusky
Quoted 2 lines · Ben Slusky

The encryption key is not stored with the metadata, as that would kinda defeat the purpose of encryption.

That depends on the usage - some people may be happy to keep the key in the metadata on removable media.

Quoted 4 lines

* If you try to create an encrypted and striped volume, lvcreate will inform you that this isn't possible. The necessary support for compound volumes just isn't there. I assume that's somewhere down the line in the development plan?

Yes, shouldn't be too far off.

I'm doing some code restructuring at the moment to abstract the various segment types better (see today's check-in).

I'll merge elements of this patch after restructuring.

Alasdair

Signature · 1 line
[email protected]
#4 lore raw
Quoted 7 lines · Alasdair G Kergon
Quoted 2 lines · Ben Slusky

The encryption key is not stored with the metadata, as that would kinda defeat the purpose of encryption.

That depends on the usage - some people may be happy to keep the key in the metadata on removable media.

I haven't kept up with how encrypted filesystems are typically used.

I think there is value in having a key to the computer that is used to "start" it, but that can be locked in a safe most of the time.

That way if a thief tries to steal the entire computer, they end-up with nothing but encrypted data.

I've even had some people tell me that HIPAA's security rule will require something like that at doctor's offices. (ie. security rule goes into effect april 2005.)

Greg

Signature · 1 line
Greg Freemyer