]> git.baikalelectronics.ru Git - kernel.git/commit
libceph: don't call crypto_free_sync_skcipher() on a NULL tfm
authorJia-Ju Bai <baijiaju1990@gmail.com>
Wed, 24 Jul 2019 09:43:06 +0000 (17:43 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 28 Aug 2019 10:33:46 +0000 (12:33 +0200)
commit59bf61366b3b839788ad22f05f36f6ef06117afc
treea037ce4be565b461d56311422a4d6c276a67a452
parentb8786e214867c70a88181789c2584744d61bde86
libceph: don't call crypto_free_sync_skcipher() on a NULL tfm

In set_secret(), key->tfm is assigned to NULL on line 55, and then
ceph_crypto_key_destroy(key) is executed.

ceph_crypto_key_destroy(key)
  crypto_free_sync_skcipher(key->tfm)
    crypto_free_skcipher(&tfm->base);

This happens to work because crypto_sync_skcipher is a trivial wrapper
around crypto_skcipher: &tfm->base is still 0 and crypto_free_skcipher()
handles that.  Let's not rely on the layout of crypto_sync_skcipher.

This bug is found by a static analysis tool STCheck written by us.

Fixes: 58745dacd9e1 ("libceph: Remove VLA usage of skcipher").
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
net/ceph/crypto.c