Re: [PATCH] backing-file: inherit FMODE_NONOTIFY from the user file
From: Edvard Conrad
Date: Tue Oct 27 2026 - 04:32:23 EST
On Tue, Oct 27, 2026 at 12:53 AM Amir Goldstein <amir73il@xxxxxxxxx> 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