From owner-svn-src-all@FreeBSD.ORG Mon Jan 5 01:06:56 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 654A9AFA; Mon, 5 Jan 2015 01:06:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 51ED933F6; Mon, 5 Jan 2015 01:06:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0516uRj072116; Mon, 5 Jan 2015 01:06:56 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0516tEM072111; Mon, 5 Jan 2015 01:06:55 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201501050106.t0516tEM072111@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 5 Jan 2015 01:06:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r276681 - in head/lib: libc/include libc/sys libthr/thread X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2015 01:06:56 -0000 Author: kib Date: Mon Jan 5 01:06:54 2015 New Revision: 276681 URL: https://svnweb.freebsd.org/changeset/base/276681 Log: 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 Modified: head/lib/libc/include/libc_private.h head/lib/libc/sys/Symbol.map head/lib/libc/sys/__error.c head/lib/libthr/thread/thr_private.h head/lib/libthr/thread/thr_syscalls.c Modified: head/lib/libc/include/libc_private.h ============================================================================== --- head/lib/libc/include/libc_private.h Mon Jan 5 01:05:35 2015 (r276680) +++ head/lib/libc/include/libc_private.h Mon Jan 5 01:06:54 2015 (r276681) @@ -173,13 +173,13 @@ typedef pthread_func_t pthread_func_entr 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, Modified: head/lib/libc/sys/Symbol.map ============================================================================== --- head/lib/libc/sys/Symbol.map Mon Jan 5 01:05:35 2015 (r276680) +++ head/lib/libc/sys/Symbol.map Mon Jan 5 01:06:54 2015 (r276681) @@ -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; Modified: head/lib/libc/sys/__error.c ============================================================================== --- head/lib/libc/sys/__error.c Mon Jan 5 01:05:35 2015 (r276680) +++ head/lib/libc/sys/__error.c Mon Jan 5 01:06:54 2015 (r276681) @@ -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) Modified: head/lib/libthr/thread/thr_private.h ============================================================================== --- head/lib/libthr/thread/thr_private.h Mon Jan 5 01:05:35 2015 (r276680) +++ head/lib/libthr/thread/thr_private.h Mon Jan 5 01:06:54 2015 (r276681) @@ -914,7 +914,7 @@ void _thr_tsd_unload(struct dl_phdr_info void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden; void _thr_stack_fix_protection(struct pthread *thrd); -int *__error_threaded(void); +int *__error_threaded(void) __hidden; void __thr_interpose_libc(void) __hidden; pid_t __thr_fork(void); int __thr_pause(void) __hidden; Modified: head/lib/libthr/thread/thr_syscalls.c ============================================================================== --- head/lib/libthr/thread/thr_syscalls.c Mon Jan 5 01:05:35 2015 (r276680) +++ head/lib/libthr/thread/thr_syscalls.c Mon Jan 5 01:06:54 2015 (r276681) @@ -692,7 +692,7 @@ void __thr_interpose_libc(void) { - __error_selector = __error_threaded; + __set_error_selector(__error_threaded); #define SLOT(name) \ *(__libc_interposing_slot(INTERPOS_##name)) = \ (interpos_func_t)__thr_##name;