Page MenuHomeFreeBSD

D14856.id40758.diff
No OneTemporary

D14856.id40758.diff

Index: sys/amd64/linux/linux_sysvec.c
===================================================================
--- sys/amd64/linux/linux_sysvec.c
+++ sys/amd64/linux/linux_sysvec.c
@@ -87,12 +87,6 @@
MODULE_VERSION(linux64, 1);
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define SHELLMAGIC 0x2123 /* #! */
-#else
-#define SHELLMAGIC 0x2321
-#endif
-
#if defined(DEBUG)
SYSCTL_PROC(_compat_linux, OID_AUTO, debug, CTLTYPE_STRING | CTLFLAG_RW, 0, 0,
linux_sysctl_debug, "A", "64-bit Linux debugging control");
@@ -124,7 +118,6 @@
static void linux_vdso_deinstall(const void *param);
static void linux_set_syscall_retval(struct thread *td, int error);
static int linux_fetch_syscall_args(struct thread *td);
-static int linux_exec_imgact_try(struct image_params *iparams);
static void linux_exec_setregs(struct thread *td, struct image_params *imgp,
u_long stack);
static int linux_vsyscall(struct thread *td);
@@ -662,42 +655,6 @@
mtx_lock(&psp->ps_mtx);
}
-/*
- * If a Linux binary is exec'ing something, try this image activator
- * first. We override standard shell script execution in order to
- * be able to modify the interpreter path. We only do this if a Linux
- * binary is doing the exec, so we do not create an EXEC module for it.
- */
-static int
-linux_exec_imgact_try(struct image_params *imgp)
-{
- const char *head = (const char *)imgp->image_header;
- char *rpath;
- int error = -1;
-
- /*
- * The interpreter for shell scripts run from a Linux binary needs
- * to be located in /compat/linux if possible in order to recursively
- * maintain Linux path emulation.
- */
- if (((const short *)head)[0] == SHELLMAGIC) {
- /*
- * Run our normal shell image activator. If it succeeds then
- * attempt to use the alternate path for the interpreter. If
- * an alternate path is found, use our stringspace to store it.
- */
- if ((error = exec_shell_imgact(imgp)) == 0) {
- linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
- imgp->interpreter_name, UIO_SYSSPACE, &rpath, 0,
- AT_FDCWD);
- if (rpath != NULL)
- imgp->args->fname_buf =
- imgp->interpreter_name = rpath;
- }
- }
- return (error);
-}
-
#define LINUX_VSYSCALL_START (-10UL << 20)
#define LINUX_VSYSCALL_SZ 1024
Index: sys/amd64/linux32/linux32_sysvec.c
===================================================================
--- sys/amd64/linux32/linux32_sysvec.c
+++ sys/amd64/linux32/linux32_sysvec.c
@@ -95,12 +95,6 @@
suword32(pos++, val); \
} while (0)
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define SHELLMAGIC 0x2123 /* #! */
-#else
-#define SHELLMAGIC 0x2321
-#endif
-
/*
* Allow the sendsig functions to use the ldebug() facility even though they
* are not syscalls themselves. Map them to syscall 0. This is slightly less
@@ -124,7 +118,6 @@
struct image_params *iparams);
static register_t *linux_copyout_strings(struct image_params *imgp);
static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
-static int linux_exec_imgact_try(struct image_params *iparams);
static void linux_exec_setregs(struct thread *td,
struct image_params *imgp, u_long stack);
static void linux32_fixlimit(struct rlimit *rl, int which);
@@ -718,42 +711,6 @@
return (0);
}
-/*
- * If a Linux binary is exec'ing something, try this image activator
- * first. We override standard shell script execution in order to
- * be able to modify the interpreter path. We only do this if a Linux
- * binary is doing the exec, so we do not create an EXEC module for it.
- */
-static int
-linux_exec_imgact_try(struct image_params *imgp)
-{
- const char *head = (const char *)imgp->image_header;
- char *rpath;
- int error = -1;
-
- /*
- * The interpreter for shell scripts run from a Linux binary needs
- * to be located in /compat/linux if possible in order to recursively
- * maintain Linux path emulation.
- */
- if (((const short *)head)[0] == SHELLMAGIC) {
- /*
- * Run our normal shell image activator. If it succeeds then
- * attempt to use the alternate path for the interpreter. If
- * an alternate path is found, use our stringspace to store it.
- */
- if ((error = exec_shell_imgact(imgp)) == 0) {
- linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
- imgp->interpreter_name, UIO_SYSSPACE, &rpath, 0,
- AT_FDCWD);
- if (rpath != NULL)
- imgp->args->fname_buf =
- imgp->interpreter_name = rpath;
- }
- }
- return (error);
-}
-
/*
* Clear registers on exec
* XXX copied from ia32_signal.c.
Index: sys/compat/linux/linux_emul.h
===================================================================
--- sys/compat/linux/linux_emul.h
+++ sys/compat/linux/linux_emul.h
@@ -49,6 +49,7 @@
struct linux_emuldata *em_find(struct thread *);
+int linux_exec_imgact_try(struct image_params *);
void linux_proc_init(struct thread *, struct thread *, int);
void linux_proc_exit(void *, struct proc *);
void linux_schedtail(struct thread *);
Index: sys/compat/linux/linux_emul.c
===================================================================
--- sys/compat/linux/linux_emul.c
+++ sys/compat/linux/linux_emul.c
@@ -32,6 +32,7 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/fcntl.h>
#include <sys/imgact.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
@@ -48,6 +49,11 @@
#include <compat/linux/linux_persona.h>
#include <compat/linux/linux_util.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define SHELLMAGIC 0x2123 /* #! */
+#else
+#define SHELLMAGIC 0x2321
+#endif
/*
* This returns reference to the thread emuldata entry (if found)
@@ -168,6 +174,42 @@
free(pem, M_LINUX);
}
+/*
+ * If a Linux binary is exec'ing something, try this image activator
+ * first. We override standard shell script execution in order to
+ * be able to modify the interpreter path. We only do this if a Linux
+ * binary is doing the exec, so we do not create an EXEC module for it.
+ */
+int
+linux_exec_imgact_try(struct image_params *imgp)
+{
+ const char *head = (const char *)imgp->image_header;
+ char *rpath;
+ int error = -1;
+
+ /*
+ * The interpreter for shell scripts run from a Linux binary needs
+ * to be located in /compat/linux if possible in order to recursively
+ * maintain Linux path emulation.
+ */
+ if (((const short *)head)[0] == SHELLMAGIC) {
+ /*
+ * Run our normal shell image activator. If it succeeds attempt
+ * to use the alternate path for the interpreter. If an
+ * alternate path is found, use our stringspace to store it.
+ */
+ if ((error = exec_shell_imgact(imgp)) == 0) {
+ linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
+ imgp->interpreter_name, UIO_SYSSPACE, &rpath, 0,
+ AT_FDCWD);
+ if (rpath != NULL)
+ imgp->args->fname_buf =
+ imgp->interpreter_name = rpath;
+ }
+ }
+ return (error);
+}
+
int
linux_common_execve(struct thread *td, struct image_args *eargs)
{
Index: sys/i386/linux/linux_sysvec.c
===================================================================
--- sys/i386/linux/linux_sysvec.c
+++ sys/i386/linux/linux_sysvec.c
@@ -76,12 +76,6 @@
MODULE_VERSION(linux, 1);
-#if BYTE_ORDER == LITTLE_ENDIAN
-#define SHELLMAGIC 0x2123 /* #! */
-#else
-#define SHELLMAGIC 0x2321
-#endif
-
#if defined(DEBUG)
SYSCTL_PROC(_compat_linux, OID_AUTO, debug, CTLTYPE_STRING | CTLFLAG_RW, 0, 0,
linux_sysctl_debug, "A", "Linux debugging control");
@@ -112,7 +106,6 @@
static int linux_fixup_elf(register_t **stack_base,
struct image_params *iparams);
static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
-static int linux_exec_imgact_try(struct image_params *iparams);
static void linux_exec_setregs(struct thread *td,
struct image_params *imgp, u_long stack);
static register_t *linux_copyout_strings(struct image_params *imgp);
@@ -815,42 +808,6 @@
return (0);
}
-/*
- * If a Linux binary is exec'ing something, try this image activator
- * first. We override standard shell script execution in order to
- * be able to modify the interpreter path. We only do this if a Linux
- * binary is doing the exec, so we do not create an EXEC module for it.
- */
-static int
-linux_exec_imgact_try(struct image_params *imgp)
-{
- const char *head = (const char *)imgp->image_header;
- char *rpath;
- int error = -1;
-
- /*
- * The interpreter for shell scripts run from a Linux binary needs
- * to be located in /compat/linux if possible in order to recursively
- * maintain Linux path emulation.
- */
- if (((const short *)head)[0] == SHELLMAGIC) {
- /*
- * Run our normal shell image activator. If it succeeds then
- * attempt to use the alternate path for the interpreter. If
- * an alternate path is found, use our stringspace to store it.
- */
- if ((error = exec_shell_imgact(imgp)) == 0) {
- linux_emul_convpath(FIRST_THREAD_IN_PROC(imgp->proc),
- imgp->interpreter_name, UIO_SYSSPACE, &rpath, 0,
- AT_FDCWD);
- if (rpath != NULL)
- imgp->args->fname_buf =
- imgp->interpreter_name = rpath;
- }
- }
- return (error);
-}
-
/*
* exec_setregs may initialize some registers differently than Linux
* does, thus potentially confusing Linux binaries. If necessary, we

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 26, 1:33 AM (1 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27988617
Default Alt Text
D14856.id40758.diff (9 KB)

Event Timeline