linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: viro@parcelfarce.linux.theplanet.co.uk
To: Jamie Lokier <jamie@shareable.org>
Cc: Ian Jackson <ijackson@chiark.greenend.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: rename("a","b") succeeds multiple times race
Date: Thu, 24 Apr 2003 22:54:10 +0100	[thread overview]
Message-ID: <20030424215410.GX10374@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <20030424213418.GJ30082@mail.jlokier.co.uk>

On Thu, Apr 24, 2003 at 10:34:18PM +0100, Jamie Lokier wrote:
> That would be most reliable, and you want to do that in case the
> filesystem is NFS, too.  (On the other hand, there are filesystems
> that support rename(2) but not link(2)).
> 
> However rename(2) should not successfully rename from the _old_ path
> more than once, whether the new names are all the same or not.

It shouldn't, but it's a known problem with 2.2.  Unfixable without
massive change of locking scheme.

What happens is that "from" lookup of second rename() succeeds
before the first one is over.  As the result, you get an old
dentry of "a", _then_ second lookup gives you the same dentry -
renamed to "b" by then.  Then you get rename() done with
old and new dentries being identical.  Which is required to
return 0 and do nothing.

It's b0rken and 2.3/2.4/2.5 prevent that crap from happening by
saner locking rules (we keep the parent director{y,ies} locked
across the entire "do lookups for last components and proceed
with actual rename" sequence; see Documentation/filesystem/ for
more details).

2.2 is hopeless in that respect - to fix that nest of races we would
need to replace the locking of directories in namei.c and friends.
I doubt that Alan is happy with that idea...

      reply	other threads:[~2003-04-24 21:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-24 11:57 rename("a","b") succeeds multiple times race Ian Jackson
2003-04-24 14:30 ` Chris Sykes
2003-04-24 16:46   ` Ian Jackson
2003-04-24 21:34   ` Jamie Lokier
2003-04-24 21:54     ` viro [this message]

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=20030424215410.GX10374@parcelfarce.linux.theplanet.co.uk \
    --to=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=ijackson@chiark.greenend.org.uk \
    --cc=jamie@shareable.org \
    --cc=linux-kernel@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).