NetBSD Problem Report #56318

From tsutsui@ceres.dti.ne.jp  Mon Jul 19 15:03:16 2021
Return-Path: <tsutsui@ceres.dti.ne.jp>
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 341B41A921F
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 19 Jul 2021 15:03:16 +0000 (UTC)
Message-Id: <202107191503.16JF36jm015067@ceres.dti.ne.jp>
Date: Tue, 20 Jul 2021 00:03:06 +0900 (JST)
From: Izumi Tsutsu <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: sshd fails to start on NetBSD/pmax 9.2 R3000 3MIN
X-Send-Pr-Version: 3.95

>Number:         56318
>Category:       lib
>Synopsis:       sshd fails to start on NetBSD/pmax 9.2 R3000 3MIN
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 19 15:05:00 +0000 2021
>Closed-Date:    Sun Aug 15 16:50:13 +0000 2021
>Last-Modified:  Sun Aug 15 16:50:13 +0000 2021
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.2
>Organization:
>Environment:
System: NetBSD proudia 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/pmax/compile/GENERIC pmax
Architecture: mipsel
Machine: pmax
>Description:
/etc/rc.d/sshd (actually /usr/bin/ssh-keygen and /usr/sbin/sshd) fails
to start on NetBSD/pmax 9.2:

---
# uname -a
NetBSD proudia 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/pmax/compile/GENERIC pmax
# sysctl hw.model
hw.model = DECstation 5000/125 (3MIN)
# /etc/rc.d/sshd start
assertion "(*wnumtop) == 0" failed: file "/usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_div.c", line 439, function "bn_div_fixed_top"
[1]   Abort trap (core dumped) "${keygen}" -t "${type}" ${bitarg} -f "${f}" -...
Starting sshd.
assertion "(*wnumtop) == 0" failed: file "/usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_div.c", line 439, function "bn_div_fixed_top"
[1]   Abort trap (core dumped) RC_PID= _rc_pid= _rc_original_stdout_fd= _rc_o...
# gdb /usr/bin/ssh-keygen ssh-keygen.core 
gdb: Undefined symbol "__clz_tab" (symnum = 3221)
# gdb /usr/sbin/sshd sshd.core 
gdb: Undefined symbol "__clz_tab" (symnum = 3221)
# file /usr/bin/ssh-keygen 
/usr/bin/ssh-keygen: ELF 32-bit LSB pie executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked, interpreter /usr/libexec/ld.elf_so, for NetBSD 9.2, not stripped
# file /usr/sbin/sshd
/usr/sbin/sshd: ELF 32-bit LSB pie executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked, interpreter /usr/libexec/ld.elf_so, for NetBSD 9.2, not stripped
#
---

Full dmesg is here:
 https://dmesgd.nycbug.org/index.cgi?do=view&id=6179

>How-To-Repeat:
Install NetBSD/pmax 9.2 (on MIPS1?) and start /etc/rc.d/sshd.

>Fix:
Not sure.

