From: Gui-Dong Han <hanguidong02@gmail.com>
To: gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
vkoul@kernel.org, yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.dev
Cc: peterz@infradead.org, cristian.marussi@arm.com,
sudeep.holla@kernel.org, linux-sound@vger.kernel.org,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
akaieurus@gmail.com, me@ziyao.cc,
Gui-Dong Han <hanguidong02@gmail.com>
Subject: [PATCH v2 0/3] debugfs: disallow NULL string creation and fix callers
Date: Mon, 23 Mar 2026 16:58:43 +0800 [thread overview]
Message-ID: <20260323085930.88894-1-hanguidong02@gmail.com> (raw)
A recent bug report [1] highlighted a NULL pointer dereference when
reading a debugfs string file created with a NULL pointer. The community
discussed the issue and agreed that creating string nodes with NULL is
invalid and should be forbidden at creation time [2]. Since no fix was
submitted following the discussion, I have implemented the agreed
solution.
Patch 1 modifies debugfs_create_str() to reject NULL pointers, returning
early and triggering a WARN_ON to expose offending callers.
Patch 2 is a code hygiene fix. While modifying the file, I noticed the
EXPORT_SYMBOL_GPL for debugfs_create_str() was misplaced far away from
the function body. This patch moves it to the correct location.
I carefully audited existing callers across the kernel tree. Some
drivers passing NULL have already been independently identified and
fixed [3]. The remaining subsystem (soundwire) is addressed in patch 3
by initializing its string parameter to an empty string (""). The
existing code correctly and safely handles empty strings.
While auditing, I also noticed a devm_kstrdup/kfree mismatch in the
interconnect subsystem which has been addressed in a separate patch [4].
Changes in v2:
- Link to v1: https://lore.kernel.org/driver-core/20260317185920.43387-1-hanguidong02@gmail.com/
- Patch 1 & 2: No changes.
- Patch 3: Rewritten to use kstrdup() instead of devm_kstrdup() to match
debugfs's kfree() behavior. Moved initialization to sdw_debugfs_init()
to correctly handle the global pointer and avoid overwriting during
slave probe.
- Patch 4 (drm/i915): Dropped. Further analysis confirmed those specific
pointers are not passed to debugfs_create_str() [5].
[1] https://lore.kernel.org/lkml/17647e4c.d461.19b46144a4e.Coremail.yangshiguang1011@163.com/
[2] https://lore.kernel.org/lkml/2025122221-gag-malt-75ba@gregkh/
[3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8cc27f5c6dd1
[4] https://lore.kernel.org/linux-pm/20260318024815.7655-1-hanguidong02@gmail.com/
[5] https://lore.kernel.org/driver-core/8ac4b6ef2dfbc1dce0047dee55f2df609287a3ec@intel.com/
Gui-Dong Han (3):
debugfs: check for NULL pointer in debugfs_create_str()
debugfs: fix placement of EXPORT_SYMBOL_GPL for debugfs_create_str()
soundwire: debugfs: initialize firmware_file to empty string
drivers/soundwire/debugfs.c | 9 +++++++--
fs/debugfs/file.c | 7 +++++--
2 files changed, 12 insertions(+), 4 deletions(-)
--
2.43.0
next reply other threads:[~2026-03-23 9:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 8:58 Gui-Dong Han [this message]
2026-03-23 8:58 ` [PATCH v2 1/3] debugfs: check for NULL pointer in debugfs_create_str() Gui-Dong Han
2026-03-23 8:58 ` [PATCH v2 2/3] debugfs: fix placement of EXPORT_SYMBOL_GPL for debugfs_create_str() Gui-Dong Han
2026-03-23 8:58 ` [PATCH v2 3/3] soundwire: debugfs: initialize firmware_file to empty string Gui-Dong Han
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=20260323085930.88894-1-hanguidong02@gmail.com \
--to=hanguidong02@gmail.com \
--cc=akaieurus@gmail.com \
--cc=cristian.marussi@arm.com \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=me@ziyao.cc \
--cc=peterz@infradead.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=rafael@kernel.org \
--cc=sudeep.holla@kernel.org \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/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