NetBSD Problem Report #56965

From www@netbsd.org  Thu Aug 11 12:33:19 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 575951A921F
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 11 Aug 2022 12:33:19 +0000 (UTC)
Message-Id: <20220811123317.8C73E1A9239@mollari.NetBSD.org>
Date: Thu, 11 Aug 2022 12:33:17 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: panic messages are sometimes garbled in syzkaller
X-Send-Pr-Version: www-1.0

>Number:         56965
>Category:       kern
>Synopsis:       panic messages are sometimes garbled in syzkaller
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 11 12:35:01 +0000 2022
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
La Fondation NètBSD
>Environment:
not sure
>Description:
Panic messages are sometimes garbled in syzkaller reports, such as this one:

[ 388.47pmap58845] panic: _get_physpage: out of memory

https://syzkaller.appspot.com/bug?id=5458c4ca59f15645a6a7a035a3399b7b1cb18714

Somehow part of the message `pmap_get_physpage: out of memory' has appeared in the middle of the dmesg timestamp, and _before_ the text `panic: ', even though the logic in subr_prf.c is serialized by a mutex and prints `panic: ' first:

    265 	kprintf_lock();
    266 	kprintf_internal("panic: ", TOLOG|TOCONS, NULL, NULL);
    267 	if (panicstr == NULL) {
    268 		/* first time in panic - store fmt first for precaution */
    269 		panicstr = fmt;
    270 
    271 		vsnprintf(scratchstr, sizeof(scratchstr), fmt, ap);
    272 		kprintf_internal("%s", TOLOG|TOCONS, NULL, NULL, scratchstr);
    273 		panicstr = scratchstr;
    274 	} else {
    275 		kprintf(fmt, TOLOG|TOCONS, NULL, NULL, ap);
    276 	}
    277 	kprintf_internal("\n", TOLOG|TOCONS, NULL, NULL);
    278 	kprintf_unlock();

https://nxr.netbsd.org/xref/src/sys/kern/subr_prf.c?r=1.188#265
>How-To-Repeat:
whatever syzbot does -- kernel config for example above:

include "arch/amd64/conf/GENERIC"

options		DEBUG
options		LOCKDEBUG

makeoptions	KMSAN=1
options		KMSAN
no options	SVS
no options	MODULAR
no options	MODULAR_DEFAULT_AUTOLOAD
options		POOL_NOCACHE
options		KMSAN_PANIC

makeoptions	KCOV=1
options		KCOV

options		FAULT

pseudo-device	vhci
usb*	at vhci?
>Fix:
Yes, please!

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.