mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-14 06:12:01 +01:00
lib{c,sys}: move auxargs more firmly into libsys
Continue to filter the public interface (elf_aux_info()), but entierly
relocate the private interfaces (_elf_aux_info(),
__init_elf_aux_vector(), and __elf_aux_vector) to libsys.
This ensures that rtld updates the correct (only) copy of
__elf_aux_vector. After 968a18975a
updates were confused and __getosreldate was failing, causing
the system to fall back to compat compat12 syscalls in some cases.
Return to explicitly linking libc to libsys and link libthr with libc
and libsys (in that order).
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D43910
This commit is contained in:
parent
ef75877fc2
commit
99ea675731
@ -62,6 +62,7 @@ CFLAGS+= -ftls-model=initial-exec
|
||||
#
|
||||
LDFLAGS+= -nodefaultlibs
|
||||
LIBADD+= compiler_rt
|
||||
LIBADD+= sys
|
||||
|
||||
LDFLAGS+=-Wl,--auxiliary,libsys.so.7
|
||||
|
||||
|
@ -10,6 +10,7 @@ CFLAGS.h_raw+= -fstack-protector-all -Wstack-protector
|
||||
# override the sanitizer runtime libraries to be the ones installed on the
|
||||
# target system.
|
||||
CFLAGS.h_raw+= -fsanitize=bounds
|
||||
LIBADD+=sys
|
||||
.elif ${COMPILER_TYPE} == "gcc"
|
||||
CFLAGS.h_raw+= --param ssp-buffer-size=1
|
||||
LDADD+= -lssp
|
||||
|
@ -57,6 +57,9 @@ MDASM=
|
||||
MIASM=
|
||||
NOASM=
|
||||
|
||||
SYM_MAPS+= ${LIBSYS_SRCTOP}/Symbol.map
|
||||
SRCS+= auxv.c
|
||||
|
||||
.include "${LIBSYS_SRCTOP}/Makefile.sys"
|
||||
|
||||
SYM_MAPS+= ${LIBSYS_SRCTOP}/Symbol.thr.map
|
||||
|
@ -47,8 +47,6 @@ SRCS+= recv.c recvmmsg.c send.c sendmmsg.c
|
||||
NOASM+= sched_getcpu.o
|
||||
PSEUDO+= _sched_getcpu.o
|
||||
|
||||
SRCS+= auxv.c
|
||||
|
||||
SRCS+= brk.c
|
||||
SRCS+= closefrom.c
|
||||
SRCS+= pipe.c
|
||||
@ -58,6 +56,14 @@ SRCS+= POSIX2x_Fork.c
|
||||
|
||||
SRCS+= compat-stub.c
|
||||
|
||||
.if ${LIB} == "c"
|
||||
# Trapping stubs in dynamic libc to be filtered by libsys.
|
||||
SOBJS+= libc_stubs.pico
|
||||
|
||||
# Link the full implementation of ELF auxargs for static libc.
|
||||
STATICOBJS+= auxv.o
|
||||
.endif
|
||||
|
||||
INTERPOSED = \
|
||||
accept \
|
||||
accept4 \
|
||||
|
5
lib/libsys/Symbol.map
Normal file
5
lib/libsys/Symbol.map
Normal file
@ -0,0 +1,5 @@
|
||||
FBSDprivate_1.0 {
|
||||
__elf_aux_vector;
|
||||
__init_elf_aux_vector;
|
||||
_elf_aux_info;
|
||||
};
|
@ -433,12 +433,10 @@ FBSD_1.8 {
|
||||
|
||||
FBSDprivate_1.0 {
|
||||
/* Add entries in sort(1) order */
|
||||
__elf_aux_vector;
|
||||
__libc_sigwait;
|
||||
__libsys_interposing_slot;
|
||||
__set_error_selector;
|
||||
__sigwait;
|
||||
_elf_aux_info;
|
||||
gssd_syscall;
|
||||
nlm_syscall;
|
||||
rpctls_syscall;
|
||||
|
11
lib/libsys/libc_stubs.c
Normal file
11
lib/libsys/libc_stubs.c
Normal file
@ -0,0 +1,11 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (c) 2024 SRI International
|
||||
*/
|
||||
|
||||
#define STUB_FUNC(f) \
|
||||
void (f)(void); \
|
||||
void (f)(void) { __builtin_trap(); }
|
||||
|
||||
STUB_FUNC(elf_aux_info);
|
@ -7,6 +7,8 @@
|
||||
PACKAGE= clibs
|
||||
SHLIBDIR?= /lib
|
||||
|
||||
LIBADD= c sys
|
||||
|
||||
.include <src.opts.mk>
|
||||
MK_SSP= no
|
||||
|
||||
|
@ -174,7 +174,7 @@ LIBZFSBOOTENV?= ${LIBDESTDIR}${LIBDIR_BASE}/libzfsbootenv.a
|
||||
LIBZPOOL?= ${LIBDESTDIR}${LIBDIR_BASE}/libzpool.a
|
||||
LIBZUTIL?= ${LIBDESTDIR}${LIBDIR_BASE}/libzutil.a
|
||||
|
||||
# enforce the 2 -lpthread and -lc to always be the last in that exact order
|
||||
# enforce -lpthread, -lc, and -lsys to always be the last in that exact order
|
||||
.if defined(LDADD)
|
||||
.if ${LDADD:M-lpthread}
|
||||
LDADD:= ${LDADD:N-lpthread} -lpthread
|
||||
@ -182,6 +182,9 @@ LDADD:= ${LDADD:N-lpthread} -lpthread
|
||||
.if ${LDADD:M-lc}
|
||||
LDADD:= ${LDADD:N-lc} -lc
|
||||
.endif
|
||||
.if ${LDADD:M-lsys}
|
||||
LDADD:= ${LDADD:N-lsys} -lsys
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# Only do this for src builds.
|
||||
|
@ -394,7 +394,7 @@ _DP_xo= util
|
||||
_DP_ztest= geom m nvpair umem zpool pthread avl zfs_core spl zutil zfs uutil icp
|
||||
# The libc dependencies are not strictly needed but are defined to make the
|
||||
# assert happy.
|
||||
_DP_c= compiler_rt
|
||||
_DP_c= compiler_rt sys
|
||||
# Use libssp_nonshared only on i386 and power*. Other archs emit direct calls
|
||||
# to __stack_chk_fail, not __stack_chk_fail_local provided by libssp_nonshared.
|
||||
.if ${MK_SSP} != "no" && \
|
||||
@ -410,6 +410,10 @@ _DP_sys= compiler_rt
|
||||
(${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH:Mpower*} != "")
|
||||
_DP_sys+= ssp_nonshared
|
||||
.endif
|
||||
.if !defined(BOOTSTRAPPING)
|
||||
_DP_thr= c sys
|
||||
_DP_pthread= ${_DP_thr}
|
||||
.endif
|
||||
_DP_tacplus= md pam
|
||||
_DP_ncursesw= tinfow
|
||||
_DP_formw= ncursesw
|
||||
|
Loading…
Reference in New Issue
Block a user