Re: [PATCH v2 0/3] fuse, fsnotify: handle embedded NUL names safely

From: Jan Kara

Date: Wed Nov 18 2026 - 07:55:39 EST


On Tue 17-11-26 22:51:34, Junyoung Jang wrote:
> FUSE READDIRPLUS can instantiate a dentry whose length-bearing name
> contains an embedded NUL. The fsnotify name-copy paths then stop at
> that NUL while retaining the original qstr length, allowing event-name
> buffers to expose uninitialized bytes.
>
> Patch 1 skips dcache instantiation for these READDIRPLUS entries while
> preserving getdents() behavior. Patches 2 and 3 copy the full qstr name
> into inotify and fanotify events. Each patch applies independently to
> the base commit.
>
> Link: https://lore.kernel.org/linux-fsdevel/20261115210952.2140036-1-graypanda.inzag@xxxxxxxxx/
>
> A custom LLM agent assisted with initial discovery and reproducer
> setup; all root-cause analysis, patches, and runtime tests were
> manually reviewed and verified by the authors.

Thanks, I've added patches 2 & 3 to my tree. Patch 1 is for Miklos so I've
left it alone.

Honza

>
> ---
> Changes in v2:
> - Follow Amir Goldstein's review: preserve FUSE readdir output and skip
> dcache instantiation only for invalid READDIRPLUS names.
> - Replace the event-name strscpy_pad() calls with length-based memcpy()
> and explicit terminators in inotify and fanotify.
>
> Tests on 23c62304dde2 in QEMU:
> - Patch 1 alone: READDIR and READDIRPLUS getdents64() returned normally;
> the embedded-NUL entry was not instantiated, and FUSE_FORGET returned
> its unused lookup reference.
> - Patch 2 alone: the FUSE READDIRPLUS/inotify reproducer returned the
> original qstr bytes after the NUL, with no stale slab bytes detected.
> - Patch 3 alone: tmpfs FAN_REPORT_DFID_NAME creation and FAN_RENAME
> reported the expected names, NUL terminators, and zeroed alignment.
> - All three together: the above FUSE and tmpfs regression probes passed.
>
> Junyoung Jang (3):
> fuse: skip dcache instantiation for readdirplus names with embedded
> NUL
> inotify: copy full qstr length for event names
> fanotify: copy full qstr length for copied event names
>
> fs/fuse/readdir.c | 2 ++
> fs/notify/fanotify/fanotify.h | 12 ++++++++++--
> fs/notify/inotify/inotify_fsnotify.c | 6 ++++--
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
>
> base-commit: 23c62304dde29abe92013d85910d03a77dada35d
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR