summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2012-05-08 14:32:02 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2012-05-08 14:32:02 +0000
commit8385ca12ee0d3c5d5645a10859e58a130ac44893 (patch)
tree81a08b3c58ae85ad769f63afa6d72fb52d04de0c /libexec
parentde5b58e5c86c2904247fc25e56831ca184a68889 (diff)
Refuse to load ELF objects that contain a PT_TLS program header.
Otherwise the binary assumes that the requested TLS storage has been allocated and will happily use it, resulting in unwanted memory corruption. ok guenther@
Diffstat (limited to 'libexec')
-rw-r--r--libexec/ld.so/library.c8
-rw-r--r--libexec/ld.so/library_mquery.c8
-rw-r--r--libexec/ld.so/loader.c7
3 files changed, 20 insertions, 3 deletions
diff --git a/libexec/ld.so/library.c b/libexec/ld.so/library.c
index a927ae1c560..f4800b7f478 100644
--- a/libexec/ld.so/library.c
+++ b/libexec/ld.so/library.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library.c,v 1.64 2012/01/09 17:01:22 ariane Exp $ */
+/* $OpenBSD: library.c,v 1.65 2012/05/08 14:32:01 jsing Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -146,6 +146,12 @@ _dl_tryload_shlib(const char *libname, int type, int flags)
case PT_DYNAMIC:
dynp = (Elf_Dyn *)phdp->p_vaddr;
break;
+ case PT_TLS:
+ _dl_printf("%s: unsupported TLS program header in %s\n",
+ _dl_progname, libname);
+ _dl_close(libfile);
+ _dl_errno = DL_CANT_LOAD_OBJ;
+ return(0);
default:
break;
}
diff --git a/libexec/ld.so/library_mquery.c b/libexec/ld.so/library_mquery.c
index 08e4d7075c4..a396200b1c3 100644
--- a/libexec/ld.so/library_mquery.c
+++ b/libexec/ld.so/library_mquery.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: library_mquery.c,v 1.40 2012/01/09 17:01:22 ariane Exp $ */
+/* $OpenBSD: library_mquery.c,v 1.41 2012/05/08 14:32:01 jsing Exp $ */
/*
* Copyright (c) 2002 Dale Rahn
@@ -184,6 +184,12 @@ _dl_tryload_shlib(const char *libname, int type, int flags)
case PT_DYNAMIC:
dynp = (Elf_Dyn *)phdp->p_vaddr;
break;
+ case PT_TLS:
+ _dl_printf("%s: unsupported TLS program header in %s\n",
+ _dl_progname, libname);
+ _dl_close(libfile);
+ _dl_errno = DL_CANT_LOAD_OBJ;
+ return(0);
default:
break;
}
diff --git a/libexec/ld.so/loader.c b/libexec/ld.so/loader.c
index a67b901fb9b..264595f807b 100644
--- a/libexec/ld.so/loader.c
+++ b/libexec/ld.so/loader.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: loader.c,v 1.127 2012/01/08 19:44:34 kettenis Exp $ */
+/* $OpenBSD: loader.c,v 1.128 2012/05/08 14:32:01 jsing Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -486,6 +486,11 @@ _dl_boot(const char **argv, char **envp, const long dyn_loff, long *dl_data)
prebind_load_exe(phdp, exe_obj);
}
break;
+ case PT_TLS:
+ _dl_printf("%s: unsupported TLS program header\n",
+ _dl_progname);
+ _dl_exit(1);
+ break;
}
phdp++;
}