Skip to content

Commit

Permalink
dm crypt: fix free of bad values after tfm allocation failure
Browse files Browse the repository at this point in the history
If crypt_alloc_tfms() had to allocate multiple tfms and it failed before
the last allocation, then it would call crypt_free_tfms() and could free
pointers from uninitialized memory -- due to the crypt_free_tfms() check
for non-zero cc->tfms[i].  Fix by allocating zeroed memory.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
  • Loading branch information
Eric Biggers authored and Mike Snitzer committed Aug 30, 2016
1 parent 4e870e9 commit 5d0be84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode)
unsigned i;
int err;

cc->tfms = kmalloc(cc->tfms_count * sizeof(struct crypto_skcipher *),
cc->tfms = kzalloc(cc->tfms_count * sizeof(struct crypto_skcipher *),
GFP_KERNEL);
if (!cc->tfms)
return -ENOMEM;
Expand Down

0 comments on commit 5d0be84

Please sign in to comment.