aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPi-Hsun Shih <pihsun@chromium.org>2019-05-20 14:51:19 +0800
committerPaul Gortmaker <paul.gortmaker@windriver.com>2019-09-12 14:08:58 -0400
commit6ae8880e5cb7e2e9da640a9ffb14e84f36955ad3 (patch)
tree7e564ac7cc9899dfe347ec216b58735831280716 /fs
parent96beda0e2b95fc445685fc131c187fedbcde17c7 (diff)
downloadlinux-yocto-6ae8880e5cb7e2e9da640a9ffb14e84f36955ad3.tar.gz
linux-yocto-6ae8880e5cb7e2e9da640a9ffb14e84f36955ad3.tar.bz2
linux-yocto-6ae8880e5cb7e2e9da640a9ffb14e84f36955ad3.zip
pstore: Set tfm to NULL on free_buf_for_compression
commit a9fb94a99bb515d8720ba8440ce3aba84aec80f8 upstream. 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: 95047b0519c1 ("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> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/platform.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index 464a81409974..4dfee2b189b1 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -308,8 +308,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;