linux/fs/f2fs
Chao Yu 08b39fbd59 f2fs crypto: fix racing of accessing encrypted page among
different competitors

Since we use different page cache (normally inode's page cache for R/W
and meta inode's page cache for GC) to cache the same physical block
which is belong to an encrypted inode. Writeback of these two page
cache should be exclusive, but now we didn't handle writeback state
well, so there may be potential racing problem:

a)
kworker:				f2fs_gc:
 - f2fs_write_data_pages
  - f2fs_write_data_page
   - do_write_data_page
    - write_data_page
     - f2fs_submit_page_mbio
(page#1 in inode's page cache was queued
in f2fs bio cache, and be ready to write
to new blkaddr)
					 - gc_data_segment
					  - move_encrypted_block
					   - pagecache_get_page
					(page#2 in meta inode's page cache
					was cached with the invalid datas
					of physical block located in new
					blkaddr)
					   - f2fs_submit_page_mbio
					(page#1 was submitted, later, page#2
					with invalid data will be submitted)

b)
f2fs_gc:
 - gc_data_segment
  - move_encrypted_block
   - f2fs_submit_page_mbio
(page#1 in meta inode's page cache was
queued in f2fs bio cache, and be ready
to write to new blkaddr)
					user thread:
					 - f2fs_write_begin
					  - f2fs_submit_page_bio
					(we submit the request to block layer
					to update page#2 in inode's page cache
					with physical block located in new
					blkaddr, so here we may read gabbage
					data from new blkaddr since GC hasn't
					writebacked the page#1 yet)

This patch fixes above potential racing problem for encrypted inode.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2015-10-13 09:52:34 -07:00
..
acl.c f2fs: make posix_acl_create() safer and cleaner 2015-05-07 11:38:31 -07:00
acl.h f2fs: avoid deadlock on init_inode_metadata 2014-11-03 16:07:33 -08:00
checkpoint.c f2fs: support lower priority asynchronous readahead in ra_meta_pages 2015-10-12 14:03:15 -07:00
crypto_fname.c f2fs crypto: clean up error handling in f2fs_fname_setup_filename 2015-06-01 16:21:08 -07:00
crypto_key.c f2fs crypto: delete an unnecessary check before the function call "key_put" 2015-08-04 14:09:52 -07:00
crypto_policy.c f2fs crypto: do not set encryption policy for non-directory by ioctl 2015-06-01 16:21:07 -07:00
crypto.c f2fs crypto: add alloc_bounce_page 2015-06-11 15:04:20 -07:00
data.c f2fs crypto: fix racing of accessing encrypted page among 2015-10-13 09:52:34 -07:00
debug.c f2fs: use atomic64_t for extent cache hit stat 2015-10-09 16:20:55 -07:00
dir.c f2fs: set GFP_NOFS for grab_cache_page 2015-10-12 13:38:03 -07:00
extent_cache.c f2fs: introduce __try_update_largest_extent 2015-10-09 16:20:53 -07:00
f2fs_crypto.h f2fs crypto: remove alloc_page for bounce_page 2015-06-01 16:21:10 -07:00
f2fs.h f2fs crypto: fix racing of accessing encrypted page among 2015-10-13 09:52:34 -07:00
file.c f2fs crypto: fix racing of accessing encrypted page among 2015-10-13 09:52:34 -07:00
gc.c f2fs crypto: fix racing of accessing encrypted page among 2015-10-13 09:52:34 -07:00
gc.h f2fs: support synchronous gc in ioctl 2015-10-09 16:20:56 -07:00
hash.c f2fs: introduce dot and dotdot name check 2015-05-28 15:41:34 -07:00
inline.c f2fs: fix error handling for calls to various functions in the function recover_inline_data 2015-10-09 16:20:53 -07:00
inode.c f2fs: no need to lock for update_inode_page all the time 2015-10-09 16:20:50 -07:00
Kconfig f2fs: fix typo 2015-08-21 22:43:32 -07:00
Makefile f2fs: maintain extent cache in separated file 2015-08-04 14:09:58 -07:00
namei.c f2fs crypto: allocate buffer for decrypting filename 2015-10-09 16:20:51 -07:00
node.c f2fs: export ra_nid_pages to sysfs 2015-10-12 14:03:43 -07:00
node.h f2fs: export ra_nid_pages to sysfs 2015-10-12 14:03:43 -07:00
recovery.c f2fs: support lower priority asynchronous readahead in ra_meta_pages 2015-10-12 14:03:15 -07:00
segment.c f2fs crypto: fix racing of accessing encrypted page among 2015-10-13 09:52:34 -07:00
segment.h Revert "f2fs: do not skip dentry block writes" 2015-10-12 13:38:02 -07:00
shrinker.c f2fs: shrink free_nids entries 2015-08-20 09:00:06 -07:00
super.c f2fs: export ra_nid_pages to sysfs 2015-10-12 14:03:43 -07:00
trace.c f2fs: add sbi and page pointer in f2fs_io_info 2015-05-28 15:41:32 -07:00
trace.h f2fs: add sbi and page pointer in f2fs_io_info 2015-05-28 15:41:32 -07:00
xattr.c f2fs: correct return value of ->setxattr 2015-08-04 14:09:59 -07:00
xattr.h f2fs crypto: add encryption xattr support 2015-05-28 15:41:47 -07:00