NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PR/60858 CVS commit: [netbsd-11] src



The following reply was made to PR lib/60858; it has been noted by GNATS.

From: "Martin Husemann" <martin%netbsd.org@localhost>
To: gnats-bugs%gnats.NetBSD.org@localhost
Cc: 
Subject: PR/60858 CVS commit: [netbsd-11] src
Date: Tue, 17 Nov 2026 15:54:43 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Tue Nov 17 15:54:43 UTC 2026
 
 Modified Files:
 	src/include/ssp [netbsd-11]: ssp.h
 	src/lib/libc/ssp [netbsd-11]: ssp_redirect.c
 	src/share/mk [netbsd-11]: bsd.own.mk
 	src/sys/arch/amd64/conf [netbsd-11]: Makefile.amd64
 	src/sys/arch/amd64/include [netbsd-11]: Makefile.inc
 	src/sys/arch/i386/conf [netbsd-11]: Makefile.i386
 	src/sys/arch/i386/include [netbsd-11]: Makefile.inc
 	src/sys/arch/sparc64/conf [netbsd-11]: Makefile.sparc64
 	src/sys/arch/xen/conf [netbsd-11]: Makefile.xen
 	src/sys/conf [netbsd-11]: ssp.mk
 
 Log Message:
 Pull up following revision(s) (requested by riastradh in ticket #579):
 
 	include/ssp/ssp.h: revision 1.17
 	share/mk/bsd.own.mk: revision 1.1488
 	share/mk/bsd.own.mk: revision 1.1489
 	sys/arch/sparc64/conf/Makefile.sparc64: revision 1.87
 	lib/libc/ssp/ssp_redirect.c: revision 1.4
 	sys/arch/amd64/conf/Makefile.amd64: revision 1.87
 	sys/conf/ssp.mk: revision 1.6
 	sys/conf/ssp.mk: revision 1.7
 	sys/arch/amd64/include/Makefile.inc: revision 1.6
 	sys/arch/xen/conf/Makefile.xen: revision 1.51
 	sys/arch/i386/include/Makefile.inc: revision 1.4
 	sys/arch/i386/conf/Makefile.i386: revision 1.198
 
 ssp.h: Stop creating references to useless __ssp_protected_* symbols.
 
 The ssp wrappers are useful _only_ when they are actually used for
 inline function call expansion; if the function is used for anything
 else like a function pointer, only the underlying library symbol
 should be used.
 
 To pacify linker complaints about spurious references to
 __ssp_protected_getcwd/read/readlink, we added equally spurious
 definitions of those symbols to libc without understanding why; it
 turns out it only happened because the ssp wrappers declared, e.g.:
 extern inline read(...) __RENAME(__ssp_protected_read);
 extern inline read(...) { <ssp check>; return __ssp_real_read(...); }
 
 The declaration with __RENAME caused the compiler to generate
 references, required by the linker to be resolved, to the symbol
 `__ssp_protected_read' when compiling code that takes the address of
 the function read() to pass around a function pointer.  Instead, the
 generated code should simply have a reference to the symbol `read',
 which is what we achieve by deleting that declaration.
 
 Now that the declaration is gone, we also need to redo the useless
 ssp_redirect.c so that the getcwd/read/readlink definitions are
 preceded by the appropriate prototypes.  Rather than try to integrate
 it into the ssp.h macrology, it is simpler to just define these three
 wrappers explicitly here because the pattern has no value to
 generalize; leave comments exhorting the reader never to extend it.
 
 We can't simply delete the symbols, though, because programs built
 against NetBSD 11 may rely on them (they won't _use_ the symbols in
 code, but the ELF files might have symbol references that have to be
 resolved).
 
 PR lib/60858: fortuitous embarrassment: fortify is all kinds of busted
 
 bsd.own.mk: Respect USE_FORT even if defined after bsd.own.mk.
 
 Using (a chain of logic that boils down to)
 
 .if ${USE_FORT:Uno} != "no"
 CPPFLAGS+=      -D_FORTIFY_SOURCE=2
 .endif
 
 expands USE_FORT eagerly, so if USE_FORT was not already defined before
 including <bsd.own.mk>, it's too late after.
 
 Using (a chain of logic that boils down to)
 
 CPPFLAGS+=      ${${USE_FORT:Uno} != "no":?-D_FORTIFY_SOURCE=2:}
 
 expands USE_FORT lazily, so it's only when CPPFLAGS itself is expanded
 -- usually in a recipe, after all variable assignments, prerequisite
 lists, and .directives have been processed -- that USE_FORT is
 expanded.
 
 This way, all of the Makefiles that do
 
 .include <bsd.own.mk>
 USE_FORT?=      yes
 
 will actually get fortify as intended!
 
 PR lib/60858: fortuitous embarrassment: fortify is all kinds of busted
 
 sys: Fix USE_SSP?=yes settings in amd64, i386, and sparc64 makefiles.
 
 This was recently broken by the change in bsd.own.mk rev. 1.1488 to
 fix USE_FORT?=yes after bsd.own.mk in userland makefiles, which
 worked by unconditionally adding a conditional definition of USE_SSP
 based on lazy expansion of USE_FORT, instead of conditionally adding
 a conditional definition of USE_SSP based on eager expansion of
 USE_FORT (confused yet?):
 
 -.if ... ${USE_FORT:Uno} != "no" ...
 -USE_SSP?=      yes
 -.endif
 +USE_SSP?=      ${... ${USE_FORT:Uno} != "no" ...:?yes:no}
 
 This isolated (ha) change to bsd.own.mk saved the trouble of editing
 dozens of userland makefiles to ensure that USE_FORT is defined
 before bsd.own.mk -- and the trouble of adding diagnostics to detect
 the mistake should it rear its head again.  And it solved the problem
 systematically for userland.
 
 Unfortunately, the ordering of includes and definitions in the kernel
 and module makefiles is a little different.  To save the trouble of
 rearranging them, we just have the kernel makefiles where SSP is on
 by default say so by defining USE_SSP_DEFAULT=yes, which is picked up
 by the new:
 
 +USE_SSP?=      ${... ${USE_FORT:Uno} ...:?yes:no}
 +USE_SSP?=      ${... ${USE_FORT:Uno} ...:?yes:${USE_SSP_DEFAULT:Uno}}
 
 This mechanism still allows kernel configs to specify
 
 makeoptions     USE_SSP="no"
 
 to override the architecture default, e.g. in i386 GENERIC_TINY.
 
 In sys/conf/ssp.mk, change ${USE_SSP:Uno} to ${USE_SSP} so that if,
 somehow, we lose the definition of USE_SSP, make(1) will fail noisily
 rather than silently.
 
 PR lib/60858: fortuitous embarrassment: fortify is all kinds of busted
 
 sys/conf/ssp.mk: Conditionalize use of USE_SSP on HAVE_SSP=yes.
 
 Fixes the following failure after my previous change from
 ${USE_SSP:Uno} to ${USE_SSP} here so that make(1) would detect
 failure to define USE_SSP -- which it did, for alpha, hppa, and ia64:
 
 nbmake: /home/riastradh/netbsd/current/src/sys/conf/ssp.mk:3: Variable "USE_SSP" is undefined
         in /home/riastradh/netbsd/current/src/sys/conf/Makefile.kern.inc:397
         in /home/riastradh/netbsd/current/obj.hppa/sys/arch/hppa/compile/GENERIC/Makefile:1333
 nbmake: Fatal errors encountered -- cannot continue
 nbmake: stopped making "depend" in /home/riastradh/netbsd/current/obj.hppa/sys/arch/hppa/compile/GENERIC
 
 PR lib/60858: fortuitous embarrassment: fortify is all kinds of busted
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.16 -r1.16.4.1 src/include/ssp/ssp.h
 cvs rdiff -u -r1.3 -r1.3.4.1 src/lib/libc/ssp/ssp_redirect.c
 cvs rdiff -u -r1.1428.2.4 -r1.1428.2.5 src/share/mk/bsd.own.mk
 cvs rdiff -u -r1.86 -r1.86.8.1 src/sys/arch/amd64/conf/Makefile.amd64
 cvs rdiff -u -r1.5 -r1.5.58.1 src/sys/arch/amd64/include/Makefile.inc
 cvs rdiff -u -r1.197 -r1.197.8.1 src/sys/arch/i386/conf/Makefile.i386
 cvs rdiff -u -r1.3 -r1.3.58.1 src/sys/arch/i386/include/Makefile.inc
 cvs rdiff -u -r1.85 -r1.85.38.1 src/sys/arch/sparc64/conf/Makefile.sparc64
 cvs rdiff -u -r1.50 -r1.50.28.1 src/sys/arch/xen/conf/Makefile.xen
 cvs rdiff -u -r1.5 -r1.5.32.1 src/sys/conf/ssp.mk
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 



Home | Main Index | Thread Index | Old Index