From: Eric Biggers <ebiggers3@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Subject: fs/namei.c: Misuse of sequence counts?
Date: Sat, 11 Oct 2014 17:58:08 -0500 [thread overview]
Message-ID: <20141011225808.GA20777@zzz> (raw)
Hi, I've been reading through the path lookup code and I believe there may have
been bugs introduced by commit 4023bfc9 ("be careful with nd->inode in
path_init() and follow_dotdot_rcu()"). And I may have found a pre-existing bug
as well.
In follow_dotdot_rcu(), said commit moved loads of the inode to just before
read_seqcount_begin(), in several instances. I don't think this is correct,
because (as I understand it) read_seqcount_begin() is opening a seq-read
critical section on the new dentry. So the inode load should come *after* it,
as in the original, to ensure the inode pointer is correctly matched with the
sequence count.
In path_init(), said commit added a call to read_seqcount_retry() after loading
the inode. I see two problems with this:
- The read_seqcount_retry() isn't needed just to load the inode pointer, so
the change doesn't seem to accomplish anything.
- If the -ECHILD code path actually runs, the reference to the 'struct file'
can be leaked.
Also: if there were actual problems that were "fixed" by this commit, I wonder
if they were/are actually caused by the fd-relative case in path_init() using:
nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
instead of
nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
since the former is missing a memory barrier before the starting inode is
loaded.
Eric
next reply other threads:[~2014-10-11 22:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-11 22:58 Eric Biggers [this message]
2014-10-11 23:46 ` fs/namei.c: Misuse of sequence counts? Al Viro
2014-10-12 3:55 ` Eric Biggers
2014-10-12 4:29 ` Al Viro
2014-10-12 0:12 ` Al Viro
2014-10-12 4:01 ` Eric Biggers
2014-10-12 4:37 ` Al Viro
2014-10-12 4:51 ` Eric Biggers
2014-10-12 5:08 ` Eric Biggers
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=20141011225808.GA20777@zzz \
--to=ebiggers3@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.