Skip to contentSkip to conversation

gfs2: avoid %pS in pr_err() fallback to prevent vsnprintf crash

PATCH In review Kriish Sharma 2 participants 2 messages Sep 16, 2025 – Sep 17, 2025 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: avoid %pS in pr_err() fallback to prevent vsnprintf crash

While debugging a syzbot report, I found that the %pS format in dump_holder() can trigger a crash when we end up in the pr_err() fallback path. This happens because %pS goes through symbol resolution inside vsnprintf, and in this case that isn’t always safe.

I switched the seq_file case to continue using %pS, since it is useful there, but changed the pr_err() path to use %p instead. This way we still print a valid pointer address without risking a kernel oops from within printk itself. The idea is to keep the debugging value but make it more robust.

Fixes 590b221ed425 ("Add linux-next specific files for 20250912")
Reported-by [email protected]
---
 fs/gfs2/glock.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
fs/gfs2/glock.c +12 -4
index b677c0e6b9ab..903844a6ebbc 100644
@@ -2284,10 +2284,18 @@ static void dump_holder(struct seq_file *seq, const struct gfs2_holder *gh,
 		if (gh_owner)
 			comm = gh_owner->comm;
 	}
-	gfs2_print_dbg(seq, "%s H: s:%s f:%s e:%d p:%ld [%s] %pS\n",
-		       fs_id_buf, state2str(gh->gh_state),
-		       hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags),
-		       gh->gh_error, (long)owner_pid, comm, (void *)gh->gh_ip);
+	if (seq) {
+		gfs2_print_dbg(seq, "%s H: s:%s f:%s e:%d p:%ld [%s] %pS\n",
+			fs_id_buf, state2str(gh->gh_state),
+			hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags),
+			gh->gh_error, (long)owner_pid, comm, (void *)gh->gh_ip);
+	} else {
+		gfs2_print_dbg(seq, "%s H: s:%s f:%s e:%d p:%ld [%s] %p\n",
+			fs_id_buf, state2str(gh->gh_state),
+			hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags),
+			gh->gh_error, (long)owner_pid, comm,
+			(void *)gh->gh_ip);
+	}
 	rcu_read_unlock();
 }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · Kriish Sharma

While debugging a syzbot report, I found that the %pS format in dump_holder() can trigger a crash when we end up in the pr_err() fallback path. This happens because %pS goes through symbol resolution inside vsnprintf, and in this case that isn’t always safe.

I'm unconvinced -- when and why is %pS not safe to use?

Thanks,
Andreas