Skip to contentSkip to conversation

xfs_scrub: fix null pointer crash in scrub_render_ino_descr

PATCH In review Darrick J. Wong 3 participants 3 messages Nov 21, 2025 – Nov 24, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_scrub: fix null pointer crash in scrub_render_ino_descr

From: Darrick J. Wong <[email protected]>

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 <[email protected]> # v6.10.0
Fixes 9a8b09762f9a52 ("xfs_scrub: use parent pointers when possible to report file operations")
---
 scrub/common.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
scrub/common.c +7 -4
index a50c810a7bd5a1..49f13466d389c1 100644
@@ -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;
 }
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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 <[email protected]> # v6.10.0
Fixes 9a8b09762f9a52 ("xfs_scrub: use parent pointers when possible to report file operations")
---
 scrub/common.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
scrub/common.c +1 -2
index a50c810a7bd5a1..49f13466d389c1 100644
@@ -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);

scrub/common.c scrub_render_ino_descr( · line 516

Quoted 10 lines
scrub/common.c +6 -2
-	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;
 }

lgtm

Signature · 1 line
- Andrey