---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: lib/56318: sshd fails to start on NetBSD/pmax 9.2 R3000 3MIN
Date: Tue, 20 Jul 2021 00:34:17 +0900

 > # gdb /usr/bin/ssh-keygen ssh-keygen.core 
 > gdb: Undefined symbol "__clz_tab" (symnum = 3221)

 Ah, this was caused by an old gdb binary (comp.tgz was not updated).
 The updated gdb doesn't provide useful info though.
 ---

 # file /usr/bin/gdb
 /usr/bin/gdb: ELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked, interpreter /usr/libexec/ld.elf_so, for NetBSD 5.99.48, not stripped
 # tar -C / -zxpvf comp.tgz ./usr/bin/gdb
 x ./usr/bin/gdb
 # gdb /usr/bin/ssh-keygen ssh-keygen.core
 GNU gdb (GDB) 8.3
 Copyright (C) 2019 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
 Type "show copying" and "show warranty" for details.
 This GDB was configured as "mipsel--netbsd".
 Type "show configuration" for configuration details.
 For bug reporting instructions, please see:
 <http://www.gnu.org/software/gdb/bugs/>.
 Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.

 For help, type "help".
 Type "apropos word" to search for commands related to "word"...
 Reading symbols from /usr/bin/ssh-keygen...
 (No debugging symbols found in /usr/bin/ssh-keygen)
 [New process 1]
 Core was generated by `ssh-keygen'.
 Program terminated with signal SIGABRT, Aborted.
 #0  0x7d798214 in ?? ()
 warning: ../../../../gdbscripts/bdump: No such file or directory
 warning: ../../../../gdbscripts/cpus: No such file or directory
 warning: ../../../../gdbscripts/kdump: No such file or directory
 warning: ../../../../gdbscripts/lwps: No such file or directory
 warning: ../../../../gdbscripts/msgbuf: No such file or directory
 warning: ../../../../gdbscripts/pgrpdump: No such file or directory
 warning: ../../../../gdbscripts/procs: No such file or directory
 warning: ../../../../gdbscripts/vchain: No such file or directory
 warning: ../../../../gdbscripts/vdump: No such file or directory
 (gdb) bt
 #0  0x7d798214 in ?? ()
 Backtrace stopped: previous frame identical to this frame (corrupt stack?)
 (gdb) 

 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: lib/56318: sshd fails to start on NetBSD/pmax 9.2 R3000 3MIN
Date: Tue, 10 Aug 2021 02:25:35 +0900

 This also happens on SPARC station 2 (sun4c) + NetBSD/sparc 9.2:

 ---
 ss2-% ssh-keygen
 Generating public/private rsa key pair.
 assertion "(*wnumtop) == 0" failed: file "/usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_div.c", line 439, function "bn_div_fixed_top"
 Abort (core dumped)
 ss2-% gdb /usr/bin/ssh-keygen ssh-keygen.core
 GNU gdb (GDB) 8.3
 Copyright (C) 2019 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
 Type "show copying" and "show warranty" for details.
 This GDB was configured as "sparc--netbsdelf".
 Type "show configuration" for configuration details.
 For bug reporting instructions, please see:
 <http://www.gnu.org/software/gdb/bugs/>.
 Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.

 For help, type "help".
 Type "apropos word" to search for commands related to "word"...

 warning: ../../../../gdbscripts/bdump: No such file or directory

 warning: ../../../../gdbscripts/cpus: No such file or directory

 warning: ../../../../gdbscripts/kdump: No such file or directory

 warning: ../../../../gdbscripts/lwps: No such file or directory

 warning: ../../../../gdbscripts/msgbuf: No such file or directory

 warning: ../../../../gdbscripts/pgrpdump: No such file or directory

 warning: ../../../../gdbscripts/procs: No such file or directory

 warning: ../../../../gdbscripts/vchain: No such file or directory

 warning: ../../../../gdbscripts/vdump: No such file or directory
 Reading symbols from /usr/bin/ssh-keygen...
 Reading symbols from /usr/libdata/debug//usr/bin/ssh-keygen.debug...
 [New process 1]
 Core was generated by `ssh-keygen'.
 Program terminated with signal SIGABRT, Aborted.
 #0  abort () at /usr/src/lib/libc/stdlib/abort.c:80
 80              (void)signal(SIGABRT, SIG_DFL);
 (gdb) bt
 #0  abort () at /usr/src/lib/libc/stdlib/abort.c:80
 #1  0xeda19fc8 in __assert13 (
     file=0xedda9630 "/usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_div.c", line=line@entry=439, function=<optimized out>,
     failedexpr=0xedda9670 "(*wnumtop) == 0")
     at /usr/src/lib/libc/gen/assert.c:72
 #2  0xedd466e0 in bn_div_fixed_top (dv=dv@entry=0x0, rm=rm@entry=0xed8c820c,
     num=num@entry=0xefffe69c, divisor=divisor@entry=0xed8c81f8,
     ctx=ctx@entry=0xedeb6150)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_div.c:439
 #3  0xedd46744 in BN_div (dv=dv@entry=0x0, rm=rm@entry=0xed8c820c,
     num=num@entry=0xefffe69c, divisor=divisor@entry=0xed8c81f8,
     ctx=ctx@entry=0xedeb6150)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_div.c:229
 #4  0xedd45a08 in BN_nnmod (r=r@entry=0xed8c820c, m=m@entry=0xefffe69c,
     d=d@entry=0xed8c81f8, ctx=ctx@entry=0xedeb6150)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_mod.c:20
 #5  0xedd44d28 in bn_mod_inverse_no_branch (pnoinv=0xefffe714, ctx=0xedeb6150,
     n=0xefffe784, a=<optimized out>, in=0xed8c81e4)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_gcd.c:67
 #6  int_bn_mod_inverse (in=0xed8c81e4, a=<optimized out>, n=0xefffe784,
     ctx=0xedeb6150, pnoinv=0xefffe714)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_gcd.c:214
 #7  0xedd45630 in BN_mod_inverse (in=in@entry=0xed8c81e4,
     a=a@entry=0xedb46144, n=n@entry=0xefffe784, ctx=ctx@entry=0xedeb6150)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_gcd.c:528
 #8  0xedd44a80 in BN_MONT_CTX_set (mont=mont@entry=0xedb46140,
     mod=mod@entry=0xedec20a0, ctx=ctx@entry=0xedeb6150)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_mont.c:351
 #9  0xedcfc06c in BN_is_prime_fasttest_ex (a=0xedec20a0,
     checks=<optimized out>, ctx_passed=0xedeb6150,
     do_trial_division=<optimized out>, cb=0x0)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_prime.c:215
 #10 0xedcfc784 in BN_generate_prime_ex (ret=ret@entry=0xedec20a0,
     bits=bits@entry=1536, safe=safe@entry=0, add=<optimized out>,
     add@entry=0x0, rem=rem@entry=0x0, cb=<optimized out>, cb@entry=0x0)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_prime.c:104
 #11 0xedc7b694 in rsa_builtin_keygen (cb=0x0, e_value=<optimized out>,
     primes=<optimized out>, bits=<optimized out>, rsa=0xedbba0c0)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/rsa/rsa_gen.c:164
 #12 RSA_generate_multi_prime_key (rsa=0xedbba0c0, bits=<optimized out>,
     primes=<optimized out>, e_value=<optimized out>, cb=0x0)
     at /usr/src/crypto/external/bsd/openssl/dist/crypto/rsa/rsa_gen.c:61
 #13 0xede37de4 in rsa_generate_private_key (rsap=0xedeb2148, bits=3072)
     at /usr/src/crypto/external/bsd/openssh/dist/sshkey.c:1454
 #14 sshkey_generate (type=-56, type@entry=0, bits=3072,
     keyp=keyp@entry=0xefffea98)
     at /usr/src/crypto/external/bsd/openssh/dist/sshkey.c:1607
 #15 0x0001931c in main (argc=<optimized out>, argv=0xeffff7f8)
     at /usr/src/crypto/external/bsd/openssh/dist/ssh-keygen.c:2816
 (gdb)

 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: lib/56318: sshd fails to start on NetBSD/pmax 9.2 R3000 3MIN
