Skip to content

Commit

Permalink
dm crypt: rewrite (wipe) key in crypto layer using random data
Browse files Browse the repository at this point in the history
The message "key wipe" used to wipe real key stored in crypto layer by
rewriting it with zeroes.  Since commit 28856a9 ("crypto: xts -
consolidate sanity check for keys") this no longer works in FIPS mode
for XTS.

While running in FIPS mode the crypto key part has to differ from the
tweak key.

Fixes: 28856a9 ("crypto: xts - consolidate sanity check for keys")
Cc: stable@vger.kernel.org
Signed-off-by: Ondrej Kozina <okozina@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Ondrej Kozina authored and Mike Snitzer committed Apr 24, 2017
1 parent 06eb061 commit c82feee
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2152,12 +2152,16 @@ static int crypt_set_key(struct crypt_config *cc, char *key)

static int crypt_wipe_key(struct crypt_config *cc)
{
int r;

clear_bit(DM_CRYPT_KEY_VALID, &cc->flags);
memset(&cc->key, 0, cc->key_size * sizeof(u8));
get_random_bytes(&cc->key, cc->key_size);
kzfree(cc->key_string);
cc->key_string = NULL;
r = crypt_setkey(cc);
memset(&cc->key, 0, cc->key_size * sizeof(u8));

return crypt_setkey(cc);
return r;
}

static void crypt_dtr(struct dm_target *ti)
Expand Down

0 comments on commit c82feee

Please sign in to comment.