All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] panic: fix va_list reuse in panic_try_force_cpu()
@ 2026-07-05 16:41 Bradley Morgan
  2026-07-05 19:10 ` Andrew Morton
  2026-07-07  9:18 ` Petr Mladek
  0 siblings, 2 replies; 4+ messages in thread
From: Bradley Morgan @ 2026-07-05 16:41 UTC (permalink / raw)
  To: Andrew Morton, Feng Tang
  Cc: Petr Mladek, Jinchao Wang, linux-kernel, Bradley Morgan

vsnprintf() consumes the caller's va_list. When the redirect fails,
vpanic() reuses it for the panic message, which is undefined
behavior. Use va_copy().

Signed-off-by: Bradley Morgan <include@grrlz.net>
---
 kernel/panic.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index f9ad0250da67..03f1eef07b17 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -412,7 +412,12 @@ static bool panic_try_force_cpu(const char *fmt, va_list args)
 	 * fall back to static message for early boot panics or allocation failure.
 	 */
 	if (panic_force_buf) {
-		vsnprintf(panic_force_buf, PANIC_MSG_BUFSZ, fmt, args);
+		va_list ap;
+
+		/* Do not consume args, the caller reuses it if we fail */
+		va_copy(ap, args);
+		vsnprintf(panic_force_buf, PANIC_MSG_BUFSZ, fmt, ap);
+		va_end(ap);
 		msg = panic_force_buf;
 	} else {
 		msg = "Redirected panic (buffer unavailable)";
-- 
2.53.0


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

end of thread, other threads:[~2026-07-07  9:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-05 16:41 [PATCH] panic: fix va_list reuse in panic_try_force_cpu() Bradley Morgan
2026-07-05 19:10 ` Andrew Morton
2026-07-07  9:28   ` Petr Mladek
2026-07-07  9:18 ` Petr Mladek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.