NetBSD Problem Report #16041

Received: (qmail 12773 invoked from network); 24 Mar 2002 23:21:49 -0000
Message-Id: <20020324232200.3756B1111A@www.netbsd.org>
Date: Sun, 24 Mar 2002 15:22:00 -0800 (PST)
From: rslr.free.fr@netbsd.org
Sender: nobody@netbsd.org
Reply-To: rslr.free.fr@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: a chroot to /emul/netbsd32 will panic the kernel
X-Send-Pr-Version: www-1.0

>Number:         16041
>Category:       port-sparc64
>Synopsis:       a chroot to /emul/netbsd32 will panic the kernel
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc64-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 24 23:22:00 +0000 2002
>Closed-Date:    Fri May 31 01:00:43 +0000 2002
>Last-Modified:  Fri May 31 01:00:43 +0000 2002
>Originator:     de SAINT LEGER Rodolphe
>Release:        current (ZA and ZC kernel)
>Organization:
none
>Environment:
NetBSD deedlit 1.5ZC NetBSD 1.5ZC (DEEDLIT) #0: Thu Mar 14 01:44:27 CET 2002     root@akima:/usr/src/sys/arch/sparc64/compile/DEEDLIT sparc64
>Description:
When using a 64 bit kernel, it is possible to emulate 32 bit netbsd sparc binaries.
When we chroot to /emul/netbsd32, it works  (with sometimes segfaults) and then panics once we launch
a command

I've tryied to setup a symlink in the netbsd32 directory to itself, and it doesn't work
ln -s / /emul/netbsd32/emul/netbsd32
>How-To-Repeat:
# chroot /emul/netbsd32 ksh
# id

>Fix:

In general chroot-ing to an emulated installation is not supported
because the device major numbers will not be correct.  However, since
this is the same operating system in both cases, that's usually not
an issue for /emul/netbsd32, so we might as well allow it in this case.

*** syssrc/sys/compat/netbsd32/netbsd32_exec_elf32.c:1.8        Tue Nov 13 04:09:05 2001
--- syssrc/sys/compat/netbsd32/netbsd32_exec_elf32.c    Fri May 31 03:49:42 2002
***************
*** 1,4 ****
! /*    $NetBSD: netbsd32_exec_elf32.c,v 1.8 2001/11/13 02:09:05 lukem Exp $    */
  /*    from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */

  /*
--- 1,4 ----
! /*    $NetBSD: netbsd32_exec_elf32.c,v 1.9 2002/05/31 00:49:42 eeh Exp $      */
  /*    from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */

  /*
***************
*** 33,39 ****
   */

  #include <sys/cdefs.h>
! __KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.8 2001/11/13 02:09:05 lukem Exp $");

  #define       ELFSIZE         32

--- 33,39 ----
   */

  #include <sys/cdefs.h>
! __KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.9 2002/05/31 00:49:42 eeh Exp $");

  #define       ELFSIZE         32

***************
*** 69,85 ****
        vaddr_t *pos;
  {
        int error;
-       size_t i;
-       const char *bp;

        if ((error = ELFNAME2(netbsd,signature)(p, epp, eh)) != 0)
                return error;

        if (itp[0]) {
                if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
!                                      itp, &bp, 0)) && 
!                   (error = emul_find(p, NULL, "", itp, &bp, 0)))
!                       return error;
                if ((error = copystr(bp, itp, MAXPATHLEN, &i)) != 0)
                        return error;
                free((void *)bp, M_TEMP);
--- 69,108 ----
        vaddr_t *pos;
  {
        int error;

        if ((error = ELFNAME2(netbsd,signature)(p, epp, eh)) != 0)
                return error;

+       return ELFNAME2(netbsd32,probe_noteless)(p, epp, eh, itp, pos);
+ }
+ 
+ int
+ ELFNAME2(netbsd32,probe_noteless)(p, epp, eh, itp, pos)
+       struct proc *p;
+       struct exec_package *epp;
+       void *eh;
+       char *itp;
+       vaddr_t *pos;
+ {
+       int error;
+       size_t i;
+       const char *bp;
+ 
        if (itp[0]) {
+               /* Translate interpreter name if needed */
                if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
!                       itp, &bp, 0)) != 0) {
!                       /* 
!                        * See if we're chroot-ed.  Since it's the same OS,
!                        * there really shouldn't be any device node issues
!                        * so we might as well support chroot-ing to a 32-bit
!                        * installation.
!                        */
!                       if ((error = emul_find(p, NULL, "/", itp, &bp, 0)) 
!                               != 0) {
!                               return error;
!                       }
!               }
                if ((error = copystr(bp, itp, MAXPATHLEN, &i)) != 0)
                        return error;
                free((void *)bp, M_TEMP);


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: eeh 
State-Changed-When: Thu May 30 18:00:15 PDT 2002 
State-Changed-Why:  
Problem fixed. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(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.