From owner-freebsd-bugs@FreeBSD.ORG Wed Oct 19 15:20:10 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37CFE106564A for ; Wed, 19 Oct 2011 15:20:10 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 139888FC17 for ; Wed, 19 Oct 2011 15:20:10 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p9JFK9iE014305 for ; Wed, 19 Oct 2011 15:20:09 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p9JFK9cc014304; Wed, 19 Oct 2011 15:20:09 GMT (envelope-from gnats) Resent-Date: Wed, 19 Oct 2011 15:20:09 GMT Resent-Message-Id: <201110191520.p9JFK9cc014304@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D98A4106564A for ; Wed, 19 Oct 2011 15:11:15 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id BEEF08FC0C for ; Wed, 19 Oct 2011 15:11:15 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p9JFBF7M032654 for ; Wed, 19 Oct 2011 15:11:15 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p9JFBFrJ032653; Wed, 19 Oct 2011 15:11:15 GMT (envelope-from nobody) Message-Id: <201110191511.p9JFBFrJ032653@red.freebsd.org> Date: Wed, 19 Oct 2011 15:11:15 GMT From: Garrett Cooper To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/161807: [patch] add option for explicitly specifying metadata version to geli X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Oct 2011 15:20:10 -0000 >Number: 161807 >Category: bin >Synopsis: [patch] add option for explicitly specifying metadata version to geli >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Oct 19 15:20:09 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: 10-CURRENT >Organization: iXsystems, Inc. >Environment: FreeBSD fallout.local 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r226332M: Wed Oct 12 22:48:55 PDT 2011 root@fallout.local:/usr/obj/usr/src/sys/FALLOUT amd64 >Description: As discussed in this thread [1], geli currently hardcodes the metadata version to whatever's compiled into the binary. pjd@ suggested that a [-V metadata] option be added to override this [2]. The attached patch is based on that suggestion. 1. http://osdir.com/ml/freebsd-geom/2011-10/msg00075.html 2. http://osdir.com/ml/freebsd-geom/2011-10/msg00083.html >How-To-Repeat: >Fix: Patch attached with submission follows: Index: sbin/geom/class/eli/geom_eli.c =================================================================== --- sbin/geom/class/eli/geom_eli.c (revision 226241) +++ sbin/geom/class/eli/geom_eli.c (working copy) @@ -60,6 +60,7 @@ #define GELI_BACKUP_DIR "/var/backups/" #define GELI_ENC_ALGO "aes" +#define GELI_VERSION "6" static void eli_main(struct gctl_req *req, unsigned flags); static void eli_init(struct gctl_req *req); @@ -81,7 +82,7 @@ /* * Available commands: * - * init [-bhPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] prov + * init [-bhPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-V version] prov * label - alias for 'init' * attach [-dprv] [-j passfile] [-k keyfile] prov * detach [-fl] prov ... @@ -112,9 +113,10 @@ { 'l', "keylen", "0", G_TYPE_NUMBER }, { 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, { 's', "sectorsize", "0", G_TYPE_NUMBER }, + { 'V', "eliversion", GELI_VERSION, G_TYPE_NUMBER }, G_OPT_SENTINEL }, - "[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] prov" + "[-bPv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] [-V version] prov" }, { "label", G_FLAG_VERBOSE, eli_main, { @@ -128,6 +130,7 @@ { 'l', "keylen", "0", G_TYPE_NUMBER }, { 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, { 's', "sectorsize", "0", G_TYPE_NUMBER }, + { 'V', "eliversion", GELI_VERSION, G_TYPE_NUMBER }, G_OPT_SENTINEL }, "- an alias for 'init'" @@ -673,9 +676,16 @@ return; } + version = gctl_get_intmax(req, "eliversion"); + if (G_ELI_VERSION_06 < version) { + gctl_error(req, "Invalid metadata version (must be between %d " + "and %d): %d", G_ELI_VERSION_00, G_ELI_VERSION_06, + version); + return; + } bzero(&md, sizeof(md)); strlcpy(md.md_magic, G_ELI_MAGIC, sizeof(md.md_magic)); - md.md_version = G_ELI_VERSION; + md.md_version = version; md.md_flags = 0; if (gctl_get_int(req, "boot")) md.md_flags |= G_ELI_FLAG_BOOT; Index: sbin/geom/class/eli/geli.8 =================================================================== --- sbin/geom/class/eli/geli.8 (revision 226241) +++ sbin/geom/class/eli/geli.8 (working copy) @@ -60,6 +60,7 @@ .Op Fl K Ar newkeyfile .Op Fl l Ar keylen .Op Fl s Ar sectorsize +.Op Fl V Ar eliversion .Ar prov .Nm .Cm label - an alias for @@ -319,6 +320,11 @@ Increasing sector size allows to increase performance, because we need to generate an IV and do encrypt/decrypt for every single sector - less number of sectors means less work to do. +.It Fl V Ar eliversion +Use a specific encryption metadata version when creating encrypted devices. +This defaults to whatever version was compiled into the +.Nm +binary. .El .It Cm attach Attach the given provider. >Release-Note: >Audit-Trail: >Unformatted: