NetBSD Problem Report #60997
From www@netbsd.org Fri Nov 13 06:28:01 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 "YR1" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 914FE1A923B
for <gnats-bugs@gnats.NetBSD.org>; Fri, 13 Nov 2026 06:28:01 +0000 (UTC)
Message-Id: <20261113062800.4895F1A923C@mollari.NetBSD.org>
Date: Fri, 13 Nov 2026 06:28:00 +0000 (UTC)
From: koorogi@koorogi.info
Reply-To: koorogi@koorogi.info
To: gnats-bugs@NetBSD.org
Subject: sigqueue accepts zero and negative "pids", contrary to POSIX and manpage
X-Send-Pr-Version: www-1.0
X-From4GNATS: "koorogi@koorogi.info via gnats" <gnats-admin@NetBSD.org>
>Number: 60997
>Category: standards
>Synopsis: sigqueue accepts zero and negative "pids", contrary to POSIX and manpage
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: standards-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Nov 13 06:30:01 +0000 2026
>Originator: Bobby Bingham
>Release: NetBSD-current 20261111155711
>Organization:
>Environment:
NetBSD netbsdvm.local 11.99.11 NetBSD 11.99.11 (GENERIC) #0: Wed Nov 11 15:57:11 UTC 2026 mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
sys_sigqueueinfo calls kill1, which is also used by sys_kill and handles the signal broadcasts specified for pid<=0 in that system call.
However, sigqueue is not specified to support broadcasts, and is required to fail for a pid that does not exist:
>From https://pubs.opengroup.org/onlinepubs/9799919799/functions/sigqueue.html
The sigqueue() function shall fail if:
...
[ESRCH]
The process pid does not exist.
This also does not appear to be a documented extension. It is not mentioned in the manpage, which in fact says:
The sigqueue() system call queues a signal to a single process specified by the pid argument
>How-To-Repeat:
Apply this patch to the tests and run them.
diff --git a/tests/lib/libc/sys/t_sigqueue.c b/tests/lib/libc/sys/t_sigqueue.c
index 317ee591162a..9fefba0f7d1a 100644
--- a/tests/lib/libc/sys/t_sigqueue.c
+++ b/tests/lib/libc/sys/t_sigqueue.c
@@ -73,7 +73,7 @@ ATF_TC_BODY(sigqueue_basic, tc)
sv.sival_int = VALUE;
- if (sigqueue(0, SIGUSR1, sv) != 0)
+ if (sigqueue(getpid(), SIGUSR1, sv) != 0)
atf_tc_fail("sigqueue failed");
sched_yield();
@@ -92,6 +92,8 @@ ATF_TC_BODY(sigqueue_err, tc)
errno = 0;
ATF_REQUIRE_ERRNO(EINVAL, sigqueue(getpid(), -1, sv) == -1);
+ errno = 0;
+ ATF_REQUIRE_ERRNO(ESRCH, sigqueue(0, SIGINFO, sv) == -1);
}
static int signals[] = {
>Fix:
diff --git a/sys/kern/sys_sig.c b/sys/kern/sys_sig.c
index 211ccc8587c7..dbed5c8191bf 100644
--- a/sys/kern/sys_sig.c
+++ b/sys/kern/sys_sig.c
@@ -285,9 +285,10 @@ sys_sigqueueinfo(struct lwp *l, const struct sys_sigqueueinfo_args *uap,
register_t *retval)
{
/* {
- syscallarg(pid_t int) pid;
+ syscallarg(pid_t) pid;
syscallarg(const siginfo_t *) info;
} */
+ pid_t pid;
ksiginfo_t ksi;
int error;
@@ -297,7 +298,10 @@ sys_sigqueueinfo(struct lwp *l, const struct sys_sigqueueinfo_args *uap,
sizeof(ksi.ksi_info))) != 0)
return error;
- return kill1(l, SCARG(uap, pid), &ksi, retval);
+ if ((pid = SCARG(uap, pid)) <= 0)
+ return ESRCH;
+
+ return kill1(l, pid, &ksi, retval);
}
int
(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.