Patch "dm crypt: wipe kernel key copy after IV initialization" has been added to the 4.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
dm crypt: wipe kernel key copy after IV initialization
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
dm-crypt-wipe-kernel-key-copy-after-iv-initialization.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
dc94902bde1e158cd19c4deab208e5d6eb382a44Mon Sep 17 00:00:00 2001
From: Ondrej Kozina <[email protected]>
Date: Fri, 12 Jan 2018 16:30:32 +0100
Subject: dm crypt: wipe kernel key copy after IV initialization
From: Ondrej Kozina <[email protected]>
commit dc94902bde1e158cd19c4deab208e5d6eb382a44 upstream.
Loading key via kernel keyring service erases the internal key copy immediately after we pass it in crypto layer. This is wrong because IV is initialized later and we use wrong key for the initialization (instead of real key there's just zeroed block).
The bug may cause data corruption if key is loaded via kernel keyring service first and later same crypt device is reactivated using exactly same key in hexbyte representation, or vice versa. The bug (and fix) affects only ciphers using following IVs: essiv, lmk and tcw.
--- drivers/md/dm-crypt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/md/dm-crypt.c +8 -4
@@ -2058,9 +2058,6 @@ static int crypt_set_keyring_key(struct ret =crypt_setkey (cc); -/* wipe the kernel key payload copy in each case */ -memset (cc->key,0 , cc->key_size *sizeof (u8)); -if (!ret) {set_bit (DM_CRYPT_KEY_VALID , &cc->flags);kzfree (cc->key_string);
@@ -2528,6 +2525,10 @@ static int crypt_ctr_cipher(struct dm_ta } } +/* wipe the kernel key payload copy */ +if (cc->key_string) +memset (cc->key,0 , cc->key_size *sizeof (u8)); +return ret; }
@@ -2966,6 +2967,9 @@ static int crypt_message(struct dm_targereturn ret;if (cc->iv_gen_ops && cc->iv_gen_ops->init) ret = cc->iv_gen_ops->init (cc); +/* wipe the kernel key payload copy */ +if (cc->key_string) +memset (cc->key,0 , cc->key_size *sizeof (u8));return ret; }if (argc ==2 && !strcasecmp (argv[1 ],"wipe" )) {
@@ -3012,7 +3016,7 @@ static void crypt_io_hints(struct dm_tarstatic struct target_type crypt_target = { .name ="crypt" , - .version = {1 ,18 ,0 }, + .version = {1 ,18 ,1 }, .module =THIS_MODULE , .ctr = crypt_ctr, .dtr = crypt_dtr,
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/dm-crypt-wipe-kernel-key-copy-after-iv-initialization.patch