NetBSD Problem Report #59345
From www@netbsd.org Wed Apr 23 11:30:07 2025
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 "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id DC0E31A923E
for <gnats-bugs@gnats.NetBSD.org>; Wed, 23 Apr 2025 11:30:07 +0000 (UTC)
Message-Id: <20250423113006.7596A1A923F@mollari.NetBSD.org>
Date: Wed, 23 Apr 2025 11:30:06 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: kdump fails to dump signal info under compat32
X-Send-Pr-Version: www-1.0
>Number: 59345
>Category: kern
>Synopsis: kdump fails to dump signal info under compat32
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Apr 23 11:35:00 +0000 2025
>Last-Modified: Wed Apr 23 11:42:45 +0000 2025
>Originator: Taylor R Campbell
>Release: current
>Organization:
The Ktr_psig32/64 Foundation
>Environment:
>Description:
Under compat32, ktrace a process that receives signals, and when you kdump it, you'll find the occasional:
kdump: Unhandled size 168 for ktrpsig
This happens because, e.g., on mips, the size of
struct {
struct ktr_psig kp;
siginfo_t si;
};
is 160 on n32, but 168 on n64, so it's not compatible.
In particular, sizeof(sig_t) and _Alignof(sig_t) are both 4 on n32, but both 8 on n64. So sizeof(struct ktr_psig) is 28 and _Alignof(struct ktr_psig) is 4 on n32, but they are 40 and 8, respectively, on n64.
>How-To-Repeat:
# cat sig.c
#include <err.h>
#include <signal.h>
static void
onsig(int signo)
{
}
int
main(void)
{
if (signal(SIGUSR1, &onsig) == SIG_ERR)
err(1, "signal");
raise(SIGUSR1);
return 0;
}
# kdump | grep -A1 -i psig
kdump: Unhandled size 168 for ktrpsig
223 223 sig PSIG SIGUSR1 SIG_DFL 223 223 sig CALL netbsd32_setcontext(0x7fff77c8)
223 223 sig RET netbsd32_setcontext JUSTRETURN
Expected output to look more like:
10263 10263 sig PSIG SIGUSR1 caught handler=0x8048917 mask=(): code=SI_LWP sent by pid=10263, uid=1000)
10263 10263 sig CALL netbsd32_setcontext(0xfffd2a34)
>Fix:
Teach ktrace(2) to produce records of the correct size under compat32.o
The logic to do this is sitting around under #ifdef notyet:
https://nxr.netbsd.org/xref/src/sys/compat/netbsd32/netbsd32_signal.c?r=1.55#650
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: port-mips-maintainer->kern-bug-people
Responsible-Changed-By: riastradh@NetBSD.org
Responsible-Changed-When: Wed, 23 Apr 2025 11:42:45 +0000
Responsible-Changed-Why:
Turns out this is a general compat32 issue, not a mips n32/n64 issue,
so I edited the PR to be more generic.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.