Commit Graph

1953 Commits

Author SHA1 Message Date
Robert Clausecker
8983acc8de lib/libc/string: apply SSP hardening and tests to memset_explicit
Reviewed by:	emaste, kevans
Differential Revision:	https://reviews.freebsd.org/D47286
2024-11-14 23:10:00 +01:00
Robert Clausecker
007871c356 lib/libc/string: add memset_explicit() for compliance with C23
Patterned after explicit_bzero, visible from C23 onwards.

Reviewed by:	emaste, kevans
Differential Revision:	https://reviews.freebsd.org/D47286
2024-11-14 23:10:00 +01:00
Mark Johnston
5af09f50d7 include: Add required guards for dev/vmm headers
Reported by:	Jenkins
Fixes:		ebd48f1e52 ("include: Install dev/vmm headers")
2024-11-05 04:23:49 +00:00
Mark Johnston
ebd48f1e52 include: Install dev/vmm headers
In preparation for their use in libvmmapi.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D47029
2024-11-05 01:40:41 +00:00
Mark Johnston
a5d1cf5e36 rpc: Fix the definition of xdr_void()
xdr_void() should have type xdrproc_t, make it so.

PR:		280514
Reviewed by:	brooks, dim
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D47340
2024-10-30 19:27:18 +00:00
Simon J. Gerraty
a64729f507 Update Makefile.depend files
After building packages we have a number of new
and updated Makefile.depend files

Reviewed by:	stevek
2024-10-14 10:26:17 -07:00
Kirk McKusick
5b21d4ad06 Ensure that soft updates are not enabled by default when using mdmfs(8)
When soft updates began being enabled by default that change carried
over to mdmfs(8) which does not want or need them. This fix ensures
that they are only enabled in mdmfs(8) when requested with the -U flag.

Reported by: Ivan Rozhuk
Tested by:   Ivan Rozhuk
PR:          279308
MFC after:   1 week
2024-10-03 08:06:28 -07:00
Graham Percival
eb84c129d6 stdio.h: don't expose rsize_t unless __EXT1_VISIBLE
This is how the other typedefs for rsize_t handle it (in <stddef.h>,
<stdlib.h>, and <string.h>).  In particular, we shouldn't have any
rsize_t if a C environment earlier C11 was requested.

This reapplies b35f0aa495, chasing c25e55bcf8, fixing ports build
failures following b35f0aa495 without c25e55bcf8.

PR:		281768
Sponsored by:	Tarsnap Backup Inc.
Signed-off-by:	Graham Percival
2024-10-02 11:01:39 -07:00
Kyle Evans
c25e55bcf8 include: ssp: hide gets_s behind __EXT1_VISIBLE
These were supposed to match the visibility of the system's declaration,
but this one was overlooked.  Fix it now so that `rsize_t` can be hidden
appropriately.

Reported by:	Shawn Webb (and now others)
2024-10-02 12:47:55 -05:00
Cy Schubert
fe55d62ab9 Revert "stdio.h: don't expose rsize_t unless __EXT1_VISIBLE"
This change has caused a number of port build failures. Let's
revert this for now and request an exp-run.

This reverts commit b35f0aa495.
2024-10-02 08:51:56 -07:00
Graham Percival
b35f0aa495 stdio.h: don't expose rsize_t unless __EXT1_VISIBLE
PR:		281768
Fixes:		c13559d31e
MFC after:	1 week
2024-09-30 20:07:43 -07:00
Stefan Eßer
12e0d31664 vendor/bc: upgrade to version 7.0.0
This is a production release to fix three bugs, none of which
affects well formed scripts on FreeBSD:

The first bug is that bc/dc will exit on macOS when the terminal
is resized.

The second bug is that an array, which should only be a function
parameter, was accepted as part of larger expressions.

The third bug is that the value stack for dc was cleared on any error.
However, this is not how other dc behave. To bring dc more in line
with other implementations, this behavior was changed. This change is
why this version is a new major version.

(cherry picked from commit 54d20d67e2af28d948ce2df13feb039fa10900fc)

MFC after:	3 days
2024-08-26 18:27:29 +02:00
Kyle Evans
de866aa352 ssp: switch to _limits.h for the upper bound of size_t
The definitions in _stdint.h has some complications around visibility
that _limits.h does not have.  Switch to __SIZE_T_MAX to avoid those.

This fixes the devel/gperf, devel/glib20 and math/mpfr builds with
_FORTIFY_SOURCE enabled to unlock a large fraction of the ports tree to
build.

