1
0
Fork 0

pstore: Set tfm to NULL on free_buf_for_compression

Set tfm to NULL on free_buf_for_compression() after crypto_free_comp().

This avoid a use-after-free when allocate_buf_for_compression()
and free_buf_for_compression() are called twice. Although
free_buf_for_compression() freed the tfm, allocate_buf_for_compression()
won't reinitialize the tfm since the tfm pointer is not NULL.

Fixes: 95047b0519 ("pstore: Refactor compression initialization")
Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
hifive-unleashed-5.2
Pi-Hsun Shih 2019-05-20 14:51:19 +08:00 committed by Kees Cook
parent a188339ca5
commit a9fb94a99b
1 changed files with 3 additions and 1 deletions

View File

@ -347,8 +347,10 @@ static void allocate_buf_for_compression(void)
static void free_buf_for_compression(void)
{
if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm)
if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) {
crypto_free_comp(tfm);
tfm = NULL;
}
kfree(big_oops_buf);
big_oops_buf = NULL;
big_oops_buf_sz = 0;