Date: Tue, 10 Aug 2021 07:11:41 +0900

 > This also happens on SPARC station 2 (sun4c) + NetBSD/sparc 9.2:
  :
 > (gdb) bt
 > #0  abort () at /usr/src/lib/libc/stdlib/abort.c:80
 > #1  0xeda19fc8 in __assert13 (
 >     file=0xedda9630 "/usr/src/crypto/external/bsd/openssl/dist/crypto/bn/bn_div.c", line=line@entry=439, function=<optimized out>,
 >     failedexpr=0xedda9670 "(*wnumtop) == 0")
 >     at /usr/src/lib/libc/gen/assert.c:72

 On the SPARC station 2, reverting
 src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/bn.inc r1.2
 solves the assertion.
  http://cvsweb.netbsd.org/bsdweb.cgi/src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/bn.inc#rev1.2

 --- src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/bn.inc	2014/03/02 09:02:43	1.1
 +++ src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/bn.inc	2020/06/21 22:16:08	1.2
 @@ -1,6 +1,5 @@
 -.if ${MACHINE} == "sparc64"
  .PATH.S: ${.PARSEDIR}
  # XXX bn-sparcv8plus.S doesn't work well. why?
  BN_SRCS = bn-sparcv8.S
 -.endif
 +AFLAGS.bn-sparcv8.S+= -Wa,-Av9
  .include "../../bn.inc"

 ---
 Izumi Tsutsui

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: lib/56318: sshd fails to start on NetBSD/pmax 9.2 R3000 3MIN
Date: Tue, 10 Aug 2021 10:08:04 +0900

 On mips, src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/bn.inc
 unconditionally pulls mips.S on mipsel (i.e. pmax etc.)
  https://nxr.netbsd.org/xref/src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/bn.inc?r=1.6
 mips.S doesn't seem to support MIPS1:
  https://nxr.netbsd.org/xref/src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/mips.S?r=1.2.2.2

 ---
       1 #if !(defined (__mips_isa_rev) && (__mips_isa_rev >= 6))
       2 .set     mips2
       3 #endif
       4 #include "mips_arch.h"
  :
      20 .rdata
      21 .asciiz	"mips3.s, Version 1.2"
      22 .asciiz	"MIPS II/III/IV ISA artwork by Andy Polyakov <appro (at) fy.chalmers.se>"

 ---
 Izumi Tsutsui

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56318 CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc
Date: Tue, 10 Aug 2021 06:38:42 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Tue Aug 10 10:38:42 UTC 2021

 Modified Files:
 	src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc: bn.inc

 Log Message:
 PR/56318: Izumi Tsutsui: Limit bn-sparcv8.S to sparc64; breaks
 on sparcstation 2 (sun4c)


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/bn.inc

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56318 CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips
Date: Tue, 10 Aug 2021 06:43:42 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Tue Aug 10 10:43:42 UTC 2021

 Modified Files:
 	src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips: bn.inc

 Log Message:
 PR/56318: Izumi Tsutsui: Don't include mips.S for 32 bit mips because it
 does not work for mips1


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/bn.inc

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Wed, 11 Aug 2021 01:00:23 +0000
State-Changed-Why:
Fixes confirmed on SPARC station 2 (sun4c) and DECstation 5000/125 (mips1).

