Commit Graph

1916 Commits

Author SHA1 Message Date
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
Alexander V. Chernikov
2cef62886d pf: convert state retrieval to netlink
Use netlink to export pf's state table.

The primary motivation is to improve how we deal with very large state
stables. With the previous implementation we had to build the entire
list (both in the kernel and in userspace) before we could start
processing. With netlink we start to get data in userspace while the
kernel is still generating more. This reduces peak memory consumption
(which can get to the GB range once we hit millions of states).

Netlink also makes future extension easier, in that we can easily add
fields to the state export without breaking userspace. In that regard
it's similar to an nvlist-based approach, except that it also deals
with transport to userspace and that it performs significantly better
than nvlists. Testing has failed to measure a performance difference
between the previous struct-copy based ioctl and the netlink approach.

Differential Revision:	https://reviews.freebsd.org/D38888
2023-10-10 11:48:21 +02:00
Warner Losh
5d51862412 Restrict the glibc compat cookie open functions to __BSD_VISIBLE
Sponsored by:		Netflix
2023-09-17 09:11:57 -06:00
Doug Rabson
78847e1e59 pkgbase: Move headers and libs out of runtime and utilities
Headers from src/include were in the runtime-dev package but
subdirectories of src/include ended up in utilities-dev by default.
Neither package is a good choice - the headers in src/include are not
useful without the libraries contained in clibs-dev.

This moves the standard C headers to clibs-dev (C++ headers are already
in this package). While working on this, I found that various clang
libraries and headers were also bundled into utilities-dev by default
so these are also moved to clang-dev.

I also added a FreeBSD-build-essential meta package to make it simple to
install all the toolchain parts.

PR:		254173
Reviewed byb:	manu
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D41815
2023-09-12 13:22:21 +01:00
Dag-Erling Smørgrav
e6615b1034 include: Implement N2867.
This adds macros for checked addition, subtraction, and multiplication with semantics similar to the builtins gcc and clang have had for years.

Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D41734
2023-09-07 06:40:14 +00:00
Dag-Erling Smørgrav
8091b82e29 time.h: Fix visibility check for C11 and C23 features.
__BSD_VISIBLE is always defined; we need to check if it's true.

Fixes:		d02489d11a 9b5d724cad
MFC after:	3 days
Reviewed by:	brooks, imp
Differential Revision:	https://reviews.freebsd.org/D41733
2023-09-06 03:38:01 +02:00
Simon J. Gerraty
1554ba03b6 Add mac_grantbylabel
This module allows controlled privilege escallation via mac labels
securely associated with a process via mac_veriexec.

There are over 700 PRIV_* but we can compress many of them into
a single GBL_* thus constraining the size of gbl labels.

The goal is to allow a daemon to run as an unprivileged process while
still being able a set of privileged operations needed.

We add APIs to libveriexec so that userland processes can check labels
and an exec_script API that allows a suitably labeled process to run
something like a python interpreter directly if necessary;
overcomming the 'indirect' flag applied to the interpreter.

