crypto: do not free algorithm before using
authorPan Bian <bianpan2016@163.com>
Thu, 22 Nov 2018 10:00:16 +0000 (18:00 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Dec 2018 08:16:21 +0000 (09:16 +0100)
commit2f94605195abe45078c9983617ea0ea6946b8264
treea3b292447f92ae0445d0630bdd2b52e3fbff7ac4
parent35929281460b2d7cd1876dbb4b0f1d57056a56c5
crypto: do not free algorithm before using

commit e5bde04ccce64d808f8b00a489a1fe5825d285cb upstream.

In multiple functions, the algorithm fields are read after its reference
is dropped through crypto_mod_put. In this case, the algorithm memory
may be freed, resulting in use-after-free bugs. This patch delays the
put operation until the algorithm is never used.

Fixes: 79c65d179a40 ("crypto: cbc - Convert to skcipher")
Fixes: a7d85e06ed80 ("crypto: cfb - add support for Cipher FeedBack mode")
Fixes: 043a44001b9e ("crypto: pcbc - Convert to skcipher")
Cc: <stable@vger.kernel.org>
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
crypto/cbc.c
crypto/cfb.c
crypto/pcbc.c