NetBSD Problem Report #60880
From martin@duskware.de Thu Oct 15 11:52:32 2026
Return-Path: <martin@duskware.de>
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 08D321A923B
for <gnats-bugs@gnats.NetBSD.org>; Thu, 15 Oct 2026 11:52:31 +0000 (UTC)
Message-Id: <20261015115227.5ADD2E1FFDF@mail.duskware.de>
Date: Thu, 15 Oct 2026 13:52:22 +0200 (CEST)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: compat_netbsd32 does not deal properly with timeval args to setsockopt()
X-Send-Pr-Version: 3.95
X-From4GNATS: "martin@NetBSD.org via gnats" <gnats-admin@NetBSD.org>
>Number: 60880
>Category: kern
>Synopsis: compat_netbsd32 does not deal properly with timeval args to setsockopt()
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 15 11:55:00 +0000 2026
>Last-Modified: Thu Oct 15 12:00:04 +0000 2026
>Originator: Martin Husemann
>Release: NetBSD 11.99.9
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD seven-days-to-the-wolves.aprisoft.de 11.99.9 NetBSD 11.99.9 (GENERIC) #904: Thu Oct 15 09:52:21 CEST 2026 martin@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
Running 32bit ATF tests on a 64bit kernel leads to failure in
/usr/tests/usr.sbin/inetd/t_inetd in the test_ratelimit test case.
It calls:
CHECK_ERROR(setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout,
sizeof(timeout)));
and that is handled in netbsd32_setsockopt() by translating all arguments
and then blindly forwarding to the native setsockopt:
return sys_setsockopt(l, &ua, retval);
which in this case (I guess) ends up in
sockopt_get() being called from sosetop1()
with &tv and sizeof(tv).
sockopt_get verifies the valsize (32bit sizeof(struct timeval)) against
native sizeof(struct timeval) and fails the call with EINVAL.
>How-To-Repeat:
cd /usr/tests/usr.sbin/inetd && ./t_inetd test_ratelimit
>Fix:
yes please
>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/60880: compat_netbsd32 does not deal properly with timeval
args to setsockopt()
Date: Thu, 15 Oct 2026 13:57:38 +0200
Special treatment is needed for SO_SNDTIMEO and SO_RECVTIMEO for
struct timeval.
Another case is SO_LINGER and struct linger - which *might* be the same
for all 32bit and 64bit architectures we currently have that support
compat_netbsd32, by plain luck.
Martin
(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.