For netbsd-9, needs to check the following mips64 changes can also be
pulled up without sideeffects to avoid extra conflicts:
 https://mail-index.netbsd.org/source-changes/2021/04/26/msg129170.html
 https://mail-index.netbsd.org/source-changes/2021/04/26/msg129181.html


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sat, 14 Aug 2021 17:19:31 +0000
State-Changed-Why:
[pullup-9 #1336]


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56318 CVS commit: [netbsd-9] src/crypto/external/bsd/openssl/lib/libcrypto/arch
Date: Sun, 15 Aug 2021 08:58:56 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Aug 15 08:58:56 UTC 2021

 Modified Files:
 	src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips [netbsd-9]:
 	    aes.inc bn.inc crypto.inc poly1305.inc sha.inc
 	src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc [netbsd-9]:
 	    bn.inc
 Added Files:
 	src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips [netbsd-9]:
 	    mips.inc

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #1336):

 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/mips.inc: revision 1.1
 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/mips.inc: revision 1.2
 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/bn.inc: revision 1.7
 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/poly1305.inc: revision 1.5
 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/bn.inc: revision 1.8
 	crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/bn.inc: revision 1.3
 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/crypto.inc: revision 1.8
 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/aes.inc: revision 1.6
 	crypto/external/bsd/openssl/lib/libcrypto/arch/mips/sha.inc: revision 1.7

 Centralize the logic for endian and 64 bit availability.

 Handle the compat builds and both the n64 and non n64 variants

 PR/56318: Izumi Tsutsui: Limit bn-sparcv8.S to sparc64; breaks
 on sparcstation 2 (sun4c)

 PR/56318: Izumi Tsutsui: Don't include mips.S for 32 bit mips because it
 does not work for mips1


 To generate a diff of this commit:
 cvs rdiff -u -r1.5 -r1.5.4.1 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/aes.inc
 cvs rdiff -u -r1.6 -r1.6.4.1 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/bn.inc \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/sha.inc
 cvs rdiff -u -r1.7 -r1.7.2.1 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/crypto.inc
 cvs rdiff -u -r0 -r1.2.6.2 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/mips.inc
 cvs rdiff -u -r1.4 -r1.4.4.1 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/mips/poly1305.inc
 cvs rdiff -u -r1.1.38.1 -r1.1.38.2 \
     src/crypto/external/bsd/openssl/lib/libcrypto/arch/sparc/bn.inc

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 15 Aug 2021 16:50:13 +0000
State-Changed-Why:
Pulled up.


>Unformatted:

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.