linux/fs/f2fs
Chao Yu b73e52824c f2fs: reposition unlock_new_inode to prevent accessing invalid inode
As the race condition on the inode cache, following scenario can appear:
[Thread a]				[Thread b]
					->f2fs_mkdir
					  ->f2fs_add_link
					    ->__f2fs_add_link
					      ->init_inode_metadata failed here
->gc_thread_func
  ->f2fs_gc
    ->do_garbage_collect
      ->gc_data_segment
        ->f2fs_iget
          ->iget_locked
            ->wait_on_inode
					  ->unlock_new_inode
        ->move_data_page
					  ->make_bad_inode
					  ->iput

When we fail in create/symlink/mkdir/mknod/tmpfile, the new allocated inode
should be set as bad to avoid being accessed by other thread. But in above
scenario, it allows f2fs to access the invalid inode before this inode was set
as bad.
This patch fix the potential problem, and this issue was found by code review.

change log from v1:
 o Add condition judgment in gc_data_segment() suggested by Changman Lee.
 o use iget_failed to simplify code.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-02 00:22:24 -07:00
..
Kconfig f2fs: fix typo 2014-08-19 10:01:33 -07:00
Makefile f2fs: key functions to handle inline data 2013-12-26 20:40:09 +09:00
acl.c f2fs: remove the redundant validation check of acl 2014-07-09 14:04:25 -07:00
acl.h f2fs: use generic posix ACL infrastructure 2014-01-25 23:58:19 -05:00
checkpoint.c f2fs: use macro for code readability 2014-08-22 13:56:47 -07:00
data.c f2fs: avoid double lock in truncate_blocks 2014-08-21 13:57:01 -07:00
debug.c f2fs: fix typo 2014-08-19 10:01:33 -07:00
dir.c f2fs: avoid double lock in truncate_blocks 2014-08-21 13:57:01 -07:00
f2fs.h f2fs: remove rewrite_node_page 2014-08-21 13:57:02 -07:00
file.c f2fs: introduce need_do_checkpoint for readability 2014-08-21 13:57:07 -07:00
gc.c f2fs: reposition unlock_new_inode to prevent accessing invalid inode 2014-09-02 00:22:24 -07:00
gc.h f2fs: fix typo 2014-08-19 10:01:33 -07:00
hash.c f2fs: fix wrong casting for dentry name 2014-08-29 00:26:50 -07:00
inline.c f2fs: skip if inline_data was converted already 2014-08-21 13:57:03 -07:00
inode.c f2fs: invalidate xattr node page when evict inode 2014-08-04 13:01:22 -07:00
namei.c f2fs: reposition unlock_new_inode to prevent accessing invalid inode 2014-09-02 00:22:24 -07:00
node.c f2fs: truncate stale block for inline_data 2014-08-25 14:52:09 -07:00
node.h f2fs: refactor flush_nat_entries codes for reducing NAT writes 2014-07-09 14:04:25 -07:00
recovery.c f2fs: remove rewrite_node_page 2014-08-21 13:57:02 -07:00
segment.c f2fs: remove rewrite_node_page 2014-08-21 13:57:02 -07:00
segment.h f2fs: fix typo 2014-08-19 10:01:33 -07:00
super.c f2fs: simplify by using a literal 2014-08-28 09:25:29 -07:00
xattr.c f2fs: fix typo 2014-08-19 10:01:33 -07:00
xattr.h f2fs: pass flags field to setxattr functions 2014-05-07 10:21:56 +09:00