• Chao Yu's avatar
    f2fs: fix to avoid race during access gc_thread pointer · 250dbf51
    Chao Yu authored
    
    
    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: default avatarChao Yu <yuchao0@huawei.com>
    Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
    250dbf51
sysfs.c 19.2 KB