mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 v2 0/3] fuse, fsnotify: handle embedded NUL names safely
Date: Tue, 17 Nov 2026 22:51:34 +0900	[thread overview]
Message-ID: <20261117135146.3174252-1-graypanda.inzag@gmail.com> (raw)

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@gmail.com/

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.

---
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

             reply	other threads:[~2026-11-17 13:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 13:51 Junyoung Jang [this message]
2026-11-17 13:51 ` [PATCH v2 1/3] fuse: skip dcache instantiation for readdirplus names with embedded NUL Junyoung Jang
2026-11-17 14:35   ` Amir Goldstein
2026-11-17 13:51 ` [PATCH v2 2/3] inotify: copy full qstr length for event names Junyoung Jang
2026-11-17 14:31   ` Amir Goldstein
2026-11-17 13:51 ` [PATCH v2 3/3] fanotify: copy full qstr length for copied " Junyoung Jang
2026-11-17 14:33   ` Amir Goldstein

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=20261117135146.3174252-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®