linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Matthew Bobrowski <repnop@google.com>,
	Ivan Delalande <colona@arista.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] fsnotify: invalidate dcache before IN_DELETE event
Date: Fri, 28 Jan 2022 17:18:02 +0200	[thread overview]
Message-ID: <CAOQ4uxhwbLvjnpuj=fiszS2_cGu-5tCFJ0Hdv7Xdw4sq09kmaA@mail.gmail.com> (raw)
In-Reply-To: <20220124135023.quzjsqtsrxynffrs@quack3.lan>

On Mon, Jan 24, 2022 at 3:50 PM Jan Kara <jack@suse.cz> wrote:
>
> On Thu 20-01-22 23:53:04, Amir Goldstein wrote:
> > Apparently, there are some applications that use IN_DELETE event as an
> > invalidation mechanism and expect that if they try to open a file with
> > the name reported with the delete event, that it should not contain the
> > content of the deleted file.
> >
> > Commit 49246466a989 ("fsnotify: move fsnotify_nameremove() hook out of
> > d_delete()") moved the fsnotify delete hook before d_delete() so fsnotify
> > will have access to a positive dentry.
> >
> > This allowed a race where opening the deleted file via cached dentry
> > is now possible after receiving the IN_DELETE event.
> >
> > To fix the regression, create a new hook fsnotify_delete() that takes
> > the unlinked inode as an argument and use a helper d_delete_notify() to
> > pin the inode, so we can pass it to fsnotify_delete() after d_delete().
> >
> > Backporting hint: this regression is from v5.3. Although patch will
> > apply with only trivial conflicts to v5.4 and v5.10, it won't build,
> > because fsnotify_delete() implementation is different in each of those
> > versions (see fsnotify_link()).
> >
> > A follow up patch will fix the fsnotify_unlink/rmdir() calls in pseudo
> > filesystem that do not need to call d_delete().
> >
> > Reported-by: Ivan Delalande <colona@arista.com>
> > Link: https://lore.kernel.org/linux-fsdevel/YeNyzoDM5hP5LtGW@visor/
> > Fixes: 49246466a989 ("fsnotify: move fsnotify_nameremove() hook out of d_delete()")
> > Cc: stable@vger.kernel.org # v5.3+
> > Signed-off-by: Amir Goldstein <amir73il@gmail.com>
>
> Thanks. Both patches look good to me now, I've merged them into my tree and
> will push them to Linus later this week.

LTP test:
https://github.com/amir73il/ltp/commits/in_delete

I'll post it later.

Thanks,
Amir.

      reply	other threads:[~2022-01-28 15:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 21:53 [PATCH v2 1/2] fsnotify: invalidate dcache before IN_DELETE event Amir Goldstein
2022-01-20 21:53 ` [PATCH v2 2/2] fsnotify: fix fsnotify hooks in pseudo filesystems Amir Goldstein
2022-01-24 13:50 ` [PATCH v2 1/2] fsnotify: invalidate dcache before IN_DELETE event Jan Kara
2022-01-28 15:18   ` Amir Goldstein [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='CAOQ4uxhwbLvjnpuj=fiszS2_cGu-5tCFJ0Hdv7Xdw4sq09kmaA@mail.gmail.com' \
    --to=amir73il@gmail.com \
    --cc=colona@arista.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=repnop@google.com \
    --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;
as well as URLs for NNTP newsgroup(s).