NetBSD Problem Report #60338
From www@netbsd.org Wed Jun 17 09:22:10 2026
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)
key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "mail.netbsd.org", Issuer "R13" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 7214F1A923A
for <gnats-bugs@gnats.NetBSD.org>; Wed, 17 Jun 2026 09:22:10 +0000 (UTC)
Message-Id: <20260617092209.5B6DA1A923B@mollari.NetBSD.org>
Date: Wed, 17 Jun 2026 09:22:09 +0000 (UTC)
From: msaitoh@execsw.org
Reply-To: msaitoh@execsw.org
To: gnats-bugs@NetBSD.org
Subject: The log priority after a newline in log(9) is forced to LOG_KERN | LOG_NOTICE
X-Send-Pr-Version: www-1.0
X-From4GNATS: "msaitoh@execsw.org via gnats" <gnats-admin@NetBSD.org>
>Number: 60338
>Category: bin
>Synopsis: The log priority after a newline in log(9) is forced to LOG_KERN | LOG_NOTICE
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jun 17 09:25:00 +0000 2026
>Last-Modified: Wed Jun 17 18:00:02 +0000 2026
>Originator: Masanobu SAITOH
>Release:
>Organization:
somewhere
>Environment:
-current
>Description:
When passing a multi-line string containing newline characters to log(9), all lines after the first are forced to use the priority LOG_KERN | LOG_NOTICE (DEFSPRI defined in usr.sbin/syslogd/syslogd.h).
This behavior is likely unintended.
>How-To-Repeat:
Diff for the test:
Index: init_sysctl.c
===================================================================
RCS file: /cvsroot/src/sys/kern/init_sysctl.c,v
retrieving revision 1.230
diff -u -p -r1.230 init_sysctl.c
--- init_sysctl.c 15 Feb 2026 21:47:18 -0000 1.230
+++ init_sysctl.c 17 Jun 2026 09:01:57 -0000
@@ -843,6 +843,7 @@ sysctl_kern_rtc_offset(SYSCTLFN_ARGS)
return (settime(l->l_proc, &ts));
}
+#include <sys/syslog.h>
/*
* sysctl helper routine for kern.maxproc. Ensures that the new
* values are not too low or too high.
@@ -857,6 +858,10 @@ sysctl_kern_maxproc(SYSCTLFN_ARGS)
node = *rnode;
node.sysctl_data = &nmaxproc;
error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ log(LOG_DEBUG, "maxproc0=%d\n", maxproc);
+ log(LOG_DEBUG, "maxproc1=%d\nmaxproc2=%d\n", maxproc, maxproc);
+ log(LOG_LOCAL0 | LOG_DEBUG, "maxproc3=%d\n", maxproc);
+ log(LOG_LOCAL0 | LOG_DEBUG, "maxproc4=%d\nmaxproc5=%d\n", maxproc, maxproc);
if (error || newp == NULL)
return (error);
Add following four lines into /etc/syslog.conf:
kern.debug /var/log/kern-debug
kern.notice /var/log/kern-notice
local0.debug /var/log/local0-debug
local0.notice /var/log/local0-notice
# cd /var/log
# rm -f kern-debug kern-notice local0-debug local0-notice
# touch kern-debug kern-notice local0-debug local0-notice
# /etc/rc.d/syslogd restart
Stopping syslogd.
Starting syslogd.
# sysctl kern.maxproc
kern.maxproc = 1044
# cat kern-debug
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc0=1044
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc1=1044
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc2=1044
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc5=1044 (changed to LOG_KERN)
# cat kern-notice
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc2=1044 (changed to LOG_KERN | LOG_NOTICE)
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc5=1044 (changed to LOG_KERN | LOG_NOTICE)
# cat local0-debug
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc3=1044
Jun 17 18:06:14 zen5 /netbsd: [ 2209.0403704] maxproc4=1044
zen5# cat local0-notice
#
>Fix:
Fix usr.sbin/syslogd/syslogd.c::printsys() or somewhere else.
>Audit-Trail:
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: bin/60338: The log priority after a newline in log(9) is forced to LOG_KERN | LOG_NOTICE
Date: Wed, 17 Jun 2026 17:56:22 -0000 (UTC)
gnats-admin@NetBSD.org ("msaitoh@execsw.org via gnats") writes:
>When passing a multi-line string containing newline characters to log(9), all lines after the first are forced to use the priority LOG_KERN | LOG_NOTICE (DEFSPRI defined in usr.sbin/syslogd/syslogd.h).
>This behavior is likely unintended.
It's how syslog works, which is a line based protocol.
Output to the log is prefixed with "<priority>" and syslogd parses the
message. If a line doesn't start with such a tag, it uses DEFSPRI for
kernel messages and DEFUPRI for userland messages.
You can surely teach log(9) to prepend each line with a priority tag,
but since log(9) is something like:
logpri(level)
kprintf(...)
you either need hooks in kprintf or some kind of expensive postprocessing.
In any case, this will generate multiple events, and then it might
be more obvious if you also have to call log(9) once for each event.
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.