Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat Get the dynamic interpreter location using emul_f...



details:   https://anonhg.NetBSD.org/src/rev/174e37a9df6b
branches:  trunk
changeset: 539932:174e37a9df6b
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Nov 29 19:13:14 2002 +0000

description:
Get the dynamic interpreter location using emul_find_interp(), so that
it checks both the alternative/emul tree, and the non-emul tree.
This makes it possible to run chrooted emulated binaries without need
to setup shadow /emul tree within the chroot hierarchy.
Only tested for COMPAT_LINUX, changes to other compat modules were
mechanical.
Fixes kern/19161 by Christian Groessler.

diffstat:

 sys/compat/freebsd/freebsd_exec_elf32.c    |  12 ++++--------
 sys/compat/ibcs2/ibcs2_exec_elf32.c        |  11 +++--------
 sys/compat/irix/irix_exec.c                |  22 ++++++----------------
 sys/compat/linux/common/linux_exec_elf32.c |  15 +++++----------
 sys/compat/svr4/svr4_exec_elf32.c          |  11 +++--------
 sys/compat/svr4/svr4_exec_elf64.c          |  11 +++--------
 sys/compat/svr4_32/svr4_32_exec_elf32.c    |  11 +++--------
 7 files changed, 27 insertions(+), 66 deletions(-)

diffs (300 lines):

diff -r 5ea3235b6fb4 -r 174e37a9df6b sys/compat/freebsd/freebsd_exec_elf32.c
--- a/sys/compat/freebsd/freebsd_exec_elf32.c   Fri Nov 29 19:11:45 2002 +0000
+++ b/sys/compat/freebsd/freebsd_exec_elf32.c   Fri Nov 29 19:13:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_exec_elf32.c,v 1.8 2002/11/28 15:08:36 jdolecek Exp $  */
+/*     $NetBSD: freebsd_exec_elf32.c,v 1.9 2002/11/29 19:13:14 jdolecek Exp $  */
 
 /*
  * Copyright (c) 1993, 1994 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_exec_elf32.c,v 1.8 2002/11/28 15:08:36 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_exec_elf32.c,v 1.9 2002/11/29 19:13:14 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -64,7 +64,6 @@
        Elf_Phdr *ph;
        Elf_Phdr *ephp;
        Elf_Nhdr *np;
-       const char *bp;
 
         static const char wantBrand[] = FREEBSD_ELF_BRAND_STRING;
         static const char wantInterp[] = FREEBSD_ELF_INTERP_PREFIX_STRING;
@@ -117,12 +116,9 @@
        }
 
        if (itp[0]) {
-               if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
-                   itp, &bp, 0)))
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
+                   itp)))
                        return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &i)) != 0)
-                       return error;
-               free((void *)bp, M_TEMP);
        }
        *pos = ELF_NO_ADDR;
 #ifdef DEBUG_FREEBSD_ELF
diff -r 5ea3235b6fb4 -r 174e37a9df6b sys/compat/ibcs2/ibcs2_exec_elf32.c
--- a/sys/compat/ibcs2/ibcs2_exec_elf32.c       Fri Nov 29 19:11:45 2002 +0000
+++ b/sys/compat/ibcs2/ibcs2_exec_elf32.c       Fri Nov 29 19:13:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_exec_elf32.c,v 1.3 2001/11/13 02:08:23 lukem Exp $       */
+/*     $NetBSD: ibcs2_exec_elf32.c,v 1.4 2002/11/29 19:13:15 jdolecek Exp $    */
 
 /*
  * Copyright (c) 1994, 1995, 1998 Scott Bartram
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec_elf32.c,v 1.3 2001/11/13 02:08:23 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec_elf32.c,v 1.4 2002/11/29 19:13:15 jdolecek Exp $");
 
 #define ELFSIZE                32
 
@@ -127,19 +127,14 @@
        char *itp;
        vaddr_t *pos;
 {
-       const char *bp;
        int error;
-       size_t len;
 
        if ((error = ibcs2_elf32_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)))
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path, itp)))
                        return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
-                       return error;
-               free((void *)bp, M_TEMP);
        }
        *pos = ELF32_NO_ADDR;
        return 0;
diff -r 5ea3235b6fb4 -r 174e37a9df6b sys/compat/irix/irix_exec.c
--- a/sys/compat/irix/irix_exec.c       Fri Nov 29 19:11:45 2002 +0000
+++ b/sys/compat/irix/irix_exec.c       Fri Nov 29 19:13:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_exec.c,v 1.24 2002/11/09 09:03:58 manu Exp $ */
+/*     $NetBSD: irix_exec.c,v 1.25 2002/11/29 19:13:15 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.24 2002/11/09 09:03:58 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.25 2002/11/29 19:13:15 jdolecek Exp $");
 
 #ifndef ELFSIZE
 #define ELFSIZE                32      /* XXX should die */
@@ -159,9 +159,7 @@
        char *itp; 
        vaddr_t *pos; 
 {
-       const char *bp;
        int error;
-       size_t len;
 
 #ifdef DEBUG_IRIX
        printf("irix_probe_o32()\n");
@@ -175,12 +173,9 @@
                if (strncmp(itp, "/lib/libc.so", 12) && 
                    strncmp(itp, "/usr/lib/libc.so", 16))
                        return ENOEXEC;
-               if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
-                   itp, &bp, 0)))
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
+                   itp)))
                        return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
-                       return error;
-               free((void *)bp, M_TEMP);
        }
        *pos = ELF_NO_ADDR;
 #ifdef DEBUG_IRIX
