From 0b849985b2a4fd5fe40bd96d94b358218c684308 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Thu, 12 Apr 2018 11:37:24 +0200 Subject: [PATCH] Do not wipe keys for wrapped key enabled ciphers. We can't wipe (overwrite with random noise) wrapped key in kernel. Such keys are usually structured and not only random bytes. Also it doesn't make sense to wipe these keys. They are supposed to be protected (encrypted) by keys sealed in hardware. TODO: tests: 1) with header, 2) without header (dm-crypt only), 3) arch with working paes cipher (at least). --- lib/setup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/setup.c b/lib/setup.c index 668aba67..1affc2cf 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -2345,7 +2345,12 @@ int crypt_suspend(struct crypt_device *cd, key_desc = crypt_get_device_key_description(name); - r = dm_suspend_and_wipe_key(cd, name); + /* we can't simply wipe wrapped keys */ + if (crypt_cipher_wrapped_key(crypt_get_cipher(cd))) + r = dm_suspend_device(cd, name); + else + r = dm_suspend_and_wipe_key(cd, name); + if (r == -ENOTSUP) log_err(cd, _("Suspend is not supported for device %s.\n"), name); else if (r)