debugfs: disallow NULL string creation and fix callers
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest3 patches 0 repliesNew
- v14 patches 5 repliesSuperseded
Changes in v2 from the cover letter
- Link to v1: https://lore.kernel.org/driver-core/[email protected]/
- 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/[email protected]/
[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/[email protected]/
[5] https://lore.kernel.org/driver-core/[email protected]/
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | debugfs: check for NULL pointer in debugfs_create_str()fs/ | +4 | 0 replies | |
| 2/3 | debugfs: fix placement of EXPORT_SYMBOL_GPL for debugfs_create_str()fs/ | +1 | 0 replies | |
| 3/3 | soundwire: debugfs: initialize firmware_file to empty stringdrivers/ | +7 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/3] debugfs: disallow NULL string creation and fix callers
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/[email protected]/
- 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/[email protected]/
[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/[email protected]/
[5] https://lore.kernel.org/driver-core/[email protected]/
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(-)
Signature · 1 line
2.43.0