mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nick Piggin <npiggin@kernel.dk>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] vfs: fix race in rcu lookup of pruned dentry
Date: Mon, 18 Jul 2011 12:04:11 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.00.1107181135170.2722@sister.anvils> (raw)
In-Reply-To: <CA+55aFxKRw8NxcHKzsSeCX3ud6eDrcQvAX+LMQOUT4p5TPLp5g@mail.gmail.com>

On Mon, 18 Jul 2011, Linus Torvalds wrote:
> On Sun, Jul 17, 2011 at 11:31 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > Now, I do agree that maybe that case simply should check the dentry
> > sequence count. I wish all cases did. Hugh patch did that. But the
> > reason I dislike Hugh's patch is that when I say "I wish they all
> > did", I mean that I dislike the special casing. And Hugh's patch just
> > adds *more* special casing for that NULL entry - I'd wish we just
> > always did it regardless of whether it was NULL or not.
> 
> Btw, looking at that, I think Hugh's patch is wrong. It does
> 
>   if (!read_seqcount_retry(&dentry->d_seq, nd->seq))
> 
> but that's after we've done the __follow_mount_rcu() that may actually
> have changed "nd->seq" to the mount-point inode (and has changed
> path->dentry to match it).

Yes, my patch is wrong there.  I started out with
	if (!read_seqcount_retry(&dentry->d_seq, seq);
but seeing __follow_mount_rcu() updates inode and nd->seq, I changed to
	if (!read_seqcount_retry(&dentry->d_seq, nd->seq);
missing the obvious, that it's changing path->dentry when it updates nd->seq.

> 
> Now, it only does it if inode is NULL, so I guess it doesn't matter,
> but it's the kind of inconsistency that I think is really dangerous,
> because it basically compares incompatible sequence numbers.

Yes, it's simply wrong.

> 
> Also, looking at that whole mount-point traversal sequence, it looks
> like __follow_mount_rcu() will happily totally ignore the old sequence
> number when it replaces it with the mount-point sequence number. So it
> looks to me that we have a case where we miss the sequence number
> check that can happen with a positive dentry too!

Al has commented on that.  I'd feel more confident with a patch like
yours, and corrected final check in mine (if we used mine at all)
	if (!read_seqcount_retry(&path->dentry->d_seq, nd->seq);
but ignore me, I'm easily confused by mounts ;)

Hugh

  parent reply	other threads:[~2011-07-18 19:04 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-17 21:03 Hugh Dickins
2011-07-17 22:00 ` Linus Torvalds
2011-07-17 22:59   ` Linus Torvalds
2011-07-17 23:26     ` Al Viro
2011-07-17 23:16   ` Al Viro
2011-07-17 23:38     ` Linus Torvalds
2011-07-17 23:47       ` Hugh Dickins
2011-07-18  0:25         ` Al Viro
2011-07-18  1:13           ` Hugh Dickins
2011-07-18  2:08             ` Al Viro
2011-07-18  6:31               ` Linus Torvalds
2011-07-18 14:41                 ` Hugh Dickins
2011-07-18 18:11                 ` Linus Torvalds
2011-07-18 18:20                   ` Al Viro
2011-07-18 19:08                     ` Linus Torvalds
2011-07-18 19:20                       ` Al Viro
2011-07-18 19:23                         ` Al Viro
2011-07-18 19:34                         ` Linus Torvalds
2011-07-18 19:04                   ` Hugh Dickins [this message]
2011-07-18 19:33                     ` Linus Torvalds
2011-07-18 19:47                       ` Al Viro
2011-07-18 20:24                         ` Linus Torvalds
2011-07-18 21:19                           ` Hugh Dickins
2011-07-18 21:42                             ` Linus Torvalds
2011-07-18 22:43                               ` Hugh Dickins
2011-07-18 23:17                                 ` Al Viro
2011-07-18 23:21                                   ` Al Viro
2011-07-18 23:27                                     ` Linus Torvalds
2011-07-18 23:40                                       ` Al Viro
2011-07-19  2:07                                         ` Hugh Dickins
2011-07-19  2:14                                           ` Linus Torvalds
2011-07-19  2:17                                             ` Linus Torvalds
2011-07-19  2:23                                               ` Al Viro
2011-07-19  2:37                                                 ` Chris Ball
2011-07-19  4:41                                                 ` Nicolas Pitre
2011-07-19  2:21                                           ` Al Viro
2011-07-19 23:45                               ` Al Viro
2011-07-19 23:52                                 ` Al Viro
2011-07-19 23:55                                   ` Al Viro
2011-07-20  0:47                                     ` NeilBrown
2011-07-20  1:40                                       ` Al Viro
2011-07-20  4:52                                         ` Linus Torvalds
2011-07-19 23:56                                 ` Linus Torvalds
2011-07-20  0:04                                   ` Al Viro
2011-07-17 23:53       ` Al Viro
2011-07-17 23:31   ` Hugh Dickins
2011-07-17 23:52     ` Linus Torvalds

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=alpine.LSU.2.00.1107181135170.2722@sister.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@kernel.dk \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®