From 19fd2507caaef03f08007fb26c4cb692c80961cd Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Thu, 23 Apr 2015 14:15:05 +0200 Subject: [PATCH] geli: Accept onetime requests from userland without TRIM awareness Previously a patched kernel would rejects onetime requests from an unpatched userland: $ geli version kernel: 7 userland: 7 $ geli onetime -s 4096 /dev/gpt/swap-ada0 geli: Missing trim argument After the (common) update steps: 1) Update kernel 2) Reboot 3) Update userland the system would be running without encrypted swap after the next reboot. --- sys/geom/eli/g_eli_ctl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sys/geom/eli/g_eli_ctl.c b/sys/geom/eli/g_eli_ctl.c index 4b221c5..094c4cb 100644 --- a/sys/geom/eli/g_eli_ctl.c +++ b/sys/geom/eli/g_eli_ctl.c @@ -256,18 +256,15 @@ g_eli_ctl_onetime(struct gctl_req *req, struct g_class *mp) gctl_error(req, "No '%s' argument.", "detach"); return; } - trim = gctl_get_paraml(req, "trim", sizeof(*trim)); - if (trim == NULL) { - gctl_error(req, "No '%s' argument.", "trim"); - return; - } strlcpy(md.md_magic, G_ELI_MAGIC, sizeof(md.md_magic)); md.md_version = G_ELI_VERSION; md.md_flags |= G_ELI_FLAG_ONETIME; if (*detach) md.md_flags |= G_ELI_FLAG_WO_DETACH; - if (*trim) + + trim = gctl_get_paraml(req, "trim", sizeof(*trim)); + if (trim != NULL && *trim) md.md_flags |= G_ELI_FLAG_DELETE; md.md_ealgo = CRYPTO_ALGORITHM_MIN - 1; -- 2.3.0