linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind@infradead.org>
To: hooanon05@yahoo.co.jp
Cc: adrian.hunter@nokia.com, linux-fsdevel@vger.kernel.org
Subject: Re: ubifs, race between link and unlink/rename?
Date: Tue, 19 May 2009 09:09:30 +0300	[thread overview]
Message-ID: <1242713370.15206.3.camel@localhost.localdomain> (raw)
In-Reply-To: <1242380159.27996.230.camel@localhost.localdomain>

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,
> > 
> > Is there a race condition in ubifs?
> > Here is a scenario.
> > 
> > Process A		Process B
> > ----------------------+---------------------------
> > create("dirA/fileA"); |
> > unlink("dirA/fileA"); |	link("dirA/fileA", "dirB/fileB");
> > 		      | unlink("dirB/fileB");
> > ----------------------+---------------------------
> 
> From: Hunter Adrian <adrian.hunter@nokia.com>
> Date: Thu, 14 May 2009 06:32:30 +0200
> Subject: [PATCH] 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 <hooanon05@yahoo.co.jp>
> 
> [Artem: add more comments, amended commit message]
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
> ---

Pushing this patch to ubifs-2.6.git, thanks.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)

--
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

  reply	other threads:[~2009-05-19  6:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13 16:31 ubifs, race between link and unlink/rename? hooanon05
2009-05-13 18:28 ` Adrian Hunter
2009-05-15  8:44 ` Artem Bityutskiy
2009-05-15  9:35 ` Artem Bityutskiy
2009-05-19  6:09   ` Artem Bityutskiy [this message]
2009-05-19  6:18     ` hooanon05

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242713370.15206.3.camel@localhost.localdomain \
    --to=dedekind@infradead.org \
    --cc=adrian.hunter@nokia.com \
    --cc=hooanon05@yahoo.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).