From: Junyoung Jang <graypanda.inzag@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>, Jan Kara <jack@suse.cz>
Cc: Junyoung Jang <graypanda.inzag@gmail.com>,
Amir Goldstein <amir73il@gmail.com>,
Matt Bobrowski <matt@bobrowski.net>,
Gwanhyun Lee <gwanhyunlee@gmail.com>,
fuse-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 0/3] fuse, fsnotify: handle embedded NUL names safely
Date: Mon, 16 Nov 2026 06:09:47 +0900 [thread overview]
Message-ID: <20261115210952.2140036-1-graypanda.inzag@gmail.com> (raw)
FUSE readdir and readdirplus parse dirent->namelen without checking for
embedded NUL bytes. Through READDIRPLUS (fuse_direntplus_link()), such a
name can instantiate or alias a dentry in dcache whose qstr length
extends past the first NUL.
When fsnotify records that dentry name, both inotify and fanotify size
the event buffer from qstr->len and copy that full length to userspace,
but populate the buffer with strscpy(). Because strscpy() stops at the
embedded NUL, the trailing heap bytes remain uninitialized.
Patch 1 rejects dirent names containing embedded NULs in FUSE.
Patch 2 zero-pads inotify event names through their recorded length.
Patch 3 zero-pads fanotify event names through their recorded lengths.
Each patch applies and builds independently on mainline commit
23c62304dde2, so the FUSE and fsnotify changes can go through their
respective trees separately.
Testing on x86_64 QEMU:
- 1/3: Crafted FUSE READDIR and READDIRPLUS entries with embedded NUL
names were accepted before the patch and rejected with -EIO
afterward.
- 2/3: With Patch 1 omitted, FUSE READDIRPLUS + inotify leaked stale
slab bytes past the embedded NUL to userspace before the patch,
and returned zeroes afterward.
- 3/3: Default FUSE mounts report a zero fsid, so fanotify_mark() with
FAN_REPORT_DFID_NAME returns -ENODEV on the FUSE setup;
regression-tested FAN_REPORT_DFID_NAME create and FAN_RENAME
events on tmpfs.
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.
Junyoung Jang (3):
fuse: reject embedded NULs in readdir entry names
inotify: zero-pad event names after an embedded NUL
fanotify: zero-pad copied event names after an embedded NUL
fs/fuse/readdir.c | 12 +++++++++---
fs/notify/fanotify/fanotify.h | 4 ++--
fs/notify/inotify/inotify_fsnotify.c | 2 +-
3 files changed, 12 insertions(+), 6 deletions(-)
next reply other threads:[~2026-11-15 21:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 21:09 Junyoung Jang [this message]
2026-11-15 21:09 ` [PATCH 1/3] fuse: reject embedded NULs in readdir entry names Junyoung Jang
2026-11-15 21:09 ` [PATCH 2/3] inotify: zero-pad event names after an embedded NUL Junyoung Jang
2026-11-15 21:09 ` [PATCH 3/3] fanotify: zero-pad copied " Junyoung Jang
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=20261115210952.2140036-1-graypanda.inzag@gmail.com \
--to=graypanda.inzag@gmail.com \
--cc=amir73il@gmail.com \
--cc=fuse-devel@lists.linux.dev \
--cc=gwanhyunlee@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@bobrowski.net \
--cc=miklos@szeredi.hu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®