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.
This commit is contained in:
parent
db25e6f163
commit
47cd9b85d6
|
@ -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
|
* Copyright (c) 1993, 1994 Christopher G. Demetriou
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -64,7 +64,6 @@ ELFNAME2(freebsd,probe)(p, epp, veh, itp, pos)
|
||||||
Elf_Phdr *ph;
|
Elf_Phdr *ph;
|
||||||
Elf_Phdr *ephp;
|
Elf_Phdr *ephp;
|
||||||
Elf_Nhdr *np;
|
Elf_Nhdr *np;
|
||||||
const char *bp;
|
|
||||||
|
|
||||||
static const char wantBrand[] = FREEBSD_ELF_BRAND_STRING;
|
static const char wantBrand[] = FREEBSD_ELF_BRAND_STRING;
|
||||||
static const char wantInterp[] = FREEBSD_ELF_INTERP_PREFIX_STRING;
|
static const char wantInterp[] = FREEBSD_ELF_INTERP_PREFIX_STRING;
|
||||||
|
@ -117,12 +116,9 @@ ELFNAME2(freebsd,probe)(p, epp, veh, itp, pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itp[0]) {
|
if (itp[0]) {
|
||||||
if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
|
if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
|
||||||
itp, &bp, 0)))
|
itp)))
|
||||||
return error;
|
return error;
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &i)) != 0)
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
*pos = ELF_NO_ADDR;
|
*pos = ELF_NO_ADDR;
|
||||||
#ifdef DEBUG_FREEBSD_ELF
|
#ifdef DEBUG_FREEBSD_ELF
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1994, 1995, 1998 Scott Bartram
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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
|
#define ELFSIZE 32
|
||||||
|
|
||||||
|
@ -127,19 +127,14 @@ ibcs2_elf32_probe(p, epp, eh, itp, pos)
|
||||||
char *itp;
|
char *itp;
|
||||||
vaddr_t *pos;
|
vaddr_t *pos;
|
||||||
{
|
{
|
||||||
const char *bp;
|
|
||||||
int error;
|
int error;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if ((error = ibcs2_elf32_signature(p, epp, eh)) != 0)
|
if ((error = ibcs2_elf32_signature(p, epp, eh)) != 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if (itp[0]) {
|
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;
|
return error;
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
*pos = ELF32_NO_ADDR;
|
*pos = ELF32_NO_ADDR;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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
|
#ifndef ELFSIZE
|
||||||
#define ELFSIZE 32 /* XXX should die */
|
#define ELFSIZE 32 /* XXX should die */
|
||||||
|
@ -159,9 +159,7 @@ ELFNAME2(irix,probe_o32)(p, epp, eh, itp, pos)
|
||||||
char *itp;
|
char *itp;
|
||||||
vaddr_t *pos;
|
vaddr_t *pos;
|
||||||
{
|
{
|
||||||
const char *bp;
|
|
||||||
int error;
|
int error;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
#ifdef DEBUG_IRIX
|
#ifdef DEBUG_IRIX
|
||||||
printf("irix_probe_o32()\n");
|
printf("irix_probe_o32()\n");
|
||||||
|
@ -175,12 +173,9 @@ ELFNAME2(irix,probe_o32)(p, epp, eh, itp, pos)
|
||||||
if (strncmp(itp, "/lib/libc.so", 12) &&
|
if (strncmp(itp, "/lib/libc.so", 12) &&
|
||||||
strncmp(itp, "/usr/lib/libc.so", 16))
|
strncmp(itp, "/usr/lib/libc.so", 16))
|
||||||
return ENOEXEC;
|
return ENOEXEC;
|
||||||
if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
|
if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
|
||||||
itp, &bp, 0)))
|
itp)))
|
||||||
return error;
|
return error;
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
*pos = ELF_NO_ADDR;
|
*pos = ELF_NO_ADDR;
|
||||||
#ifdef DEBUG_IRIX
|
#ifdef DEBUG_IRIX
|
||||||
|
@ -202,9 +197,7 @@ ELFNAME2(irix,probe_n32)(p, epp, eh, itp, pos)
|
||||||
char *itp;
|
char *itp;
|
||||||
vaddr_t *pos;
|
vaddr_t *pos;
|
||||||
{
|
{
|
||||||
const char *bp;
|
|
||||||
int error;
|
int error;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
#ifdef DEBUG_IRIX
|
#ifdef DEBUG_IRIX
|
||||||
printf("irix_probe_n32()\n");
|
printf("irix_probe_n32()\n");
|
||||||
|
@ -218,12 +211,9 @@ ELFNAME2(irix,probe_n32)(p, epp, eh, itp, pos)
|
||||||
if (strncmp(itp, "/lib32/libc.so", 14) &&
|
if (strncmp(itp, "/lib32/libc.so", 14) &&
|
||||||
strncmp(itp, "/usr/lib32/libc.so", 18))
|
strncmp(itp, "/usr/lib32/libc.so", 18))
|
||||||
return ENOEXEC;
|
return ENOEXEC;
|
||||||
if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
|
if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
|
||||||
itp, &bp, 0)))
|
itp)))
|
||||||
return error;
|
return error;
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
*pos = ELF_NO_ADDR;
|
*pos = ELF_NO_ADDR;
|
||||||
#ifdef DEBUG_IRIX
|
#ifdef DEBUG_IRIX
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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
|
#ifndef ELFSIZE
|
||||||
/* XXX should die */
|
/* XXX should die */
|
||||||
|
@ -315,9 +315,7 @@ ELFNAME2(linux,probe)(p, epp, eh, itp, pos)
|
||||||
char *itp;
|
char *itp;
|
||||||
vaddr_t *pos;
|
vaddr_t *pos;
|
||||||
{
|
{
|
||||||
const char *bp;
|
|
||||||
int error;
|
int error;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (((error = ELFNAME2(linux,signature)(p, epp, eh, itp)) != 0) &&
|
if (((error = ELFNAME2(linux,signature)(p, epp, eh, itp)) != 0) &&
|
||||||
#ifdef LINUX_GCC_SIGNATURE
|
#ifdef LINUX_GCC_SIGNATURE
|
||||||
|
@ -330,12 +328,9 @@ ELFNAME2(linux,probe)(p, epp, eh, itp, pos)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
if (itp[0]) {
|
if (itp[0]) {
|
||||||
if ((error = emul_find(p, NULL, epp->ep_esch->es_emul->e_path,
|
if ((error = emul_find_interp(p, epp->ep_esch->es_emul->e_path,
|
||||||
itp, &bp, 0)))
|
itp)))
|
||||||
return error;
|
return (error);
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
*pos = ELF_NO_ADDR;
|
*pos = ELF_NO_ADDR;
|
||||||
DPRINTF(("linux_probe: returning 0\n"));
|
DPRINTF(("linux_probe: returning 0\n"));
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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 */
|
#define ELFSIZE 32 /* XXX should die */
|
||||||
|
|
||||||
|
@ -69,16 +69,11 @@ svr4_elf32_probe(p, epp, eh, itp, pos)
|
||||||
char *itp;
|
char *itp;
|
||||||
vaddr_t *pos;
|
vaddr_t *pos;
|
||||||
{
|
{
|
||||||
const char *bp;
|
|
||||||
int error;
|
int error;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (itp[0]) {
|
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;
|
return error;
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
*pos = SVR4_INTERP_ADDR;
|
*pos = SVR4_INTERP_ADDR;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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 */
|
#define ELFSIZE 64 /* XXX should die */
|
||||||
|
|
||||||
|
@ -69,16 +69,11 @@ svr4_elf64_probe(p, epp, eh, itp, pos)
|
||||||
char *itp;
|
char *itp;
|
||||||
vaddr_t *pos;
|
vaddr_t *pos;
|
||||||
{
|
{
|
||||||
const char *bp;
|
|
||||||
int error;
|
int error;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (itp[0]) {
|
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;
|
return error;
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
*pos = SVR4_INTERP_ADDR;
|
*pos = SVR4_INTERP_ADDR;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -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.
|
* Copyright (c) 1994 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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 */
|
#define ELFSIZE 32 /* XXX should die */
|
||||||
|
|
||||||
|
@ -282,16 +282,11 @@ svr4_32_elf32_probe(p, epp, eh, itp, pos)
|
||||||
char *itp;
|
char *itp;
|
||||||
vaddr_t *pos;
|
vaddr_t *pos;
|
||||||
{
|
{
|
||||||
const char *bp;
|
|
||||||
int error;
|
int error;
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (itp[0]) {
|
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;
|
return error;
|
||||||
if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
|
|
||||||
return error;
|
|
||||||
free((void *)bp, M_TEMP);
|
|
||||||
}
|
}
|
||||||
epp->ep_flags |= EXEC_32;
|
epp->ep_flags |= EXEC_32;
|
||||||
*pos = SVR4_32_INTERP_ADDR;
|
*pos = SVR4_32_INTERP_ADDR;
|
||||||
|
|
Loading…
Reference in New Issue