aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man4/man4.i386/linux.48
-rw-r--r--sys/alpha/alpha/elf_machdep.c2
-rw-r--r--sys/alpha/linux/linux_sysvec.c2
-rw-r--r--sys/amd64/amd64/elf_machdep.c2
-rw-r--r--sys/amd64/linux32/linux32_sysvec.c2
-rw-r--r--sys/arm/arm/elf_machdep.c2
-rw-r--r--sys/compat/ia32/ia32_sysvec.c2
-rw-r--r--sys/i386/i386/elf_machdep.c2
-rw-r--r--sys/i386/linux/linux_sysvec.c2
-rw-r--r--sys/ia64/ia64/elf_machdep.c2
-rw-r--r--sys/kern/imgact_elf.c17
-rw-r--r--sys/powerpc/powerpc/elf_machdep.c2
-rw-r--r--sys/sparc64/sparc64/elf_machdep.c2
-rw-r--r--sys/sys/imgact_elf.h2
14 files changed, 34 insertions, 15 deletions
diff --git a/share/man/man4/man4.i386/linux.4 b/share/man/man4/man4.i386/linux.4
index 649027b6f262..926b4ab4dbb5 100644
--- a/share/man/man4/man4.i386/linux.4
+++ b/share/man/man4/man4.i386/linux.4
@@ -108,14 +108,6 @@ regardless of whether the
.Nm
module is statically linked into the kernel
or loaded as a module.
-.Pp
-Some Linux scripts want to execute
-.Pa /lib/ld-linux.so.2 .
-In order to do this,
-you should turn the
-.Va kern.elf32.can_exec_dyn
-.Xr sysctl 8
-variable to 1.
.Sh FILES
.Bl -tag -width /compat/linux/proc -compact
.It Pa /compat/linux
diff --git a/sys/alpha/alpha/elf_machdep.c b/sys/alpha/alpha/elf_machdep.c
index 6a3c0607cc06..88b665a65c8e 100644
--- a/sys/alpha/alpha/elf_machdep.c
+++ b/sys/alpha/alpha/elf_machdep.c
@@ -85,6 +85,7 @@ static Elf64_Brandinfo freebsd_brand_info = {
"/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -99,6 +100,7 @@ static Elf64_Brandinfo freebsd_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,
diff --git a/sys/alpha/linux/linux_sysvec.c b/sys/alpha/linux/linux_sysvec.c
index 4ec29578d1fc..61f7875f402a 100644
--- a/sys/alpha/linux/linux_sysvec.c
+++ b/sys/alpha/linux/linux_sysvec.c
@@ -208,6 +208,7 @@ static Elf64_Brandinfo linux_brand = {
"/lib/ld-linux.so.1",
&elf_linux_sysvec,
NULL,
+ BI_CAN_EXEC_DYN,
};
static Elf64_Brandinfo linux_glibc2brand = {
@@ -218,6 +219,7 @@ static Elf64_Brandinfo linux_glibc2brand = {
"/lib/ld-linux.so.2",
&elf_linux_sysvec,
NULL,
+ BI_CAN_EXEC_DYN,
};
Elf64_Brandinfo *linux_brandlist[] = {
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
index 0c4a0cce7419..cb5694dde13d 100644
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -82,6 +82,7 @@ static Elf64_Brandinfo freebsd_brand_info = {
"/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -96,6 +97,7 @@ static Elf64_Brandinfo freebsd_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
index c69b5318464c..31d2cb8e39e9 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -1026,6 +1026,7 @@ static Elf32_Brandinfo linux_brand = {
"/lib/ld-linux.so.1",
&elf_linux_sysvec,
NULL,
+ BI_CAN_EXEC_DYN,
};
static Elf32_Brandinfo linux_glibc2brand = {
@@ -1036,6 +1037,7 @@ static Elf32_Brandinfo linux_glibc2brand = {
"/lib/ld-linux.so.2",
&elf_linux_sysvec,
NULL,
+ BI_CAN_EXEC_DYN,
};
Elf32_Brandinfo *linux_brandlist[] = {
diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c
index 496b975bc2d9..749a8493aae7 100644
--- a/sys/arm/arm/elf_machdep.c
+++ b/sys/arm/arm/elf_machdep.c
@@ -82,6 +82,7 @@ static Elf32_Brandinfo freebsd_brand_info = {
"/libexec/ld-elf.so.1",
&elf32_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -96,6 +97,7 @@ static Elf32_Brandinfo freebsd_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&elf32_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,
diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c
index a18163b1d9e3..ede511d63fec 100644
--- a/sys/compat/ia32/ia32_sysvec.c
+++ b/sys/compat/ia32/ia32_sysvec.c
@@ -137,6 +137,7 @@ static Elf32_Brandinfo ia32_brand_info = {
"/libexec/ld-elf.so.1",
&ia32_freebsd_sysvec,
"/libexec/ld-elf32.so.1",
+ 0,
};
SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -151,6 +152,7 @@ static Elf32_Brandinfo ia32_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&ia32_freebsd_sysvec,
"/libexec/ld-elf32.so.1",
+ 0,
};
SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY,
diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c
index d8756cc51fbf..2b3ffb4587ac 100644
--- a/sys/i386/i386/elf_machdep.c
+++ b/sys/i386/i386/elf_machdep.c
@@ -82,6 +82,7 @@ static Elf32_Brandinfo freebsd_brand_info = {
"/libexec/ld-elf.so.1",
&elf32_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -96,6 +97,7 @@ static Elf32_Brandinfo freebsd_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&elf32_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index f28371dc5218..1335f9aae010 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -868,6 +868,7 @@ static Elf32_Brandinfo linux_brand = {
"/lib/ld-linux.so.1",
&elf_linux_sysvec,
NULL,
+ BI_CAN_EXEC_DYN,
};
static Elf32_Brandinfo linux_glibc2brand = {
@@ -878,6 +879,7 @@ static Elf32_Brandinfo linux_glibc2brand = {
"/lib/ld-linux.so.2",
&elf_linux_sysvec,
NULL,
+ BI_CAN_EXEC_DYN,
};
Elf32_Brandinfo *linux_brandlist[] = {
diff --git a/sys/ia64/ia64/elf_machdep.c b/sys/ia64/ia64/elf_machdep.c
index ccd50835694d..64f82503d420 100644
--- a/sys/ia64/ia64/elf_machdep.c
+++ b/sys/ia64/ia64/elf_machdep.c
@@ -90,6 +90,7 @@ static Elf64_Brandinfo freebsd_brand_info = {
"/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
(sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_info);
@@ -102,6 +103,7 @@ static Elf64_Brandinfo freebsd_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,
(sysinit_cfunc_t)elf64_insert_brand_entry, &freebsd_brand_oinfo);
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index ce80f8b2ae71..5047d4161c55 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -97,11 +97,6 @@ SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
TUNABLE_INT("kern.elf" __XSTRING(__ELF_WORD_SIZE) ".fallback_brand",
&__elfN(fallback_brand));
-int __elfN(can_exec_dyn) = 0;
-SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
- can_exec_dyn, CTLFLAG_RW, &__elfN(can_exec_dyn), 0,
- __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) " can exec shared libraries");
-
static int elf_trace = 0;
SYSCTL_INT(_debug, OID_AUTO, __elfN(trace), CTLFLAG_RW, &elf_trace, 0, "");
@@ -619,9 +614,12 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
/*
* Do we have a valid ELF header ?
+ *
+ * Only allow ET_EXEC & ET_DYN here, reject ET_DYN later
+ * if particular brand doesn't support it.
*/
- if (__elfN(check_header)(hdr) != 0 || (hdr->e_type != ET_EXEC
- && (!__elfN(can_exec_dyn) || hdr->e_type != ET_DYN)))
+ if (__elfN(check_header)(hdr) != 0 ||
+ (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN))
return (-1);
/*
@@ -654,6 +652,11 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
hdr->e_ident[EI_OSABI]);
return (ENOEXEC);
}
+ if (hdr->e_type == ET_DYN &&
+ (brand_info->flags & BI_CAN_EXEC_DYN) == 0) {
+ error = ENOEXEC;
+ goto fail;
+ }
sv = brand_info->sysvec;
if (interp != NULL && brand_info->interp_newpath != NULL)
interp = brand_info->interp_newpath;
diff --git a/sys/powerpc/powerpc/elf_machdep.c b/sys/powerpc/powerpc/elf_machdep.c
index 6063e7bc793c..be979b34c5fa 100644
--- a/sys/powerpc/powerpc/elf_machdep.c
+++ b/sys/powerpc/powerpc/elf_machdep.c
@@ -85,6 +85,7 @@ static Elf32_Brandinfo freebsd_brand_info = {
"/libexec/ld-elf.so.1",
&elf32_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -99,6 +100,7 @@ static Elf32_Brandinfo freebsd_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&elf32_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_ANY,
diff --git a/sys/sparc64/sparc64/elf_machdep.c b/sys/sparc64/sparc64/elf_machdep.c
index b113afed7855..1b9bbc23ece9 100644
--- a/sys/sparc64/sparc64/elf_machdep.c
+++ b/sys/sparc64/sparc64/elf_machdep.c
@@ -95,6 +95,7 @@ static Elf64_Brandinfo freebsd_brand_info = {
"/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
@@ -109,6 +110,7 @@ static Elf64_Brandinfo freebsd_brand_oinfo = {
"/usr/libexec/ld-elf.so.1",
&elf64_freebsd_sysvec,
NULL,
+ 0,
};
SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_ANY,
diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h
index 8bb4cc25a976..663a09078fa8 100644
--- a/sys/sys/imgact_elf.h
+++ b/sys/sys/imgact_elf.h
@@ -63,6 +63,8 @@ typedef struct {
const char *interp_path;
struct sysentvec *sysvec;
const char *interp_newpath;
+ int flags;
+#define BI_CAN_EXEC_DYN 0x0001
} __ElfN(Brandinfo);
__ElfType(Auxargs);