diff options
author | 2008-06-12 04:32:57 +0000 | |
---|---|---|
committer | 2008-06-12 04:32:57 +0000 | |
commit | be2183ffa64d4d74432099e99034f8e513277f79 (patch) | |
tree | 14d4f52f9cc48add8c28ef683836726122cb9e0b | |
parent | thal shalt not code past the eightieth column (diff) | |
download | wireguard-openbsd-be2183ffa64d4d74432099e99034f8e513277f79.tar.xz wireguard-openbsd-be2183ffa64d4d74432099e99034f8e513277f79.zip |
Do not attempt to recognize foreign ELF binaries if emulation is disabled;
also recognize modern Linux binaries without branding, but with a ``GNU''
ABI note.
-rw-r--r-- | sys/compat/freebsd/freebsd_exec.c | 5 | ||||
-rw-r--r-- | sys/compat/linux/linux_exec.c | 16 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_exec.c | 5 |
3 files changed, 22 insertions, 4 deletions
diff --git a/sys/compat/freebsd/freebsd_exec.c b/sys/compat/freebsd/freebsd_exec.c index 6c545c299ca..3a750dce41d 100644 --- a/sys/compat/freebsd/freebsd_exec.c +++ b/sys/compat/freebsd/freebsd_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freebsd_exec.c,v 1.17 2006/01/19 17:54:50 mickey Exp $ */ +/* $OpenBSD: freebsd_exec.c,v 1.18 2008/06/12 04:32:57 miod Exp $ */ /* $NetBSD: freebsd_exec.c,v 1.2 1996/05/18 16:02:08 christos Exp $ */ /* @@ -166,6 +166,9 @@ freebsd_elf_probe(p, epp, itp, pos, os) int error; size_t len; + if (!(emul_freebsd_elf.e_flags & EMUL_ENABLED)) + return (ENOEXEC); + /* * Older FreeBSD ELF binaries use a brand; newer ones use EI_OSABI */ diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c index 1611639b241..a5cb81d7c31 100644 --- a/sys/compat/linux/linux_exec.c +++ b/sys/compat/linux/linux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_exec.c,v 1.27 2007/10/30 12:09:22 gilles Exp $ */ +/* $OpenBSD: linux_exec.c,v 1.28 2008/06/12 04:32:59 miod Exp $ */ /* $NetBSD: linux_exec.c,v 1.13 1996/04/05 00:01:10 christos Exp $ */ /*- @@ -483,9 +483,21 @@ linux_elf_probe(p, epp, itp, pos, os) int error; size_t len; + if (!(emul_linux_elf.e_flags & EMUL_ENABLED)) + return (ENOEXEC); + + /* + * Modern Linux binaries carry an identification note. + */ + if (ELFNAME(os_pt_note)(p, epp, epp->ep_hdr, "GNU", 4, 0x10) == 0) { + goto recognized; + } + brand = elf32_check_brand(eh); - if (brand && strcmp(brand, "Linux")) + if (brand == NULL || strcmp(brand, "Linux") != 0) return (EINVAL); + +recognized: if (itp) { if ((error = emul_find(p, NULL, linux_emul_path, itp, &bp, 0))) return (error); diff --git a/sys/compat/svr4/svr4_exec.c b/sys/compat/svr4/svr4_exec.c index 0f06a6ce105..d7b9cc55853 100644 --- a/sys/compat/svr4/svr4_exec.c +++ b/sys/compat/svr4/svr4_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_exec.c,v 1.15 2006/01/19 17:54:56 mickey Exp $ */ +/* $OpenBSD: svr4_exec.c,v 1.16 2008/06/12 04:32:59 miod Exp $ */ /* $NetBSD: svr4_exec.c,v 1.16 1995/10/14 20:24:20 christos Exp $ */ /* @@ -126,6 +126,9 @@ svr4_elf_probe(p, epp, itp, pos, os) int error; size_t len; + if (!(emul_svr4.e_flags & EMUL_ENABLED)) + return (ENOEXEC); + if (itp) { if ((error = emul_find(p, NULL, svr4_emul_path, itp, &bp, 0))) return (error); |