Commit graph

1942 commits

Author SHA1 Message Date
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
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, amd64, amd64) (push) Waiting to run
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
Val Packett 820401bf17 nl_types.h: explicitly include cdefs.h
This file uses __BEGIN_DECLS/__END_DECLS. When bootstrapping from
Linux/musl, they were missing.

Sponsored by:	https://www.patreon.com/valpackett
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1066
2024-01-24 16:59:18 -05:00
Konstantin Belousov 211bdd601e Add kcmp(2) userspace bits
Unlike Linux, we do provide libc wrapper.  All definitions and
prototypes are available from <unistd.h>

Tested by:	manu
Reviewed by:	brooks, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D43518
2024-01-24 07:11:26 +02:00
Jan Beich 58cf91d3b7 resolv: Add a required include to resolv.h
Add a required include to resolv.h for sockaddr_in.  This should reduce
patching required when porting code written with Linux or NetBSD in mind.

PR:		182466
MFC after:	1 week
2024-01-08 20:52:08 +09:00
Brooks Davis 8ccd0b876e libc: expose execvpe for Linux compat
We already implemented execvpe internally with an _ prefix in libc so
go ahead and expose it for compatibility with Linux.

This reverts c605eea952.

Bump __FreeBSD_version for the addition and add definitions to supress
compat shims in libzfs (zfs changes were merged from upstream).

PR:		275370 (request and exp-run (thanks antoine!))
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42846
2023-12-11 19:24:53 +00:00
Jose Luis Duran dff3a80f6d endian.h: Remove duplicate words
Reviewed by:	emaste
Pull Request:	https://github.com/freebsd/freebsd-src/pull/920
2023-12-10 12:40:57 -05:00
Warner Losh 33ccf36671 include: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:23:59 -07:00
Warner Losh 5b31cc94b1 sccs: Manual changes
For the uncommon items: Go through the tree and remove sccs tags that
didn't fit any nice pattern. If in the neighborhood, other SCM tags were
removed when they were detritis of long-ago CVS somehow in the early
mists of the project. Some adjacent copyrights stringswere removed (they
duplicated the copyright notices in the file). This also removed
non-standard formations of omission of SCCS tags (usually by adding an
extra #if 0 somewhere.

After this commit, a number of strings tagged with the 'what' @(#)
prefix remain, but they are primarily copyright notices.

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh 5a1d14419a include: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:28 -07:00
Ka Ho Ng d030761168 dirdeps: Update/fix Makefile.depend* for toolchain
This fixes make pseudo/toolchain.
2023-11-26 20:50:13 -05:00
Alan Somers 24938f9311 lib/libc/rpc: switch the per-fd structs in clnt_{dg,vc}.c to RB Trees
This saves oodles of memory, especially when "ulimit -n" is large.  It
also prevents a buffer overflow if getrlimit should fail.

Also replace per-fd condvars with mutexes to simplify the code.

PR:		274968
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42597
2023-11-15 16:12:50 -07:00
John Baldwin f53355131f Trim various $FreeBSD$
Approved by:	markj (cddl/contrib changes)
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41961
2023-10-10 10:34:43 -07:00