All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [RFC] weirdness in ext4_sync_file()
Date: Fri, 24 Jun 2016 05:36:05 +0100	[thread overview]
Message-ID: <20160624043604.GU14480@ZenIV.linux.org.uk> (raw)

Could somebody explain when would the second part of that test _not_ be true?

                if (!ret && !hlist_empty(&inode->i_dentry))
                        ret = ext4_sync_parent(inode);

inode is that of an opened file; how could it possibly _not_ have a dentry
alias?  Is that code actually supposed to check if the sucker is not
unlinked?  If so, it's not what we are actually checking - pinned dentry
remains positive (and unhashed) after unlink(2).  What's more, the loop
in ext4_sync_parent() is vulnerable to races with rmdir(2) - if you
get unlink and rmdir of ancestors between
                next = igrab(d_inode(dentry->d_parent));
and
                inode = next;
                ret = sync_mapping_buffers(inode->i_mapping);
                if (ret)
                        break;
                ret = sync_inode_metadata(inode, 1);
                if (ret)
                        break;
you are risking interesting things done in the middle of rmdir and/or
unlink; that might be actually safe, but in that case it's worth a comment
explaining that.

             reply	other threads:[~2016-06-24  4:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24  4:36 Al Viro [this message]
2016-07-06 12:00 ` [RFC] weirdness in ext4_sync_file() Jan Kara

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=20160624043604.GU14480@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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.