Skip to content

Commit 99c787c

Browse files
Li GuifuJaegeuk Kim
authored andcommitted
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: Li Guifu <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 68e79ba commit 99c787c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/f2fs/super.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,9 @@ static void f2fs_put_super(struct super_block *sb)
11751175
int i;
11761176
bool dropped;
11771177

1178+
/* unregister procfs/sysfs entries in advance to avoid race case */
1179+
f2fs_unregister_sysfs(sbi);
1180+
11781181
f2fs_quota_off_umount(sb);
11791182

11801183
/* prevent remaining shrinker jobs */
@@ -1240,8 +1243,6 @@ static void f2fs_put_super(struct super_block *sb)
12401243

12411244
kvfree(sbi->ckpt);
12421245

1243-
f2fs_unregister_sysfs(sbi);
1244-
12451246
sb->s_fs_info = NULL;
12461247
if (sbi->s_chksum_driver)
12471248
crypto_free_shash(sbi->s_chksum_driver);

0 commit comments

Comments
 (0)