summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-01-05 01:06:54 +0000
committerkib <kib@FreeBSD.org>2015-01-05 01:06:54 +0000
commit6b2710fe565e79b8b3f78ae193d1b68ab1a90bf2 (patch)
treeae1060e14ffc1f7203b630e4e1e7624871ab2ce0 /lib/libc
parentdd81221ce677c9962a2192db095b25098af8a656 (diff)
downloadFreeBSD-src-6b2710fe565e79b8b3f78ae193d1b68ab1a90bf2.zip
FreeBSD-src-6b2710fe565e79b8b3f78ae193d1b68ab1a90bf2.tar.gz
Avoid calling internal libc function through PLT or accessing data
though GOT, by staticizing and hiding. Add setter for __error_selector to hide it as well. Suggested and reviewed by: jilles Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/include/libc_private.h4
-rw-r--r--lib/libc/sys/Symbol.map3
-rw-r--r--lib/libc/sys/__error.c14
3 files changed, 14 insertions, 7 deletions
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index adf342d..ea1a97b 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -173,13 +173,13 @@ typedef pthread_func_t pthread_func_entry_t[2];
extern pthread_func_entry_t __thr_jtable[];
-extern int *(*__error_selector)(void);
+void __set_error_selector(int *(*arg)(void));
int _pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
void *(calloc_cb)(__size_t, __size_t));
typedef int (*interpos_func_t)(void);
interpos_func_t *__libc_interposing_slot(int interposno);
-extern interpos_func_t __libc_interposing[];
+extern interpos_func_t __libc_interposing[] __hidden;
enum {
INTERPOS_accept,
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
index 7d82361..f1f57ba 100644
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -1045,8 +1045,7 @@ FBSDprivate_1.0 {
__sys_write;
_writev;
__sys_writev;
- __error_unthreaded;
- __error_selector;
+ __set_error_selector;
nlm_syscall;
gssd_syscall;
__libc_interposing_slot;
diff --git a/lib/libc/sys/__error.c b/lib/libc/sys/__error.c
index 329d124..28cc31d 100644
--- a/lib/libc/sys/__error.c
+++ b/lib/libc/sys/__error.c
@@ -32,13 +32,21 @@ __FBSDID("$FreeBSD$");
extern int errno;
-int *
+static int *
__error_unthreaded(void)
{
- return(&errno);
+
+ return (&errno);
}
-int *(*__error_selector)(void) = __error_unthreaded;
+static int *(*__error_selector)(void) = __error_unthreaded;
+
+void
+__set_error_selector(int *(*arg)(void))
+{
+
+ __error_selector = arg;
+}
int *
__error(void)
OpenPOWER on IntegriCloud