@@ -202,9 +197,7 @@
        char *itp; 
        vaddr_t *pos; 
 {
-       const char *bp;
        int error;
-       size_t len;
 
 #ifdef DEBUG_IRIX
        printf("irix_probe_n32()\n");
@@ -218,12 +211,9 @@
                if (strncmp(itp, "/lib32/libc.so", 14) &&
                    strncmp(itp, "/usr/lib32/libc.so", 18))
                        return ENOEXEC;
-               if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
-                   itp, &bp, 0)))
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
+                   itp)))
                        return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
-                       return error;
-               free((void *)bp, M_TEMP);
        }
        *pos = ELF_NO_ADDR;
 #ifdef DEBUG_IRIX
diff -r 5ea3235b6fb4 -r 174e37a9df6b sys/compat/linux/common/linux_exec_elf32.c
--- a/sys/compat/linux/common/linux_exec_elf32.c        Fri Nov 29 19:11:45 2002 +0000
+++ b/sys/compat/linux/common/linux_exec_elf32.c        Fri Nov 29 19:13:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec_elf32.c,v 1.59 2002/11/13 15:16:29 jdolecek Exp $   */
+/*     $NetBSD: linux_exec_elf32.c,v 1.60 2002/11/29 19:13:16 jdolecek Exp $   */
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.59 2002/11/13 15:16:29 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.60 2002/11/29 19:13:16 jdolecek Exp $");
 
 #ifndef ELFSIZE
 /* XXX should die */
@@ -315,9 +315,7 @@
        char *itp;
        vaddr_t *pos;
 {
-       const char *bp;
        int error;
-       size_t len;
 
        if (((error = ELFNAME2(linux,signature)(p, epp, eh, itp)) != 0) &&
 #ifdef LINUX_GCC_SIGNATURE
@@ -330,12 +328,9 @@
                        return error;
 
        if (itp[0]) {
-               if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
-                   itp, &bp, 0)))
-                       return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
-                       return error;
-               free((void *)bp, M_TEMP);
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
+                   itp)))
+                       return (error);
        }
        *pos = ELF_NO_ADDR;
        DPRINTF(("linux_probe: returning 0\n"));
diff -r 5ea3235b6fb4 -r 174e37a9df6b sys/compat/svr4/svr4_exec_elf32.c
--- a/sys/compat/svr4/svr4_exec_elf32.c Fri Nov 29 19:11:45 2002 +0000
+++ b/sys/compat/svr4/svr4_exec_elf32.c Fri Nov 29 19:13:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_exec_elf32.c,v 1.4 2002/08/26 21:06:03 christos Exp $      */
+/*     $NetBSD: svr4_exec_elf32.c,v 1.5 2002/11/29 19:13:15 jdolecek Exp $      */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_exec_elf32.c,v 1.4 2002/08/26 21:06:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_exec_elf32.c,v 1.5 2002/11/29 19:13:15 jdolecek Exp $");
 
 #define        ELFSIZE         32                              /* XXX should die */
 
@@ -69,16 +69,11 @@
        char *itp;
        vaddr_t *pos;
 {
-       const char *bp;
        int error;
-       size_t len;
 
        if (itp[0]) {
-               if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path, itp, &bp, 0)))
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path, itp)))
                        return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
-                       return error;
-               free((void *)bp, M_TEMP);
        }
        *pos = SVR4_INTERP_ADDR;
        return 0;
diff -r 5ea3235b6fb4 -r 174e37a9df6b sys/compat/svr4/svr4_exec_elf64.c
--- a/sys/compat/svr4/svr4_exec_elf64.c Fri Nov 29 19:11:45 2002 +0000
+++ b/sys/compat/svr4/svr4_exec_elf64.c Fri Nov 29 19:13:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_exec_elf64.c,v 1.4 2002/08/26 21:06:03 christos Exp $      */
+/*     $NetBSD: svr4_exec_elf64.c,v 1.5 2002/11/29 19:13:16 jdolecek Exp $      */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_exec_elf64.c,v 1.4 2002/08/26 21:06:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_exec_elf64.c,v 1.5 2002/11/29 19:13:16 jdolecek Exp $");
 
 #define        ELFSIZE         64                              /* XXX should die */
 
@@ -69,16 +69,11 @@
        char *itp;
        vaddr_t *pos;
 {
-       const char *bp;
        int error;
-       size_t len;
 
        if (itp[0]) {
-               if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path, itp, &bp, 0)))
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path, itp)))
                        return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
-                       return error;
-               free((void *)bp, M_TEMP);
        }
        *pos = SVR4_INTERP_ADDR;
        return 0;
diff -r 5ea3235b6fb4 -r 174e37a9df6b sys/compat/svr4_32/svr4_32_exec_elf32.c
--- a/sys/compat/svr4_32/svr4_32_exec_elf32.c   Fri Nov 29 19:11:45 2002 +0000
+++ b/sys/compat/svr4_32/svr4_32_exec_elf32.c   Fri Nov 29 19:13:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_32_exec_elf32.c,v 1.7 2002/08/29 14:01:08 christos Exp $   */
+/*     $NetBSD: svr4_32_exec_elf32.c,v 1.8 2002/11/29 19:13:16 jdolecek Exp $   */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_32_exec_elf32.c,v 1.7 2002/08/29 14:01:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_32_exec_elf32.c,v 1.8 2002/11/29 19:13:16 jdolecek Exp $");
 
 #define        ELFSIZE         32                              /* XXX should die */
 
@@ -282,16 +282,11 @@
        char *itp;
        vaddr_t *pos;
 {
-       const char *bp;
        int error;
-       size_t len;
 
        if (itp[0]) {
-               if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path, itp, &bp, 0)))
+               if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path, itp)))
                        return error;
-               if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
-                       return error;
-               free((void *)bp, M_TEMP);
        }
        epp->ep_flags |= EXEC_32;
        *pos = SVR4_32_INTERP_ADDR;



Home | Main Index | Thread Index | Old Index