[LTP] [PATCH] syscalls/fanotify26: Add cases that list the directory
Petr Vorel
pvorel@suse.cz
Tue Nov 3 20:44:09 CET 2026
Hi Edvard, Amir,
TL;DR: merged, thank you. Few notes below.
> On Tue, Nov 3, 2026 at 1:14 PM Edvard Conrad <edvard@tuta.io> wrote:
> > Listing a directory through the event file descriptor makes overlayfs
> > open its layers again, after the event fd exists: every layer of a
> > merged directory in ovl_dir_read_merged(), and the upper directory of
> > an impure one in ovl_dir_read_impure(). Unless those opens inherit
> > FMODE_NONOTIFY from the event fd, a listener that marks the backing
> > filesystem and lists the directory before it answers is sent a nested
> > permission event and blocks in getdents64().
> > Add a case for each. The impure directory is made by renaming a lower
> > file into a directory created on the overlay. The case reports TCONF
> > when the overlay cannot record the file's origin and so does not mark
"the overlay cannot record the file's origin": I'm just curious how this can
happen. Obviously it's not a mistake when you chose TCONF.
> > the directory impure. The impure listing is cached with the inode, so
> > the case moves the entry out and back first; otherwise a later
> > iteration would read the cache instead of the layer.
> > Both cases fail on a kernel without the pending overlayfs fix for
> > directory opens.
> > Signed-off-by: Edvard Conrad <edvard@tuta.io>
> > ---
> > Applies on top of "syscalls/fanotify26: Add directory cases for the
> > nested event":
> > https://lore.kernel.org/ltp/P5Iny41--F-9@tuta.io/
> > Asked for by Amir on the kernel thread, where both paths came up:
> > https://lore.kernel.org/all/CAOQ4uxh67+vs0mr-Lxmwz9-N+F8m29WUNz+8qFLLDpOVYB7=vg@mail.gmail.com/
+1
> > Tested in a VM on 6b4b543fa18, each kernel run once and with -i 2,
> > with the backing filesystem marked:
> > file dir merged dir impure dir
> > listed listed
> > no fix FAIL FAIL FAIL FAIL
> > + c3d355f427ce PASS FAIL FAIL FAIL
> > + ovl directory fix, v1 PASS PASS FAIL FAIL
> > + ovl directory fix, v2 PASS PASS PASS FAIL
> > + v2 and the follow-up on PASS PASS PASS PASS
> > the kernel thread
+1. So there will be 2 kernel fixing commits.
> > The overlay-only cases pass on all of them. Without the fix the impure
> > case fails in both iterations of -i 2, which is what moving the entry
> > out and back is for.
...
> > .../kernel/syscalls/fanotify/fanotify26.c | 92 ++++++++++++++++---
> > /*
> > * The listener either answers the event at once or is blocked for good, so
> > @@ -56,19 +74,41 @@
> > #define WAIT_MSEC 5000
> > static int fd_notify = -1;
> > +static int idir_is_impure;
> > static struct tcase {
> > const char *tname;
> > + const char *path;
> > int mark_backing;
> > int ondir;
> > + int list;
> > + int impure;
> > } tcases[] = {
> > - {"Overlay mark, file", 0, 0},
> > - {"Overlay and backing mark, file", 1, 0},
> > - {"Overlay mark, directory", 0, 1},
> > - {"Overlay and backing mark, directory", 1, 1},
> > + {"Overlay mark, file", OVL_FILE, 0, 0, 0, 0},
> > + {"Overlay and backing mark, file", OVL_FILE, 1, 0, 0, 0},
> > + {"Overlay mark, directory", OVL_DIR, 0, 1, 0, 0},
> > + {"Overlay and backing mark, directory", OVL_DIR, 1, 1, 0, 0},
> > + {"Overlay and backing mark, merged directory, listed",
> > + OVL_MDIR, 1, 1, 1, 0},
> > + {"Overlay and backing mark, impure directory, listed",
> > + OVL_IDIR, 1, 1, 1, 1},
> > };
nit: I usually prefer designated initializers instead of list of 0 or 1
(readability), but that's ok.
...
> Looks good!
> Only problem I got:
> tst_supported_fs_types.c:67: TINFO: mkfs.ext2 does exist
> tst_test.c:1305: TINFO: Formatting /dev/loop0 with ext2 opts='' extra opts=''
> mke2fs 1.47.2 (1-Jan-2025)
> [ 107.271105] operation not supported error, dev loop0, sector 614272
> op 0x9:(WRITE_ZEROES) flags 0x20800800 phys_seg 0 prio class 2
> tst_test.c:1317: TINFO: Mounting /dev/loop0 to
> /tmp/LTP_fanfH7dWr/mntpoint fstyp=ext2 flags=0
> [ 107.359391] ext2 filesystem being mounted at
> /tmp/LTP_fanfH7dWr/mntpoint supports timestamps until 2038-01-19
> (0x7fffffff)
> [ 107.367943] overlayfs: upper fs does not support RENAME_WHITEOUT.
> tst_test.c:1895: TINFO: Overall timeout per run is 0h 02m 00s
> fanotify26.c:232: TINFO: Umounting /tmp/LTP_fanfH7dWr/mntpoint/ovl
> [ 107.383261] overlayfs: upper fs does not support RENAME_WHITEOUT.
> fanotify26.c:246: TBROK: rename(mntpoint/ovl/moved_file,
> mntpoint/ovl/impure_dir/moved_file) failed: EINVAL (22)
> So I added to the test:
> --- a/testcases/kernel/syscalls/fanotify/fanotify26.c
> +++ b/testcases/kernel/syscalls/fanotify/fanotify26.c
> @@ -275,6 +275,11 @@ static struct tst_test test = {
> .mount_device = 1,
> .needs_overlay = 1,
> .mntpoint = OVL_BASE_MNTPOINT,
> + /* Test requires a base filesystem that supports RENAME_WHITEOUT */
> + .filesystems = (struct tst_fs[]) {
> + {.type = "ext4"},
> + {}
> + },
> };
+1, I added it before merge.
Kind regards,
Petr
More information about the ltp
mailing list