Reported by:	Shawn Webb (HardenedBSD)
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
2024-08-01 15:42:17 -05:00
Kyle Evans
9333e1cbd0 include: ssp: hide ppoll redirect behind __BSD_VISIBLE
This mirrors ppoll's visibility in sys/poll.h and fixes a build issue
with some _POSIX_C_SOURCE requests due to missing the sigset_t typedef.

Reported by:	eduardo
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
2024-07-30 11:36:58 -05:00
Ed Maste
5c2bc3db20 Remove "All Rights Reserved" from FreeBSD Foundation copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder.

Sponsored by:	The FreeBSD Foundation
2024-07-30 12:16:36 -04:00
Kyle Evans
9a3f7fb46c include: ssp: fix last bare inline
This was missed in b8730c11a3 ("include: ssp: fix the build [...]"),
but <ssp/wchar.h> also had a bare `inline` in use.  Swap it over to
__ssp_inline as well.

Reported by:	netchild
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
2024-07-20 23:17:55 -05:00
Kyle Evans
0c47b9c211 include: ssp: don't shadow the mempcpy builtin
GCC emits a warning about shadowing a builtin with our mempcpy
declaration, so switch it to using the same model as memcpy() and
use the apparently-existing __builtin___mempcpy_chk().

Reviewed by:	kib (earlier version), markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45976
2024-07-16 00:12:28 -05:00
Kyle Evans
b8730c11a3 include: ssp: fix the build with earlier C standards
`inline` isn't always a keyword, so we should be using __ssp_inline
as we do everywhere else in the _FORTIFY_SOURCE support.  Variable
declarations in a loop initializer are also not always supported, so
declare any loop vars in advance.

Reviewed by:	kib (earlier version), markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45976
2024-07-16 00:12:27 -05:00
Warner Losh
e9ac41698b Remove residual blank line at start of Makefile
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Kyle Evans
1f155d48f8 include: ssp: fortify <sys/socket.h>
The entire recv*() implementation set is ripe for opportunities to
validate, so do what we can with what we have.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45686
2024-07-13 00:16:26 -05:00
Kyle Evans
1ace24b30c include: ssp: fortify <sys/uio.h>
Check both the buffer size of the iov object itself, as well as that
of each indidvidually io base.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45684
2024-07-13 00:16:25 -05:00
Kyle Evans
062d9380b9 include: ssp: fortify <sys/random.h>
That is to say, fortify getrandom(2).

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45683
2024-07-13 00:16:25 -05:00
Kyle Evans
b53d7aa88f include: ssp: fortify <wchar.h>
This includes all of the w*() equivalents to str*()/mem*() implemented
in more or less the same way.  For these ones, we'll just use
header-only implementations from the start to stop further cluttering
the libc symbol table.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45682
2024-07-13 00:16:25 -05:00
Kyle Evans
d0b7445904 include: ssp: fortify <stdlib.h>
The immediately obvious and attractive targets from <stdlib.h> are
arc4random_buf(3) and realpath(3) -- scraping the header didn't reveal
much else of interest.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45681
2024-07-13 00:16:24 -05:00
Kyle Evans
88276dfbf1 include: ssp: fortify poll/ppoll from <poll.h>
For poll/ppoll we just need to bounds-check the poll array that we're
about to write out to.

Reviewed by:	kib, markj (earlier version)
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45680
2024-07-13 00:16:24 -05:00
Kyle Evans
cf8e5289a1 include: ssp: round out fortification of current set of headers
ssp/ssp.h needed some improvements:
 - `len` isn't always a size_t, it may need casted
 - In some cases we may want to use a len that isn't specified as a
    parameter (e.g., L_ctermid), so __ssp_redirect() should be more
    flexible.
 - In other cases we may want additional checking, so pull all of the
    declaration bits out of __ssp_redirect_raw() so that some functions
    can implement the body themselves.

strlcat/strlcpy should be the last of the fortified functions that get
their own __*_chk symbols, and these cases are only done to be
consistent with the rest of the str*() set.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45679
2024-07-13 00:16:24 -05:00
Kyle Evans
c10d567ea0 include: de-macro __ssp_overlap(), improve semantics and checking
Switch away from pointer arithmetic to provide more obvious semantics
for checking overlap on pointer ranges.  This lets us remove some casts
that need not exist and removes some possible fragility in its use.