Add -l option to sbin/veriexec to report labels.

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D41431
2023-08-24 17:42:11 -07:00
Dag-Erling Smørgrav
9b5d724cad libc: Add timespec_getres(3) as per C23.
This also adds support for TIME_MONOTONIC to timespec_get(3).

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D41524
2023-08-24 21:31:54 +00:00
Warner Losh
9524e274b5 Remove $FreeBSD$: one-line xdr pattern
Remove /^\s*%\s*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:55:47 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh
42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Mike Karels
d5d97bed4a arm64 lib32: prepare arm64 headers to redirect to arm
In order to compile lib32 libraries and other 32-bit code on arm64,
<machine/foo.h> needs to be redirected to an arm header rather
than arm64 when building with -m32.  Ifdef the arm64 headers that
are installed in /usr/include/machine and used by user-level software
(including references from /usr/include/*.h) so that if __arm__ is
defined when including the arm64 version, <arm/foo.h> is included
rather than using the rest of the file's contents.  Some arm headers
had no arm64 equivalent; headers were added just to do the redirection.
These files use #error if __arm__ is not defined to guard against
confusion.  Also add an include/arm Makefile, and modify Makefiles
as needed to install everything, including the arm files in
/usr/include/arm.  fenv.h comes from lib/msun/arm/fenv.h.

The new arm64 headers are:
    acle-compat.h
    cpuinfo.h
    sysreg.h

Reviewed by:	jrtc27, imp
Differential Revision:	https://reviews.freebsd.org/D40944
2023-07-25 18:59:26 -05:00
Jessica Clarke
d3748fc0c2 include: Migrate from COMPAT_32BIT to generic COMPAT_libcompat
See commit 8fad2cda93 ("bsd.compat.mk: Provide new CPP and sub-make
variables") for the context behind this change.

Reviewed by:	emaste, brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D40924
2023-07-09 18:48:54 +01:00
Jessica Clarke
be01082b86 elf-hints.h: Allow rtld_paths.h to be included before it
Currently rtld_paths.h will #undef _PATH_ELF_HINTS in order to override
this to the right value if included afterwards, but the other way round
does not work as elf-hints.h tries to define an already-defined macro to
a potentially different value. Thus, guard the definition here so that
rtld_paths.h's definition continues to take precedence.

Note that, although all in-tree uses of _PATH_ELF_HINTS have included
rtld_paths.h already, pax-utils wants _PATH_ELF_HINTS from elf-hints.h
and so we cannot just drop the define. In-tree uses must just continue
to make sure that they include rtld_paths.h to get the right value for
libcompat builds as is already required.

Reviewed by:	kib, brooks, jhb, imp
Differential Revision:	https://reviews.freebsd.org/D40918
2023-07-09 18:45:42 +01:00
John Baldwin
1aaa8f670a nvme: Don't install nvme_private.h in /usr/include.
Reviewed by:	chuck, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D40394
2023-06-26 20:30:45 -07:00
Warner Losh
eebd9d5366 spdx: Simplify BSD-2-Clause AND BSD-2-Clause
After removing the -FreeBSD and -NetBSD, we're left with a nuber of
BSD-2-Clause AND BSD-2-Clause, so tidy that up.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh
b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Ed Maste
b6271cc0d0 includes: avoid installing if_wg.h twice
if_wg.h was installed via dev/wg in LSUBDIRS and also explicitly.  We
want to install only wg/if_wg.h not the other headers, so add dev/wg to
the skip list in the copies and symlinks targets.

PR:		271266
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40031
2023-05-09 21:09:39 -04:00
Hans Petter Selasky
bb8e8e230d Revert "libc: Implement bsort(3) a bitonic type of sorting algorithm."
Some points for the future:
 - libc is not the right place for sorting algorithms.
   Probably libutil is better suited for this purpose or
   a dedicated libsort. Should move all sorting algorithms
   away from libc eventually.
 - CheriBSD uses capabilities for memory access, and could
   benefit from a standard memswap() function.
 - Do something about qsort() in FreeBSD's libc like:
   - Mark it deprecated on FreeBSD, as a first step,
     due to missing limits on CPU time.
   - Audit the use of qsort() in the FreeBSD base system
     and consider swapping to other existing sorting
     algorithms.

Discussed with:	brooks@

Differential Revision:	https://reviews.freebsd.org/D36493

This reverts commit a7469c9c0a.
This reverts commit 7d65a450cd.
This reverts commit 8dcf3a82c5.
2023-04-20 19:16:14 +02:00
Hans Petter Selasky
a7469c9c0a libc: bsort_s() requires both __BSD_VISIBLE and __EXT1_VISIBLE
Fixes build of Python:
/usr/include/stdlib.h:409:1: error: unknown type name 'errno_t'
errno_t  bsort_s(void *, rsize_t, rsize_t,

Reported by:	vishwin@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
Differential Revision:	https://reviews.freebsd.org/D36493
2023-04-19 22:12:04 +02:00
Brooks Davis
1a2249ff0b include: add a check-ldirs target
This target ensures all LDIRS, LSUBDIRS, and LSUBSUBDIRS actually exist.

Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D39006
2023-04-19 16:58:06 +01:00
Hans Petter Selasky
8dcf3a82c5 libc: Implement bsort(3) a bitonic type of sorting algorithm.
The bsort(3) algorithm works by swapping objects, similarly to qsort(3),
and does not require any significant amount of additional memory.

The bsort(3) algorithm doesn't suffer from the processing time issues
known the plague the qsort(3) family of algorithms, and is bounded by
a complexity of O(log2(N) * log2(N) * N), where N is the number of
elements in the sorting array. The additional complexity compared to
mergesort(3) is a fair tradeoff in situations where no memory may
be allocated.

The bsort(3) APIs are identical to those of qsort(3), allowing for
easy drop-in and testing.

The design of the bsort(3) algorithm allows for future parallell CPU
execution when sorting arrays. The current version of the bsort(3)
algorithm is single threaded. This is possible because fixed areas
of the sorting data is compared at a time, and can easily be divided
among different CPU's to sort large arrays faster.

Reviewed by:	gbe@, delphij@, pauamma_gundo.com (manpages)
Sponsored by:	NVIDIA Networking
Differential Revision:	https://reviews.freebsd.org/D36493
2023-04-19 14:04:22 +02:00
Simon J. Gerraty
d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Val Packett
f9c7fb7cae arpa: garbage collect ns_newmsg/ns_rdata decls
These were brought in by the libbind import, but these functions were
never actually implemented anywhere, only header declarations and symbol
map entries were imported.

Fixes: 046c3635cd ("Bring final version of libbind:")
Fixes: e45764721a ("Update our stub resolver to final version of ...")
Reported by:	ld.lld 16 being --no-undefined-version by default
Sponsored by:	https://www.patreon.com/valpackett
Reviewed by:	emaste
Pull request:	https://github.com/freebsd/freebsd-src/pull/700
Differential Revision: https://reviews.freebsd.org/D38407
2023-03-22 14:58:23 -04:00