From owner-freebsd-stable@freebsd.org Thu Jul 27 16:29:04 2017 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37DC1DAA015 for ; Thu, 27 Jul 2017 16:29:04 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D557E8159C for ; Thu, 27 Jul 2017 16:29:03 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v6RGSuNY073417 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 27 Jul 2017 19:28:57 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v6RGSuNY073417 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v6RGSuMR073416; Thu, 27 Jul 2017 19:28:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 27 Jul 2017 19:28:56 +0300 From: Konstantin Belousov To: Eugene Grosbein Cc: FreeBSD Stable Subject: Re: stable/11 regression: SIGSYS in the /bin/sh Message-ID: <20170727162856.GH1700@kib.kiev.ua> References: <597A018D.4040601@grosbein.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <597A018D.4040601@grosbein.net> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jul 2017 16:29:04 -0000 On Thu, Jul 27, 2017 at 10:06:53PM +0700, Eugene Grosbein wrote: > Hi! > > Very recently stable/11 got a problem somewhere between r321073 and r321459: > /bin/sh crashes with SIGSYS at boot time: > > Trying to mount root from ufs:/dev/ada0s1a [ro]... > start_init: trying /sbin/init > ppid 21 (sh), uid 0: exited on signal 12 > id 21 comm sh: nosys 42 > Jul 27 14:30:23 init: /bin/sh on /etc/rc terminated abnormally, going to single user mode Take your /bin/sh, libraries and rtld to some other machine and try to catch where the pipe(2) call come from. I do not see any other way forward, assuming your build env is not contaminated somehow. I did the following on the today stable/11: pooma% ktrace -if /tmp/ktrace.out sh -c 'jot 100 | grep 1 | wc -l' 20 pooma% kdump -f /tmp/ktrace.out | grep pipe 1493 sh CALL pipe2(0x7fffffffe390,0) 1493 sh RET pipe2 0 1493 sh CALL pipe2(0x7fffffffe390,0) 1493 sh RET pipe2 0 > > This is *not* upgrade but complete rebuild of NanoBSD image: > all binaries, libraries and kernel are built from stable/11 sources. > > My custom kernel for amd64 has COMPAT_43TTY and COMPAT_FREEBSD32 options > and no other COMPAT_XXX options. It has no COMPAT_FREEBSD10 option too > as this is new installation. > > Also, I needed the following patch to make sysctl kern.lognosys > work for non-tty case: > > --- sys/kern/subr_prf.c.orig 2017-07-25 15:14:27.236304000 +0700 > +++ sys/kern/subr_prf.c 2017-07-27 21:05:55.912042000 +0700 > @@ -958,6 +958,7 @@ number: > break; > } > } > + return (retval); > #undef PCHAR > } > > --- sys/kern/kern_sig.c.orig 2017-07-25 15:14:27.232126000 +0700 > +++ sys/kern/kern_sig.c 2017-07-27 21:07:58.298440000 +0700 > @@ -3596,7 +3596,9 @@ > tdsignal(td, SIGSYS); > PROC_UNLOCK(p); > if (kern_lognosys) > - uprintf("pid %d comm %s: nosys %d\n", p->p_pid, p->p_comm, > + if (!uprintf("pid %d comm %s: nosys %d\n", p->p_pid, p->p_comm, > + td->td_sa.code)) > + printf("pid %d comm %s: nosys %d\n", p->p_pid, p->p_comm, > td->td_sa.code); > return (ENOSYS); > } > The following has more regular behavior. diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 37da97924ca..ce5e7b2768f 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -3579,9 +3579,14 @@ nosys(struct thread *td, struct nosys_args *args) PROC_LOCK(p); tdsignal(td, SIGSYS); PROC_UNLOCK(p); - if (kern_lognosys) + if (kern_lognosys == 1 || kern_lognosys == 3) { uprintf("pid %d comm %s: nosys %d\n", p->p_pid, p->p_comm, td->td_sa.code); + } + if (kern_lognosys == 2 || kern_lognosys == 3) { + printf("pid %d comm %s: nosys %d\n", p->p_pid, p->p_comm, + td->td_sa.code); + } return (ENOSYS); }