lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d063b5db-7cd6-fbcd-1ece-f3e764b02c23@huawei.com>
Date:   Wed, 18 Apr 2018 17:53:16 +0800
From:   Chao Yu <yuchao0@...wei.com>
To:     <jaegeuk@...nel.org>
CC:     <linux-f2fs-devel@...ts.sourceforge.net>,
        <linux-kernel@...r.kernel.org>, <chao@...nel.org>
Subject: Re: [PATCH 1/5] f2fs: fix race in between GC and atomic open

Hi all,

Please ignore this patch, I just sent this before, sorry.

Thanks,

On 2018/4/18 17:45, Chao Yu wrote:
> Thread					GC thread
> - f2fs_ioc_start_atomic_write
>  - get_dirty_pages
>  - filemap_write_and_wait_range
> 					- f2fs_gc
> 					 - do_garbage_collect
> 					  - gc_data_segment
> 					   - move_data_page
> 					    - f2fs_is_atomic_file
> 					    - set_page_dirty
>  - set_inode_flag(, FI_ATOMIC_FILE)
> 
> Dirty data page can still be generated by GC in race condition as
> above call stack.
> 
> This patch adds fi->dio_rwsem[WRITE] in f2fs_ioc_start_atomic_write
> to avoid such race.
> 
> Signed-off-by: Chao Yu <yuchao0@...wei.com>
> ---
>  fs/f2fs/file.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 78b3a58cfe21..408471bf4799 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1677,6 +1677,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
>  
>  	inode_lock(inode);
>  
> +	down_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
> +
>  	if (f2fs_is_atomic_file(inode))
>  		goto out;
>  
> @@ -1702,6 +1704,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
>  	stat_inc_atomic_write(inode);
>  	stat_update_max_atomic_write(inode);
>  out:
> +	up_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
>  	inode_unlock(inode);
>  	mnt_drop_write_file(filp);
>  	return ret;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