While we're here, check for overflow just in case; sometimes we use a
caller-supplied size if __builtin_object_size(3) can't deduce the buffer
size, and we should fail the check if the size is nonsensical for the
provided buffers.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
2024-07-13 00:16:23 -05:00
Kyle Evans
4719366192 libc: move __ssp_overlap back out into <ssp/ssp.h>
We'll be using it in some upcoming definitions in headers, so move it
back now but slap a warning on it.  Our upcoming uses will all be inside
of inline functions, so we're not overly concerned about double
evaluation immediately.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45677
2024-07-13 00:16:23 -05:00
Warner Losh
4a86b26b84 stdlib: Support compiling with tinyc by omitting compat qsort code
TinyC doesn't support the .symver assembler directive. Add a generic way
to signal this and use that not to define __sym_() macros that use
it. Only use the __sym_* macros in headers when they are defined (which
currently is only for the qsort_r compat code. Not supporting this for
tcc is fine: It's an edge case for legacy binaries / code anyway which
isn't relevant to tinyc.

Sponsored by:		Netflix
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D45651
2024-06-21 09:53:07 -06:00
Brooks Davis
39c4f65c72 stddef.h/stdlib.h: Remove unused rune_t
This non-standard type is unused in the base system (__ct_rune_t or
__rune_t are used instead) and ports.  It has been around as long as our
current source repo, but we have avoided using it.  In sys/_types.h
where the __*rune_t typedefs are defined, the following appears in a
comment:

    NOTE: rune_t is not covered by ANSI nor other standards, and should
    not be instantiated outside of lib/libc/locale.  Use wchar_t.

The definition of this unused type meant we gratutiously differed from
standards compliant stddef.h/stdlib.h.

PR:		279357 (exp-run by antoine)

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D45426
2024-06-02 19:41:22 +01:00
Kyle Evans
5af6fbd727 ssp: appease -Wgnu-statement-expression-from-macro-expansion
It's a stupid warning, but some ports enable it by default and were
already defining _FORTIFY_SOURCE, thus exposing the new macros
immediately.  This at least fixes the libfido2 build, perhaps others as
well.

While we're here, fix a fresh build of stand w/ FORTIFY_SOURCE enabled
by not pulling in the ssp headers if _STANDALONE is defined.  We do not
have runtime support in libsa as of the time of writing.

Reported by:	netchild
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
2024-05-14 18:22:18 -05:00
Kyle Evans
0ed58ac88a include: ssp: kill off leftover $FreeBSD$ tag
Most of these were fixed when rebasing the patch forward, but this one
seems to have been missed.

Reported by:	marck
Fixes:	be04fec426 ("Import _FORTIFY_SOURCE implementation [...]")
2024-05-13 17:45:55 -05:00
Kyle Evans
8b0682644e Fix the GCC build after _FORTIFY_SOURCE import
We haven't exposed gets(3) in a long time, rip out __gets_chk before
it's too late and something builds a gets(3) user with it enabled.
2024-05-13 11:21:38 -05:00
Kyle Evans
9bfd3b4076 Add a build knob for _FORTIFY_SOURCE
In the future, we will Default to _FORTIFY_SOURCE=2 if SSP is enabled,
otherwise default to _FORTIFY_SOURCE=0.  For now we default it to 0
unconditionally to ease bisect across older versions without the new
symbols, and we'll put out a call for testing.

include/*.h include their ssp/*.h equivalents as needed based on the
knob. Programs and users are allowed to override FORTIFY_SOURCE in their
Makefiles or src.conf/make.conf to force it off.

Reviewed by:	des, markj
Relnotes:	yes
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32308
2024-05-13 00:23:50 -05:00
Kyle Evans
e55512504d Prepare the system for _FORTIFY_SOURCE
Notably:
- libc needs to #undef some of the macros from ssp/* for underlying
  implementations
- ssp/* wants a __RENAME() macro (snatched more or less from NetBSD)

There's some extra hinkiness included for read(), since libc spells it
as "_read" while the rest of the world spells it "read."

Reviewed by:	imp, ngie
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32307
2024-05-13 00:23:50 -05:00
Kyle Evans
be04fec426 Import _FORTIFY_SOURCE implementation from NetBSD
This is a mostly-unmodified copy of the various *_chk implementations
and headers from NetBSD, without yet modifying system headers to start
actually including them.  A future commit will also apply the needed
bits to fix ssp/unistd.h.

Reviewed by:	imp, pauamma_gundo.com (both previous versions), kib
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32306
2024-05-13 00:23:49 -05:00
Alexander Ziaee
5ccaab1797 sysexits: Tidy deprecated header and manual
<sysexits.h> was deprecated in the base system in a1432b4 for FreeBSD
8.0 and is retained only for backwards compatibility.  Make that clear,
since sysexits(3) suggested using it since it was in style(9) prior
to this.

MFC after:	1 week
Co-authored-by:	imp
Fixes:		a1432b4
Reviewed by:	imp, pauamma (previous version)
Pull Request	https://github.com/freebsd/freebsd-src/pull/1195
2024-05-09 20:50:48 -06:00
Poul-Henning Kamp
14b475c479 Remove gbde support from swapon(8) 2024-05-07 07:21:46 +00:00
Warner Losh
1314d14c32 endian.h: Define uint{16,32,64}_t
The Draft Posix Issue 8 standard requires that these be defined. Define
them in the usual way that lets multiple headers define them. Opted to
not just use #include <stdint.h>, allowed by the draft, to be
conservative. Add notes about how we comply with Issue 8, and that we've
opted to define these only as macros, though the standard allows
functions, macros or both.

Sponsored by:		Netflix
2024-05-06 10:43:14 -06:00
John Baldwin
70e5a9ea78 nvmf: Install nvmf.h and nvmf_proto.h in /usr/include/dev/nvmf
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44707
2024-05-02 16:27:30 -07:00
Konstantin Belousov
220aa0f450 libthr: add pthread_sigqueue(3)
PR:	278459
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44867
2024-04-23 19:51:22 +03:00
Elyes Haouas
5e2a419256 include: Remove repeated words
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/887
2024-04-11 11:53:36 -06:00
Stephen J. Kiernan
41956c13f9 include: Ensure security/audit/audit.h gets staged properly.
There is a conflict between bsm/audit.h and security/audit/audit.h due
to the way that staging is being set up using .PATH to point to the
full directory and the leaf files being specified in the list. Due to
this, the bsm/audit.h was getting staged as both bsm/audit.h and
security/audit/audit.h since the sys/bsm directory is listed first in
the .PATH list.

Use sys/security in the .PATH instead of sys/security/audit and specify
the audit header files as audit/<name>.h. This ensures that we get the
correct audit.h stanged for security/audit/audit.h.

Reviewed by:	sjg
Obtained from:	Juniper Networks, Inc.
2024-04-03 20:26:33 -04:00
Stephen J. Kiernan
f6e77cb8c1 include: Allow SDESTDIR to be overridden
Obtained from:	Juniper Networks, Inc.
Reviewed by:	sjg
Differential Revision:	https://reviews.freebsd.org/D44540
2024-03-27 19:18:43 -04:00
Warner Losh
a34940a975 timezone: Move to the XSI/POSIX definition for timezone.
The old timezone(3) function has long since been obsolete and has a
fatally flawed interface. Retain this function for compatibility
purposes, but shift to providing the offset from UTC in the timezone
variable, whether or not the timezone observes summer time in the
'daylight' variable. Document the tzname variable that's already been
set. Also make _tztab() static. It's not used in libc (or anywhere in
the tree) and it's not exported as a public dynamic symbol.

Sponsored by:		Netflix
Reviewed by:		brooks, kib
Differential Revision:	https://reviews.freebsd.org/D44281
2024-03-11 22:19:31 -06:00
Konstantin Belousov
822042fdfc posix_spawn(3): add POSIX_SPAWN_DISABLE_ASLR_NP
similar to Apple _POSIX_SPAWN_DISABLE_ASLR

Reviewed by:	emaste, kevans
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44195
2024-03-04 03:00:38 +02:00
Gordon Bergling
8f87d402e3 dumprestore.h: Fix typos in source code comments
- s/dumpped/dumped/

MFC after:	3 days
2024-02-27 13:49:21 +01:00
Warner Losh
d56a6f0516 stdlib.h: Partially revert c27a899718
quick_exit() can call other functions, and we don't guarantee it calls
std::terminate should those other functions throw exceptions. And to
make it do so has ABI complications for libc. Until that's sorted out,
revert this noexcept (but leave a comment behind so people will find
this commit message)

Requested by:		kib

Sponsored by:		Netflix
2024-02-02 12:11:50 -07:00
Lexi Winter
c27a899718 stdlib.h: add __noexcept to prototypes
The noexcept specifier is required on these functions in C++:
_Exit(), atexit(), quick_exit(), at_quick_exit(), abort().

MFC after:	2 weeks

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1085
2024-02-02 11:11:17 -07:00
Ed Maste
fbd156d78f Revert "nl_types.h: explicitly include cdefs.h"
This isn't the right approach for addressing this cross-build issue.

This reverts commit 820401bf17.
2024-01-24 22:50:49 -05:00