Re: [PATCH 1/3] fuse: reject embedded NULs in readdir entry names

From: Junyoung Jang

Date: Mon Nov 16 2026 - 06:32:09 EST


On Mon, Nov 16, 2026 at 7:25 PM Amir Goldstein <amir73il@xxxxxxxxx> wrote:
>
> On Sun, Nov 15, 2026 at 10:10 PM Junyoung Jang
> <graypanda.inzag@xxxxxxxxx> wrote:
> >
> > parse_dirfile() and parse_dirplusfile() reject '/' in dirent->name, but
> > do not check for embedded NUL bytes.
> >
> > Unlike plain getdents() buffers covered by verify_dirent_name() in
> > fs/readdir.c, FUSE READDIRPLUS passes dirent->namelen directly to
> > QSTR_INIT() in fuse_direntplus_link() and instantiates or aliases live
> > dentries via d_splice_alias(). A dirent name containing an embedded NUL
> > produces a dentry whose d_name.len extends past the NUL terminator,
> > which allows callers such as inotify to copy uninitialized kernel slab
> > memory past the NUL byte to userspace.
> >
> > Reject dirent names containing NUL alongside '/' in the FUSE readdir
> > parsers.
>
> My concern is that there are innocent buggy servers that pass NUL
> maybe even because of length including the terminating NUL.
>
> It would be more considerate to make this check in fuse_direntplus_link()
> rather than to fail the readdir.
>
> See precedent in:
> 78d04af4995a1 NFS: nfs_prime_dcache must validate the filename
>
> Also, verify_dirent_name() never checks for embedded NUL, so all the
> other filesystems can get away with this without failing readdir.
>
> Thanks,
> Amir.

Hi Amir,

That makes sense, breaking getdents() for FUSE servers that include a
trailing NUL in namelen is definitely a real risk.

In v2, I will drop the parser checks and instead have
fuse_direntplus_link() return 0 early when memchr(name.name, '\0',
name.len) is non-NULL, skipping dcache instantiation without failing
readdir (matching the nfs_prime_dcache() precedent).

Thanks,
Junyoung