summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Guifu <bluce.liguifu@huawei.com>2020-07-24 09:38:11 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-03 11:24:21 +0200
commit8cfbac12a68bb660491759d56e37049a05289691 (patch)
tree073507756b3de89afa01767f671fc64c1c9e1583
parent9094d83e14661b0fe8c1d7014e734443b8f4cbb0 (diff)
downloadlinux-stable-8cfbac12a68bb660491759d56e37049a05289691.tar.gz
linux-stable-8cfbac12a68bb660491759d56e37049a05289691.tar.bz2
linux-stable-8cfbac12a68bb660491759d56e37049a05289691.zip
f2fs: fix use-after-free issue
[ Upstream commit 99c787cfd2bd04926f1f553b30bd7dcea2caaba1 ] During umount, f2fs_put_super() unregisters procfs entries after f2fs_destroy_segment_manager(), it may cause use-after-free issue when umount races with procfs accessing, fix it by relocating f2fs_unregister_sysfs(). [Chao Yu: change commit title/message a bit] Signed-off-by: Li Guifu <bluce.liguifu@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/f2fs/super.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9782250c9815..161ce0eb8891 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1004,6 +1004,9 @@ static void f2fs_put_super(struct super_block *sb)
int i;
bool dropped;
+ /* unregister procfs/sysfs entries in advance to avoid race case */
+ f2fs_unregister_sysfs(sbi);
+
f2fs_quota_off_umount(sb);
/* prevent remaining shrinker jobs */
@@ -1067,8 +1070,6 @@ static void f2fs_put_super(struct super_block *sb)
kfree(sbi->ckpt);
- f2fs_unregister_sysfs(sbi);
-
sb->s_fs_info = NULL;
if (sbi->s_chksum_driver)
crypto_free_shash(sbi->s_chksum_driver);