mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-05 19:21:05 +00:00
1bdda52fe9
This patch moves the vDSO setup from libc to loader code, just after the vDSO link_map setup. For static case the initialization is moved to _dl_non_dynamic_init instead. Instead of using the mangled pointer, the vDSO data is set as attribute_relro (on _rtld_global_ro for shared or _dl_vdso_* for static). It is read-only even with partial relro. It fixes BZ#24967 now that the vDSO pointer is setup earlier than malloc interposition is called. Also, vDSO calls should not be a problem for static dlopen as indicated by BZ#20802. The vDSO pointer would be zero-initialized and the syscall will be issued instead. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, s390x-linux-gnu, sparc64-linux-gnu, and sparcv9-linux-gnu. I also run some tests on mips. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
58 lines
2.1 KiB
C
58 lines
2.1 KiB
C
/* vDSO common definition for Linux.
|
|
Copyright (C) 2015-2020 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef SYSDEP_VDSO_LINUX_H
|
|
# define SYSDEP_VDSO_LINUX_H
|
|
|
|
#include <ldsodefs.h>
|
|
|
|
#ifndef INTERNAL_VSYSCALL_CALL
|
|
# define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
|
|
funcptr (args)
|
|
#endif
|
|
|
|
#define INLINE_VSYSCALL(name, nr, args...) \
|
|
({ \
|
|
__label__ out; \
|
|
__label__ iserr; \
|
|
INTERNAL_SYSCALL_DECL (sc_err); \
|
|
long int sc_ret; \
|
|
\
|
|
__typeof (GLRO(dl_vdso_##name)) vdsop = GLRO(dl_vdso_##name); \
|
|
if (vdsop != NULL) \
|
|
{ \
|
|
sc_ret = INTERNAL_VSYSCALL_CALL (vdsop, sc_err, nr, ##args); \
|
|
if (!INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
|
|
goto out; \
|
|
if (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err) != ENOSYS) \
|
|
goto iserr; \
|
|
} \
|
|
\
|
|
sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, ##args); \
|
|
if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
|
|
{ \
|
|
iserr: \
|
|
__set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
|
|
sc_ret = -1L; \
|
|
} \
|
|
out: \
|
|
sc_ret; \
|
|
})
|
|
|
|
#endif /* SYSDEP_VDSO_LINUX_H */
|