1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

Prepare some build fixes in advance of more _FORTIFY_SOURCE

ZFS' libspl needs to be made aware that we have strlcat(3) and
strlcpy(3) to avoid some more complicated declaration duplication, so
go ahead and define these HAVE_ macros now.

libprocstat has to define `_KERNEL` and include kernel headers in order
to get what it wants, but this results in sys/cdefs.h being included too
late and we pick up the build breaking version of the __RENAME
definition.  Just explicitly include sys/cdefs.h earlier rather than
disabling _FORTIFY_SOURCE.  The zfs/ subdir only builds an object that
holds some structures and sizes, so just disable _FORTIFY_SOURCE there
entirely rather than trying to move #define _KERNEL into the file..

While we're here, make sure that we disable _FORTIFY_SOURCE in the
bootloader because we don't have the symbol renaming support today to do
it as cleanly as we'd like.  ssp/ssp.h needs to be pulled into the libsa
environment so that other bits can understand that ssp is disabled in
the consistent __SSP_FORTIFY_LEVEL way that we try to do.

Reviewed by:	allanjude (previous version), markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45676
This commit is contained in:
Kyle Evans 2024-07-13 00:16:09 -05:00
parent 9b505845a3
commit 41c233dec6
8 changed files with 11 additions and 4 deletions

View File

@ -5,6 +5,7 @@ OPENSOLARIS_SYS_DISTDIR= ${.CURDIR}/../../../sys/cddl/contrib/opensolaris
IGNORE_PRAGMA= YES
CFLAGS+= -DNEED_SOLARIS_BOOLEAN
CFLAGS+= -DHAVE_STRLCAT -DHAVE_STRLCPY
# Do not lint the CDDL stuff. It is all externally maintained and
# lint output is wasteful noise here.

View File

@ -61,7 +61,7 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzfs
CFLAGS+= -I${SRCTOP}/sys
CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
CFLAGS+= -DHAVE_ISSETUGID
CFLAGS+= -DHAVE_ISSETUGID -DHAVE_STRLCAT -DHAVE_STRLCPY
CFLAGS.be.c= -Wno-cast-qual
CFLAGS.be_access.c= -Wno-cast-qual
CFLAGS.be_error.c= -Wno-cast-qual

View File

@ -24,7 +24,7 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd
CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
CFLAGS+= -DHAVE_ISSETUGID -DHAVE_BOOLEAN
CFLAGS+= -DHAVE_ISSETUGID -DHAVE_BOOLEAN -DHAVE_STRLCAT -DHAVE_STRLCPY
CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libctf/common \
-I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common \
-I${SRCTOP}/sys/cddl/compat/opensolaris

View File

@ -26,6 +26,8 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h> /* __RENAME */
#include <stdbool.h>
#include <sys/param.h>

View File

@ -5,6 +5,7 @@ SRCS= zfs_defs.c
OBJS= zfs_defs.o
WARNS?= 1
FORTIFY_SOURCE= 0
CFLAGS+= -DIN_BASE -D__KERNEL__ -D_KERNEL -I. -I${.CURDIR}
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include

View File

@ -22,7 +22,7 @@ CFLAGS+= -I${SRCTOP}/sys
CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include
CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include
CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h
CFLAGS+= -DHAVE_ISSETUGID
CFLAGS+= -DHAVE_ISSETUGID -DHAVE_STRLCAT -DHAVE_STRLCPY
CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h
HAS_TESTS= yes

View File

@ -2,6 +2,8 @@
.if !defined(__BOOT_DEFS_MK__)
__BOOT_DEFS_MK__=${MFILE}
FORTIFY_SOURCE= 0
# We need to define all the MK_ options before including src.opts.mk
# because it includes bsd.own.mk which needs the right MK_ values,
# espeically MK_CTF.

View File

@ -195,7 +195,7 @@ MAN=libsa.3
# Create a subset of includes that are safe, as well as adjusting those that aren't
# The lists may drive people nuts, but they are explicitly opt-in
FAKE_DIRS=xlocale arpa
FAKE_DIRS=xlocale arpa ssp
SAFE_INCS=a.out.h assert.h elf.h inttypes.h limits.h nlist.h setjmp.h stddef.h stdbool.h string.h strings.h time.h unistd.h uuid.h
STAND_H_INC=ctype.h fcntl.h signal.h stdio.h stdlib.h
OTHER_INC=stdarg.h errno.h stdint.h
@ -210,6 +210,7 @@ beforedepend:
ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \
ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
ln -sf ${SRCTOP}/include/ssp/ssp.h ssp/ssp.h; \
for i in _time.h _strings.h _string.h; do \
[ -f xlocale/$$i ] || :> xlocale/$$i; \
done; \