All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edvard Conrad <edvard@tuta.io>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Edvard Conrad <edvard@tuta.io>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] backing-file: inherit FMODE_NONOTIFY from the user file
Date: Tue, 27 Oct 2026 09:31:55 +0100 (CET)	[thread overview]
Message-ID: <P4wUBaI--F-9@tuta.io> (raw)

On Tue, Oct 27, 2026 at 12:53 AM Amir Goldstein <amir73il@gmail.com> wrote:
> Any chance you can post this as an LTP test?

Yes. Written and verified, I will post it to the LTP list shortly as
syscalls/fanotify26. Two cases: a mark on the overlay only, which passes
on every kernel and keeps the test from passing for the wrong reason,
and a mark on the overlay plus the backing filesystem, which is the
shape that deadlocks.

> Urgh I hate how special case this is.
>
> How about something like below (untested)

Agreed on the shape, and it covers backing_tmpfile_open() as well, which
mine did not. As posted it does not fix the deadlock though:

> -       f->f_mode       = OPEN_FMODE(flags);
> +       f->f_mode       = OPEN_FMODE(flags) | fmode;

Five lines further down init_file() calls

	file_set_fsnotify_mode(f, FMODE_NONOTIFY_PERM);

and that helper clears FMODE_FSNOTIFY_MASK before it sets its argument,
so the inherited FMODE_NONOTIFY is dropped again. The backing file ends
up at FMODE_NONOTIFY_PERM, which is not FMODE_FSNOTIFY_NONE(), so
fsnotify_open_perm_and_set_mode() does not take its early return and
still raises FS_OPEN_PERM on the real path.

Measured in a VM on a defconfig + OVERLAY_FS + FANOTIFY +
FANOTIFY_ACCESS_PERMISSIONS build of this tree, with the reproducer from
the patch and with the LTP test:

  kernel                        reproducer    fanotify26
  mainline                      hangs         1 pass 1 fail
  v1 (fs/backing-file.c)        ok            2 pass
  your diff as posted           hangs         1 pass 1 fail
  v2                            ok            2 pass

v2 keeps your structure and routes the fsnotify part through
file_set_fsnotify_mode() instead:

	fmode_t fsnotify_mode = fmode & FMODE_FSNOTIFY_MASK;
	...
	f->f_mode	= OPEN_FMODE(flags) | fmode;
	file_set_fsnotify_mode(f, fsnotify_mode ? fsnotify_mode :
						  FMODE_NONOTIFY_PERM);

One deliberate difference from your version: it inherits only the "no
events at all" mode rather than masking FMODE_NONOTIFY out of whatever
the user file carries. A user file in the HSM mode (FMODE_NONOTIFY |
FMODE_NONOTIFY_PERM) would otherwise leave its backing file fully
silent, suppressing the events on real files that bc2473c90fca
deliberately enabled.

v2 follows in this thread.

Thanks,
Edvard

             reply	other threads:[~2026-10-27  8:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  8:31 Edvard Conrad [this message]
2026-10-28 15:48 ` [PATCH] backing-file: inherit FMODE_NONOTIFY from the user file Amir Goldstein
  -- strict thread matches above, loose matches on Subject: below --
2026-10-26 15:11 Edvard Conrad
2026-10-26 22:53 ` Amir Goldstein

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=P4wUBaI--F-9@tuta.io \
    --to=edvard@tuta.io \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=stable@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.