summaryrefslogtreecommitdiffstats
path: root/fs/pstore/platform.c
diff options
context:
space:
mode:
authorPi-Hsun Shih <pihsun@chromium.org>2019-05-20 14:51:19 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-11 12:19:16 +0200
commit3d388ad42027b8155c635aa3b9699eba76e4585b (patch)
tree8435a3f5117a548960614f9eb7b1fc3096cf7d2e /fs/pstore/platform.c
parent62fc9aae41bd9f2f5da55847c5e30be838106e90 (diff)
downloadlinux-stable-3d388ad42027b8155c635aa3b9699eba76e4585b.tar.gz
linux-stable-3d388ad42027b8155c635aa3b9699eba76e4585b.tar.bz2
linux-stable-3d388ad42027b8155c635aa3b9699eba76e4585b.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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/pstore/platform.c')
-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 75887a269b64..8355a46638d0 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -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;