From mboxrd@z Thu Jan 1 00:00:00 1970 From: Artem Bityutskiy Subject: Re: ubifs, race between link and unlink/rename? Date: Tue, 19 May 2009 09:09:30 +0300 Message-ID: <1242713370.15206.3.camel@localhost.localdomain> References: <9917.1242232308@jrobl> <1242380159.27996.230.camel@localhost.localdomain> Reply-To: dedekind@infradead.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: adrian.hunter@nokia.com, linux-fsdevel@vger.kernel.org To: hooanon05@yahoo.co.jp Return-path: Received: from smtp.nokia.com ([192.100.122.233]:53402 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751998AbZESGJr (ORCPT ); Tue, 19 May 2009 02:09:47 -0400 In-Reply-To: <1242380159.27996.230.camel@localhost.localdomain> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Fri, 2009-05-15 at 12:36 +0300, Artem Bityutskiy wrote: > On Thu, 2009-05-14 at 01:31 +0900, hooanon05@yahoo.co.jp wrote: > > Hello, > >=20 > > Is there a race condition in ubifs? > > Here is a scenario. > >=20 > > Process A Process B > > ----------------------+--------------------------- > > create("dirA/fileA"); | > > unlink("dirA/fileA"); | link("dirA/fileA", "dirB/fileB"); > > | unlink("dirB/fileB"); > > ----------------------+--------------------------- >=20 > From: Hunter Adrian > Date: Thu, 14 May 2009 06:32:30 +0200 > Subject: [PATCH] UBIFS: return error if link and unlink race >=20 > 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. >=20 > This problem was reported by J. R. Okajima >=20 > [Artem: add more comments, amended commit message] >=20 > Signed-off-by: Adrian Hunter > Signed-off-by: Artem Bityutskiy > --- Pushing this patch to ubifs-2.6.git, thanks. --=20 Best regards, Artem Bityutskiy (=D0=91=D0=B8=D1=82=D1=8E=D1=86=D0=BA=D0=B8=D0=B9 =D0=90= =D1=80=D1=82=D1=91=D0=BC) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html