Commit 99c787cf authored by Li Guifu's avatar Li Guifu Committed by Jaegeuk Kim

f2fs: fix use-after-free issue

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: default avatarLi Guifu <bluce.liguifu@huawei.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 68e79baf
...@@ -1175,6 +1175,9 @@ static void f2fs_put_super(struct super_block *sb) ...@@ -1175,6 +1175,9 @@ static void f2fs_put_super(struct super_block *sb)
int i; int i;
bool dropped; bool dropped;
/* unregister procfs/sysfs entries in advance to avoid race case */
f2fs_unregister_sysfs(sbi);
f2fs_quota_off_umount(sb); f2fs_quota_off_umount(sb);
/* prevent remaining shrinker jobs */ /* prevent remaining shrinker jobs */
...@@ -1240,8 +1243,6 @@ static void f2fs_put_super(struct super_block *sb) ...@@ -1240,8 +1243,6 @@ static void f2fs_put_super(struct super_block *sb)
kvfree(sbi->ckpt); kvfree(sbi->ckpt);
f2fs_unregister_sysfs(sbi);
sb->s_fs_info = NULL; sb->s_fs_info = NULL;
if (sbi->s_chksum_driver) if (sbi->s_chksum_driver)
crypto_free_shash(sbi->s_chksum_driver); crypto_free_shash(sbi->s_chksum_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment