public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_scrub: fix null pointer crash in scrub_render_ino_descr
@ 2025-11-21 16:39 Darrick J. Wong
  2025-11-24  9:28 ` Andrey Albershteyn
  2025-11-24  9:35 ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Darrick J. Wong @ 2025-11-21 16:39 UTC (permalink / raw)
  To: Andrey Albershteyn; +Cc: xfs

From: Darrick J. Wong <djwong@kernel.org>

Starting in Debian 13's libc6, passing a NULL format string to vsnprintf
causes the program to segfault.  Prior to this, the null format string
would be ignored.  Because @format is optional, let's explicitly steer
around the vsnprintf if there is no format string.  Also tidy whitespace
in the comment.

Found by generic/45[34] on Debian 13.

Cc: <linux-xfs@vger.kernel.org> # v6.10.0
Fixes: 9a8b09762f9a52 ("xfs_scrub: use parent pointers when possible to report file operations")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 scrub/common.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/scrub/common.c b/scrub/common.c
index a50c810a7bd5a1..49f13466d389c1 100644
--- a/scrub/common.c
+++ b/scrub/common.c
@@ -404,7 +404,7 @@ within_range(
 /*
  * Render an inode number into a buffer in a format suitable for use in
  * log messages. The buffer will be filled with:
- * 	"inode <inode number> (<ag number>/<ag inode number>)"
+ *	"inode <inode number> (<ag number>/<ag inode number>)"
  * If the @format argument is non-NULL, it will be rendered into the buffer
  * after the inode representation and a single space.
  */
@@ -506,8 +506,11 @@ scrub_render_ino_descr(
 	pathlen = ret;
 
 report_format:
-	va_start(args, format);
-	pathlen += vsnprintf(buf + pathlen, buflen - pathlen, format, args);
-	va_end(args);
+	if (format) {
+		va_start(args, format);
+		pathlen += vsnprintf(buf + pathlen, buflen - pathlen, format,
+				args);
+		va_end(args);
+	}
 	return pathlen;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-24  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 16:39 [PATCH] xfs_scrub: fix null pointer crash in scrub_render_ino_descr Darrick J. Wong
2025-11-24  9:28 ` Andrey Albershteyn
2025-11-24  9:35 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox