Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern panic(9): Serialize panicstr access and printing `p...
details: https://anonhg.NetBSD.org/src/rev/9bc4d72211cb
branches: trunk
changeset: 365275:9bc4d72211cb
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Apr 17 09:09:13 2022 +0000
description:
panic(9): Serialize panicstr access and printing `panic:' message.
This isn't riskier than before -- previously we took kprintf_lock
inside each separate printf/vprintf call here. Now we just take it
once around access to panicstr and printing the message.
With any luck, this should help avoid interleaving panic messages
with each other and with other output -- and maybe cut down on the
number of syzkaller duplicates.
diffstat:
sys/kern/subr_prf.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diffs (51 lines):
diff -r fb425a59f788 -r 9bc4d72211cb sys/kern/subr_prf.c
--- a/sys/kern/subr_prf.c Sat Apr 16 23:20:47 2022 +0000
+++ b/sys/kern/subr_prf.c Sun Apr 17 09:09:13 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_prf.c,v 1.187 2022/03/16 20:31:02 andvar Exp $ */
+/* $NetBSD: subr_prf.c,v 1.188 2022/04/17 09:09:13 riastradh Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.187 2022/03/16 20:31:02 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.188 2022/04/17 09:09:13 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -96,6 +96,7 @@
*/
static void putchar(int, int, struct tty *);
+static void kprintf_internal(const char *, int, void *, char *, ...);
/*
@@ -261,18 +262,20 @@
if (logenabled(msgbufp))
panicstart = msgbufp->msg_bufx;
- printf("panic: ");
+ kprintf_lock();
+ kprintf_internal("panic: ", TOLOG|TOCONS, NULL, NULL);
if (panicstr == NULL) {
/* first time in panic - store fmt first for precaution */
panicstr = fmt;
vsnprintf(scratchstr, sizeof(scratchstr), fmt, ap);
- printf("%s", scratchstr);
+ kprintf_internal("%s", TOLOG|TOCONS, NULL, NULL, scratchstr);
panicstr = scratchstr;
} else {
- vprintf(fmt, ap);
+ kprintf(fmt, TOLOG|TOCONS, NULL, NULL, ap);
}
- printf("\n");
+ kprintf_internal("\n", TOLOG|TOCONS, NULL, NULL);
+ kprintf_unlock();
if (logenabled(msgbufp))
panicend = msgbufp->msg_bufx;
Home |
Main Index |
Thread Index |
Old Index