OSDN Git Service

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:46:54 +0000 (17:46 -0700)
commita1259450b6dba27306a065b4e079d8fb234d0a4e
tree11b103cc45141ef1cdfcd653734781a745c1cac3
parentd2e0f2f786a68136d2fb5c57c669896eba2f4d7f
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