aboutsummaryrefslogtreecommitdiff
path: root/sys/geom/eli/g_eli.c
diff options
context:
space:
mode:
authorColin Percival <cperciva@FreeBSD.org>2014-10-22 23:41:15 +0000
committerColin Percival <cperciva@FreeBSD.org>2014-10-22 23:41:15 +0000
commit66427784c1233629cbe4298073b472c2af4a631f (patch)
tree42841fc5abb0b7084695c9c3c7348c8bb0a10f33 /sys/geom/eli/g_eli.c
parentd4fef7d3422759b8c6177ae5e76f3ff95d7a3dc9 (diff)
downloadsrc-66427784c1233629cbe4298073b472c2af4a631f.tar.gz
src-66427784c1233629cbe4298073b472c2af4a631f.zip
Populate the GELI passphrase cache with the kern.geom.eli.passphrase
variable (if any) provided in the boot environment. Unset it from the kernel environment after doing this, so that the passphrase is no longer present in kernel memory once we enter userland. This will make it possible to provide a GELI passphrase via the boot loader; FreeBSD's loader does not yet do this, but GRUB (and PCBSD) will have support for this soon. Tested by: kmoore
Notes
Notes: svn path=/head/; revision=273489
Diffstat (limited to 'sys/geom/eli/g_eli.c')
-rw-r--r--sys/geom/eli/g_eli.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c
index f545b75bfd0e..23fd7bab0042 100644
--- a/sys/geom/eli/g_eli.c
+++ b/sys/geom/eli/g_eli.c
@@ -93,6 +93,25 @@ SYSCTL_UINT(_kern_geom_eli, OID_AUTO, boot_passcache, CTLFLAG_RD,
&g_eli_boot_passcache, 0,
"Passphrases are cached during boot process for possible reuse");
static void
+fetch_loader_passphrase(void * dummy)
+{
+ char * env_passphrase;
+
+ KASSERT(dynamic_kenv, ("need dynamic kenv"));
+
+ if ((env_passphrase = kern_getenv("kern.geom.eli.passphrase")) != NULL) {
+ /* Extract passphrase from the environment. */
+ strlcpy(cached_passphrase, env_passphrase,
+ sizeof(cached_passphrase));
+ freeenv(env_passphrase);
+
+ /* Wipe the passphrase from the environment. */
+ kern_unsetenv("kern.geom.eli.passphrase");
+ }
+}
+SYSINIT(geli_fetch_loader_passphrase, SI_SUB_KMEM + 1, SI_ORDER_ANY,
+ fetch_loader_passphrase, NULL);
+static void
zero_boot_passcache(void * dummy)
{