From: Hunter Adrian Date: Thu, 14 May 2009 04:32:30 +0000 (+0200) Subject: UBIFS: return error if link and unlink race X-Git-Tag: Release-2010-05/1~3^2~74 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64427711828a05d54c1f99efab691a02d7134904;p=pandora-kernel.git UBIFS: return error if link and unlink race Consider a scenario when 'vfs_link(dirA/fileA)' and 'vfs_unlink(dirA/fileA, dirB/fileB)' race. 'vfs_link()' does not lock 'dirA->i_mutex', so this is possible. Both of the functions lock 'fileA->i_mutex' though. Suppose 'vfs_unlink()' wins, and takes 'fileA->i_mutex' mutex first. Suppose 'fileA->i_nlink' is 1. In this case 'ubifs_unlink()' will drop the last reference, and put 'inodeA' to the list of orphans. After this, 'vfs_link()' will link 'dirB/fileB' to 'inodeA'. Thir is a problem because, for example, the subsequent 'vfs_unlink(dirB/fileB)' will add the same inode to the list of orphans. This problem was reported by J. R. Okajima [Artem: add more comments, amended commit message] Signed-off-by: Adrian Hunter Signed-off-by: Artem Bityutskiy --- Reading git-diff-tree failed