f2fs: fix to avoid race during access gc_thread pointer
authorChao Yu <yuchao0@huawei.com>
Mon, 28 May 2018 08:57:32 +0000 (16:57 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 9 Jul 2018 00:40:58 +0000 (17:40 -0700)
commit5dbd21b17b6318324bafdc150c30e3cb099960f6
tree060cf4ee69aa72bcb363acdbbd7d8cc865e5ec4d
parentb6f0cb185000da482c55d71488796e2408f50493
f2fs: fix to avoid race during access gc_thread pointer

Thread A Thread B
- f2fs_remount
 - stop_gc_thread
- f2fs_sbi_store
   sbi->gc_thread = NULL;
  access sbi->gc_thread->gc_*

Previously, we allocate memory for sbi->gc_thread based on background
gc thread mount option, the memory can be released if we turn off
that mount option, but still there are several places access gc_thread
pointer without considering race condition, result in NULL point
dereference.

In order to fix this issue, use sb->s_umount to exclude those operations.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/sysfs.c