Commit graph

24605 commits

Author SHA1 Message Date
Brooks Davis 304cdac738 lib{c,sys}: expose _getlogin consistently
Historically we exposed _getlogin as a private symbol on a per-arch basis
(except on aarch64 and riscv) for no obvious reason.  We now need to
expose it for libc's use so remove the special case from
makesyscalls.lua and expose it in the generated syscalls.map.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44116
2024-02-29 19:46:33 +00:00
Brooks Davis 6d3f4dcda2 libsys: make PSEUDO take a bare syscall name
Rather than having PSEUDO be a list of object files when all consumers
want syscall names or source files, make it a list of bare syscall
names like INTERPOSED (which is built on PSEUDO).

Improve document of variables developers can set.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44108
2024-02-29 19:19:01 +00:00
Brooks Davis f102db5028 libsys: consolidate PSEUDO definitions
Consolidate in preparation for further cleanup.

Also relocate the sole NOASM entry.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44107
2024-02-29 19:19:01 +00:00
Brooks Davis e52a9177d9 libsys: reduce makefile declaration duplication
Every PSEUDO entry (_foo.o) has a corresponding NOASM entry (foo.o) to
suppress its addition to ASM.  Check PSEUDO instead when adding entries
to ASM.  No functional change.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44106
2024-02-29 19:19:01 +00:00
Brooks Davis 882d9f4507 lib{c,sys}: expose cap_sandboxed from libc/gen
It's a thin wrapper on cap_getmode() implemented in libc, not a system
call so the symbol should have been exposed by libc/gen/Symbol.map
alongside the implementation.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44110
2024-02-28 23:39:55 +00:00
Kristof Provost 706d465dae pf: convert kill/clear state to use netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D44090
2024-02-28 23:26:18 +01:00
Emmanuel Vadot 5acbe6d1fb pam_xdg: Reset rv to 0
Otherwise on success it ontain the return value of asprintf.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Fixes:		2d2950c889 ("pam_xdg: Check asprintf return value")
2024-02-27 08:06:02 +01:00
Emmanuel Vadot 2d2950c889 pam_xdg: Check asprintf return value
Reported by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Fixes:          6e69612d5d ("pam: Add pam_xdg module")
2024-02-27 07:42:47 +01:00
Emmanuel Vadot 84329908c5 pam_xdg: Remove leftover debug printf
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Fixes:		6e69612d5d ("pam: Add pam_xdg module")
2024-02-27 07:42:47 +01:00
Emmanuel Vadot 6b9e6f12e5 pam: Always use pam_xdg for session and xdm
This ensure that the XDG_RUNTIME_DIR is always created and the environment
variable is present which is a must for any wayland user (at least).
The only "cost" of it is a directory is created and unused.

Reviewed by:	des
Differential Revision:	https://reviews.freebsd.org/D44012
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-02-26 18:35:22 +01:00
Emmanuel Vadot 6e69612d5d pam: Add pam_xdg module
This is a module to setup the XDG directories and environment variables.
For now the only usage is to have a XDG_RUNTIME_DIR environment setup at
user login.
All other environment variable have a default fallback so no need to export
them in this module.
The directory is created according to the XDG Base directory specification.

The default base directory is /var/run/xdg/<username> but can be configured
using the runtime_dir=<dir> module option.

According to the spec the directory *must* not survive a reboot so adding
var_run_enable="YES" to rc.conf is highly recommanded.

Reviewed by:	des, pauamma (manpages)
Differential Revision:	https://reviews.freebsd.org/D44011
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2024-02-26 18:34:52 +01:00
Xin LI 8db56defa7 MFV: xz 5.6.0.
MFC after:	2 weeks
2024-02-25 15:46:22 -08:00
Konstantin Belousov 32fdcff870 libc/sys: add errno test
Despite looking trivial, it requires proper split of exports from libsys
and libc, proper filtering work in rtld, and operational libsys.

Reviewed by:	emaste, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44075
2024-02-25 22:35:17 +02:00
Brooks Davis c5698afcd5 libsys: remove duplicate, commented out code 2024-02-23 22:25:35 +00:00
Konstantin Belousov 7d233b2220 libsys: fix sleep(3)/usleep(3) cancel behavior
Move functions back to libc/gen sources; they are only versioned from
libc and not libsys.
Access libsys interposing slots using __libsys_interposing_slot()
instead of direct __libsys_interposing array dereference, which cannot
work from libc.

Reported by:	glebius
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D44042
2024-02-23 19:39:44 +02:00
Konstantin Belousov baa7d0741b libsys: link symbolic
so that libc/libthr do not preempt libsys symbols, esp. errno-related.

The issue is, if libsys is linked with DT_BIND_NOW flag, and then loaded
as filter, rtld tries to relocate its PLT symbols immediately, not as
filter.  There, during symbol lookup, rtld finds filtering symbols in
libc, and since libc is in loading filters mode, the resolution stops
there.  The end result is that libsys links to libc.

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D44027
2024-02-23 19:39:42 +02:00
Konstantin Belousov 2f4cbf459d libsys auxv.c: add fences needed to ensure that flag works
Noted by:	jrtc27
Sponsored by:	The FreeBSD Foundation
2024-02-21 16:18:10 +02:00
Warner Losh 1edb7116f4 bearssl: Make shared library link
Creating a lua shared library module linking against libbearssl.so won't
load w/o these functions.

Sponsored by:		Netflix
Reviewed by:		sjg
Differential Revision:	https://reviews.freebsd.org/D43982
2024-02-20 20:31:41 -07:00
Konstantin Belousov 3668e1fa0a libsys: disable ssp
Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Konstantin Belousov fe920a4f2f libsys: move errno to libsys
Before, the 'errno' itself was defined in libc and was referenced by
libsys, causing undesired dependency.

Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Konstantin Belousov 8271d9b99a libsys: remove usage of pthread_once and _once_stub
that existed in auxv.c, use simple bool gate instead. This leaves a
small window if two threads try to call _elf_aux_info(3) simultaneously.
The situation is safe because auxv parsing is really idempotent. The
parsed data is the same, and we store atomic types (int/long/ptr) so
double-init does not matter.

Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Konstantin Belousov af9758deff libsys: internalize memcpy, memset, and strlcpy
Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D43985
2024-02-21 02:26:11 +02:00
Brooks Davis eb90239d08 lib{c,thr}: add DT_RUNPATH for gcc -m32
To allow gcc -m32 to work, link libc and libthr with --rpath-/usr/lib32.
When called with -m32, gcc is currently unable to communicate to
the bfd linker that it should look in /usr/lib32 to resolve needed (as
opposed to explicitly linked) libraries so we need to provide a hint.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=31395

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43910
2024-02-19 22:44:08 +00:00
Brooks Davis 99ea675731 lib{c,sys}: move auxargs more firmly into libsys
Continue to filter the public interface (elf_aux_info()), but entierly
relocate the private interfaces (_elf_aux_info(),
__init_elf_aux_vector(), and __elf_aux_vector) to libsys.

This ensures that rtld updates the correct (only) copy of
__elf_aux_vector.  After 968a18975a
updates were confused and __getosreldate was failing, causing
the system to fall back to compat compat12 syscalls in some cases.

Return to explicitly linking libc to libsys and link libthr with libc
and libsys (in that order).

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43910
2024-02-19 22:44:08 +00:00
Xin LI 4543ef5166 MFV: expat 2.6.0.
MFC after:	3 days
2024-02-17 14:04:14 -08:00
Xin LI 345cf360f8 Vendor import of expat 2.6.0 2024-02-17 13:54:42 -08:00
Dimitry Andric 73ff7384e0 Optionally create full debuginfo for llvm-related executables
Commit de6feefdb7 limited the amount of debuginfo generated for clang
and other llvm-related executables. This was done to save disk space and
memory during building, but it makes debugging any of these executables
much harder.

Add a new src.conf(5) setting, WITH_LLVM_FULL_DEBUGINFO, to generate
full debuginfo instead. This is off by default, but could for example be
enabled for release builds or snapshots, so llvm executables are easier
to debug.

Reviewed by:	emaste
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43839
2024-02-17 00:15:32 +01:00
Maxim Konovalov 1250c96479 fclose.3: remove a confusing sentence
PR:		277037
Reviewed by:	oshogbo
2024-02-16 18:50:12 +00:00
Warner Losh f7781d030c flua: Add hash module
Add lua bindings to hashing functions. sha256 is available. sha256.new
craetes a new object. sha256.update updates the digest. sha256.digest
returns the digest as a binary string and resets the
context. sha256.hexdigest returns the digest as a string of hex digits
and then resets the cotnext.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43872
2024-02-15 20:59:23 -07:00
Ed Maste 3733d82c4d libcasper: fix cap_rights_init usage
Capability rights passed to cap_rights_* are not simple bitmaks and
cannot be ORed together in general (although it will work for certain
subsets of rights).

PR:		277057
Fixes:		faaf43b2a7 ("fileargs: add tests")
Sponsored by:	The FreeBSD Foundation
2024-02-14 22:33:24 -05:00
Cy Schubert b76ef9a7cb unbound: Vendor import 1.19.1
Release notes at
    https://www.nlnetlabs.nl/news/2024/Feb/13/unbound-1.19.1-released/

Security:	CVE-2023-50387, CVE-2023-50868
MFC after:	3 days
2024-02-13 21:05:50 -08:00
Dag-Erling Smørgrav 46c599340f Update tzcode to 2024a.
MFC after:	3 weeks
Sponsored by:	Klara, Inc.
2024-02-13 21:31:41 +01:00
Ting-Hsuan Huang 2a3a8eb9fa
libusb(3): Fix link in comment
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1042
2024-02-13 16:55:54 +08:00
Cheng-Yuan Wu 38b7eebc4a
libbsdstat: Fix typo in bsdstat.h
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1040
2024-02-13 16:53:35 +08:00
Cheng-Yuan Wu f446c9482c
libbe(3): Fix typo and grammar
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1039
2024-02-13 16:52:35 +08:00
Cheng-Hsun Lin 1d479bf6b4
gjournal(8): standardize capitalization for consistency
Event:		Advanced UNIX Programming Course (Fall'23) at NTHU
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1017
2024-02-13 16:09:35 +08:00
Assume-Zhan eb8ba6fb74
rpc: Fix typo in comment
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/995
2024-02-13 14:20:45 +08:00
Simon J. Gerraty f616d61ab6 libsecureboot do not report expected unverified files
By default only report unverified files at severity VE_WANT
and above.  This inlcudes *.conf but not *.hints, *.cookie
or *.tgz which get VE_TRY as their severity.

If Verbose is set to 0, then VerifyFlags should default to 0 too.
Thus the combination of

	module_verbose=0
	VE_VEBOSE=0

is sufficient to make the loader almost totally silent.

When verify_prep has to find_manifest and it is verified ok
return VE_NOT_CHECKED to verify_file so that it can skip
repeating verify_fd

Also add better debugging output for is_verified and add_verify_status.

vectx handle compressed modules

When verifying a compressed module (.ko.gz or .ko.bz2)
stat() reports the size as -1 (unknown).
vectx_lseek needs to spot this during closing - and just read until
EOF is hit.

Note: because of the way libsa's open() works, verify_prep will see
the path to be verified as module.ko not module.ko.bz2 etc.  This is
actually ok, because we need a separate module.ko.bz2 entry so that
the package can be verified, and the hash for module.ko is of the
uncompressed file which is what vectx will see.

Re-work local.trust.mk so site.trust.mk need only set
VE_SIGN_URL_LIST (if using the mentioned signing server)

interp.c: restrict interactive input

Apply the same restrictions to interactive input as for
unverified conf and hints files.

Use version.veriexec when LOADER_VERIEXEC is yes

Reviewed by:	kevans
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43810
2024-02-12 14:35:01 -08:00
Christos Margiolis 53c768e683 mixer(3): Do not hardcode "/dev/mixer"
We have BASEPATH defined.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D43812
2024-02-12 13:00:05 +02:00
Dimitry Andric d9c0e2e166 Revert "Build clang and other llvm executables as PIE"
This reverts commit 470f9f13de.

I need more time to figure out how to make this work correctly with
incremental builds, which it currently miserably fails on.
2024-02-12 10:27:00 +01:00
Dimitry Andric 470f9f13de Build clang and other llvm executables as PIE
There is no reason anymore to not build these as PIE. Unfortunately
bsd.lib.mk does not allow for building _only_ PIE static libraries, so
lib/clang/Makefile.inc needs a kludge to work around that issue.

MFC after:	1 week
2024-02-11 19:01:56 +01:00
Konstantin Belousov a52cb4c480 Document aio_read2/aio_write2
Reviewed by:	jhb
Discussed with:	asomers
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43448
2024-02-11 03:54:16 +02:00
Konstantin Belousov 8dfc788b84 aio_read2/aio_write2: add AIO_OP2_VECTORED
Suggested by:	Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43448
2024-02-11 03:54:11 +02:00
Konstantin Belousov 06cb1c3f95 libc: add aio_read2() and aio_write2() functions
as wrappers around lio_listio(LIO_READ/WRITE | LIO_FOFFSET, &iocb, 1);

Suggested and reviewed by:	jhb
Discussed with:	asomers
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differrential revision:	https://reviews.freebsd.org/D43448
2024-02-11 03:54:00 +02:00
Konstantin Belousov e4b7bbd6ab lio_listio(2): add LIO_FOFFSET flag to ignore aiocb aio_offset
and use the current file offset instead.

Requested by:	Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com>
Reviewed by:	jhb
Discussed with:	asomers
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43448
2024-02-11 03:53:50 +02:00
Konstantin Belousov 3e9515846f read.2: Describe debug.iosize_max_clamp
same as it is done for write.2.

PR:	276937
Reported by:	bugs.freebsd.org@masklinn.net
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-02-10 11:43:29 +02:00
Brooks Davis 1995ea1ea2 libsys: add guards to MD manpages
This avoids duplicate installations which fail packaging tests.

Reported by:	emaste
2024-02-09 17:22:13 +00:00
Brooks Davis d5677b0b8b libsys: actually install manpages
In initial hacking I'd bluntly disabled manpage installation in libsys,
then later disabled them for libc, but forgot to fix the former leading
to no syscall manapages.

PR:		276887
Reported by:	Martin Birgmeier <d8zNeCFG@aon.at>
2024-02-08 19:53:29 +00:00
Brooks Davis cc697d22c4 libsys: move some missed manpages
Fixes:	29d079c964 - libsys: move __libsys_interposer consumers
2024-02-08 19:50:32 +00:00
Brooks Davis 49d684369c libthr: filter rather than link with libsys
The allows gcc + GNU ld to link programs with -m32 -pthread without
erroring out due to _umtx_op_err being undefined (unless -lsys is added
to the link command.

We now always link _umtx_op_err into libthr (not just when it's static)
and filter it with libsys so we call that implementation.  The dynamic
implementations (at least the assembly ones) should likely become stubs
as a further refinement.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43783
2024-02-07 19:50:47 +00:00
Brooks Davis 49076f376a libc: don't directly link libsys
It is sufficent to add it as a filter.

Reported by:	kib
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43781
2024-02-07 19:50:47 +00:00
Brooks Davis 57ddfad884 lib/libc: version auxiliary libsys.so
We need to use libsys.so.7 so that we can work without /usr and because
we're bound a specific ABI.

Reported by:	jtrc27, kib
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43772
2024-02-07 00:47:04 +00:00
Brooks Davis 11f9745c5b libsys: fix powerpcspe build
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43771
2024-02-07 00:47:03 +00:00
Piotr Pawel Stefaniak 12bae251fb libcompat: silence -Wdeprecated-non-prototype
by removing unnecessary re-declarations and converting K&R-style
function definitions.

Differential Revision:	https://reviews.freebsd.org/D43723
Reviewed by:	imp, emaste
2024-02-06 20:32:46 +01:00
Brooks Davis 8d2e8f7205 libc: make syscall stubs empty for shared lib
They are always replaced by libsys so just make them empty.  In
https://reviews.freebsd.org/D14609 x86 variants call abort2, but that
requires per-arch assembly and should be of low value in the steady
state.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:57 +00:00
Brooks Davis f217772244 SYS.h: make _SYSCALL_BODY overridable
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 0d4f7723bc libc: link libsys as a auxiliary filter library
At runtime, when rtld loads libc it will also load libsys.  For each
symbol that is present in both, the libsys one will override the libc
one.  It continues to be the case that program need only link against
libc (usually implicitly).  The linkage to libsys is automatic.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis ef9871c620 libthr: move _umtx_op_err() to libsys
Declare in sys/umtx.h and implement in libsys.  Explicitly link libthr
with libsys.

When building libthr static include _umtx_op_err so we don't break static
linkage with -lpthread.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis e9d961055a libsys: plumb in to build
libsys provides the FreeBSD kernel interface (auxargs, system calls,
vdso).  It can be linked directly for programs using a non-standard
libc and will later be linked as a filter library to libc providing
the actual system call implementation.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 86deddfacb libsys: generate private symbol map
We now export all _ and __sys_ prefixed syscalls stubs from libc and
libsys so that libsys can replace them.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 10f1b536ad libc: move __getosreldate to libsys
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis f70c5a0925 libc: move getpagesize(s) to libsys
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 4c33415e4c libc: elf auxiliary vector handling to libsys
This is part of the interface to the kernel and some syscall wrappers
depend on it so move it there.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 81245a77f0 libc: compile _once in libsys
auxv support requires _once(), but we don't want the libsys version
stomping on the libc version should they diverge in the future.  We
could rename it entierly, but for now just hook it in via Makefile.sys.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 1e2502bfca libc: move MD sys related symbols to libsys
This is a mix genuine MD interfaces and compat symbols like _getlogin.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis cdecda8da3 libc: move rfork_thread(3) to libsys
rfork_thread(3) is assembly that makes syscalls directly and uses
cerror so it belongs in libsys.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:56 +00:00
Brooks Davis 31a46e2cc8 libc: Move per-arch sys/Makefile.inc to libsys
libc/<arch>/sys/Makefile.inc -> libsys/<arch>/Makefile.sys.

Require that libsys/<arch>/Makefile.sys exist.  At least for current
archtiectures, it's not possible for an architecture to not have and MD
syscall bits.

powerpcspe/Makefile.sys's structure means it had to be modified when moved
so rename detection won't work, but it has trivial contents so the
history is unimportant.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 19149b03b1 libc: remove .PATH refs to libc/<arch>/sys
There are no longer any source files here so remove references.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 4bc66c0f9f libc: remove remaining x86 sys bits to libsys
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 0d6cc87b18 libc: libc/<arch>/sys/__vdso_gettc -> libsys/<arch>/
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 84dd0c080b libc: libc/gen/sched_getcpu_gen.c -> libsys/
It is a trivial system call wrapper.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 29d079c964 libsys: move __libsys_interposer consumers
These system call wrappers call interposed system calls in fairly
trivial ways.  Move them over to libsys so all __libsys_interposer
consumers end up in libsys.

Also move recvmmsg and sendmmsg as they are documented with recv and
send.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 8f529310bd libc: libc/sys/Makefile.inc -> libsys/Makefile.sys
Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 8269e7673c libsys: relocate implementations and manpages
Remove core system call implementations and documentation to lib/libsys
and lib/libsys/<arch> from lib/libc/sys and lib/libc/<arch>/<sys>.
Update paths to allow libc to find them in their new home.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 228d8c9efe libc: split libc and syscall interposing (2/2)
Move the __libc_interposing implementation to libc/gen so it doesn't end
up in libsys.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Brooks Davis 9cbd96582c libc: split libc and syscall interposing (1/2)
System calls or their wrappers are now interposed by
__libsys_interposing with purely libc entries remaining in
__libc_interposing.

Use __libsys_interposing_slot in libthr to update __libsys_interposing,
but also make __libc_interposing_slot fall back to
__libsys_interposing_slot so an out of date libc has a chance of working
during updates.

Reviewed by:	kib, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
2024-02-05 20:34:55 +00:00
Mark Johnston dfabf3efaa libjail: Guard against programmer error in jailparam_export()
If the caller didn't use jailparam_import() to fetch the parameter
value, an attempt to export it will trigger a segfault.  Make it a bit
easier to figure out what's happening in this situation.

PR:		276809
Reviewed by:	jamie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43732
2024-02-04 17:52:30 -05:00
Hodong a03f768612 libstdthreads: destroy mutexattr in mtx_init()
PR:	276818
MFC after:	1 week
2024-02-04 13:50:56 +02:00
Minsoo Choo 6bd60e15b1 libc: Specify parameter types for function pointer
Reviewed by:	dab
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43726
2024-02-03 20:08:59 -05:00
Martin Oliveira 4309f9f234 include/math.h: fix warning with -Wconversion
The way the __fp_type_select macro uses the _Generic expression causes
gcc to throw a warning on valid code if the -Wconversion flag is used.

For example, consider the following program:

    #include <math.h>
    int main()
    {
    	double x = 1.0;
    	isnan(x);
    	return 0;
    }

which throws a warning:

    $ gcc -Wconversion a.c
    a.c:5:15: warning: conversion from 'double' to 'float' may change value [-Wfloat-conversion]
        5 |         isnan(x);
          |               ^

This happens because the functions are invoked inside of the _Generic.
Looking at the example of _Generic in the C11 specification, one sees
that the parameters are outside of the _Generic expression (see page 79
here: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf).

Reference: https://stackoverflow.com/a/68309379
Signed-off-by: Martin Oliveira <martin.oliveira@eideticom.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/841
2024-02-02 21:05:49 -07:00
rilysh fb3dc55a5c lib/libfetch/common.c: remove an extra semicolon
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/959
2024-02-02 18:35:02 -07:00
rilysh b139f2ee99 lib/libbe/be.c: remove an extra semicolon
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/959
2024-02-02 18:35:02 -07:00
rilysh e9b261f297 lib/libvgl/main.c: remove an extra semicolon
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/959
2024-02-02 18:35:01 -07:00
Jose Luis Duran 05ad376bfc libc: Fix typo (triple M)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/963
2024-02-02 18:35:00 -07:00
Lexi Winter 5590bacaaf sctp: update manpages
Add missing documentation for sctp_sendv(3) and sctp_recvv(3).

Add a note that sctp_send(3), sctp_sendx(3) and sctp_recvmsg(3) are
deprecated by RFC 6458.

Add a STANDARDS section to all functions specified in RFC 6458 to
indicate their standards conformance.

MFC after:	2 weeks
Reviewed by: imp, bcr, kp, tuexen
Pull Request: https://github.com/freebsd/freebsd-src/pull/965
2024-02-02 18:35:00 -07:00
Corinna Vinschen 619f455b8f regex: fix freeing g->charjump in low memory condition
computejumps() moves g->charjump to a position relativ to the value of
CHAR_MIN.  As such, g->charjump doesn't necessarily point to the address
actually allocated.  While regfree() takes that into account, the low
memory handling in regcomp_internal() doesn't.  Fix that by free'ing
the actually allocated address, as in regfree().

MFC After: 2 weeks
Reviewed by: imp,jrtc27
Pull Request: https://github.com/freebsd/freebsd-src/pull/692
2024-02-02 11:51:54 -07:00
Brooks Davis 0e867a4911 aarch/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43058
2024-02-02 17:08:55 +00:00
Kristof Provost 306d3fb23d libpfct: fix incorrect array check
Reported by:	Coverity Scan
CID:		1523771
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-02-02 17:55:16 +01:00
Kristof Provost 777a4702c5 pf: implement addrule via netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-02-02 17:55:16 +01:00
Mark Johnston 36f0a34ca6 libthr: Force the thr_wake() symbol to be resolved during initialization
Otherwise the lock upgrade performed by rtld's load_filtees() can result
in infinite recursion, wherein:
1. _rtld_bind() acquires the bind read lock,
2. the source DSO's filtees haven't been loaded yet, so the lock upgrade
   in load_filtees() cause rtld to jump to _rtld_bind() and release the
   bind lock,
3. _thr_rtld_lock_release() calls _thr_ast(), which calls thr_wake(),
   which hasn't been resolved yet,
4. _rtld_bind() acquires the bind read lock in order to resolve
   thr_wake(),
5. ...

See the linked pull request for an instance of this problem arising with
libsys.  That particular instance is also worked around by commit
e7951d0b04.

Reported by:	brooks
Reviewed by:	kib
Pull Request:	https://github.com/freebsd/freebsd-src/pull/908
MFC after:	1 week
Sponsored by:	Innovate UK
2024-02-02 10:32:30 -05:00
Ed Maste ed3563b0ac csu: add crtbrand.o dependency on sys/param.h
__FreeBSD_version is recorded in *crt1.o and crti.o via crtbrand.o.  Add
an explicit dependency to pick up __FreeBSD_version bumps.

Additional changes are required to fully plumb *crt1.o dependencies
through the build.

Reported by:	bapt
Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43417
2024-01-31 15:40:27 -05:00
Olivier Certner c7e645269f
login_cap.h: Remove LOGIN_DEFPRI
This is an implementation detail which is likely to become irrelevant in
the future, as we move to not resetting the priority if the
corresponding capability is not present in the configuration file
('/etc/login.conf').

GitHub's code search and Google show no use of this public constant, and
it doesn't exist in OpenBSD and NetBSD.

So, remove this definition and its sole use in-tree.

PR:                     276570 (exp-run)
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43609
2024-01-29 22:58:10 +01:00
Olivier Certner e3a396eb2a
login_cap.h: Remove LOGIN_DEFUMASK
This public constant has not been used in-tree since 1997 (this was
noticed while working on previous commit "setusercontext(): umask: Set
it only once (in the common case)").

Since it was an implementation detail and GitHub's code search and
Google show no use of this symbol today, simply remove it.

PR:                     276570 (exp-run)
Reviewed by:            emaste, kib (earlier version, then part of D40344)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43608
2024-01-29 22:58:10 +01:00
Olivier Certner f2a0277d3e
setusercontext(): Set priority from '~/.login_conf' as well
Setting the process priority is done only when the current process'
effective UID corresponds to that for which context is to be set.
Consequently, setting priority is done with appropriate credentials and
will fail if the target user tries to raise it unduly via his
'~/.login_conf'.

PR:                     271751
Reviewed by:            kib, Andrew Gierth <andrew_tao173.riddles.org.uk>
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40352
2024-01-29 22:58:09 +01:00
Olivier Certner 33d4ce5496
login.conf(5): Document priority's special value 'inherit'
Reviewed by:            emaste, yuripv (older version)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40691
2024-01-29 22:58:09 +01:00
Olivier Certner d162d7e2ad
setclasspriority(): New possible value 'inherit'
It indicates to the login.conf machinery (setusercontext() /
setclasscontext()) to leave priority alone, effectively inheriting it
from the parent process.

PR:                     271749
Reviewed by:            emaste, yuripv
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40690
2024-01-29 22:58:09 +01:00
Olivier Certner 7b94ec550e
setusercontext(): Move priority setting in new setclasspriority()
In preparation for setting priorities from '~/.login_conf' and to ease
reading of setusercontext().

No functional change.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40350
2024-01-29 22:58:08 +01:00
Olivier Certner aa96945e71
login.conf(5): Document priority's default and possible values
Priority is reset to 0 if not explicitly specified.

While here, be more explicit about what "Initial priority (nice) level"
means and document that it is possible to set real-time or idle class'
priorities with this capability.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40689
2024-01-29 22:58:08 +01:00
Olivier Certner d988621b0c
setusercontext(): Better error messages when priority is not set correctly
Polish the syslog messages to contain readily useful information.

Behavior of capability 'priority' is inconsistent with what is done for
all other contexts: 'umask', 'cpumask', resource limits, etc., where an
absence of capability means to inherit the value.  It is currently
preserved for compatibility, but is subject to change on a future major
release.

Reviewed by:            emaste, kib (older version)
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40349
2024-01-29 22:58:07 +01:00
Olivier Certner 92b2c4358f
login.conf(5): Default values: Rename column, elaborate on absence of such
Column "Notes" in fact only contains default values for capabilities, so
make this clear by renaming it to "Default".

Add a small introductory text mentioning it, and what an absence of
default value means (inheritance).

PR:                     271748
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40347
2024-01-29 22:58:07 +01:00
Olivier Certner 771d5c93ab
setlogincontext(): Comply to style(9)
Remove indentation by inverting the big 'if (lc)' and using 'return'.
Use explicit binary operators to produce booleans.

Reviewed by:            emaste, kib, dchagin
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40346
2024-01-29 22:58:07 +01:00
Olivier Certner ea9bd44810
login.conf(5): Document umask's special value 'inherit'
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40688
2024-01-29 22:58:06 +01:00
Olivier Certner c328e6c6cc
setclassumask(): Accept 'inherit' as a value
'inherit' explicitly indicates that the umask should not be changed.

Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Relnotes:               yes
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40687
2024-01-29 22:58:06 +01:00
Olivier Certner 0dd1705f58
setusercontext(): Set umask in a separate function, setclassumask()
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40686
2024-01-29 22:58:06 +01:00
Olivier Certner 97256feb7a
login_cap(3): Document login_getcapenum()
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40685
2024-01-29 22:58:05 +01:00
Olivier Certner 90e914cd5a
New login_getcapenum(): Allows to read named enum values
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40684
2024-01-29 22:58:05 +01:00
Olivier Certner 0d1fe948d9
login.conf(5): umask has no default value
The umask is simply left unchanged if no explicit value is specified in
the login class capabilities database.

PR:                     271747
Reviewed by:            emaste
Approved by:            emaste (mentor)
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40345
2024-01-29 22:58:05 +01:00
Olivier Certner e99c28e93b
setusercontext(): umask: Set it only once (in the common case)
Simplify the code and make it more coherent (umask was the only context
setting not modified by setlogincontext() directly).

Preserve the current behavior of not changing the umask if none is
specified in the login class capabilities database, but without the
superfluous umask() dance.  (The only exception to this is that
a special value no user is likely to input in the database now stands
for no specification.)

If some user has a 'umask' override in its '~/.login_conf', the umask
will still be set twice as before (as is the case for all other context
settings overriden in '~/.login_conf').

Log a warning in case of an invalid umask specification.

This change makes it apparent that the value of LOGIN_DEFUMASK doesn't
matter.  It will be removed in a subsequent commit.

PR:                     271747
Reviewed by:            emaste, kib (earlier version)
Approved by:            emaste
MFC after:              3 days
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40344
2024-01-29 22:57:58 +01:00
Konstantin Belousov a570fe4d0d open(2): describe *at behavior for dirfd opened without O_SEARCH
and move the BUGS paragraph about dirfd permissions into STANDARDS
section, noting that we provide POSIX-mandated implementation.

Reviewed by:	emaste, kevans
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D43652
2024-01-29 23:38:48 +02:00
Mark Johnston 8d5353de74 libc: Annotate a couple of local functions as such
No functional change intended.

MFC after:	1 week
2024-01-29 11:44:36 -05:00
R. Christian McDonald 5086b6ec32
libbe: handle destroying/renaming temporary/bootonce boot environments
When a temporary/bootonce boot environment is renamed, we need to also
update the bootenv nvlist on-disk to reflect the new name. Additionally,
when a temporary/bootonce boot environment is destroyed, we also need to
clear out the on-disk state.

Reviewed by:	kevans
Approved by:	kp
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43591
2024-01-29 10:07:49 -05:00
Steve Kargl 0dd5a5603e lib/msun: Cleanup after $FreeBSD$ removal
Remove no longer needed explicit inclusion of sys/cdefs.h.

PR:	276669
MFC after:	1 week
2024-01-28 17:00:23 +02:00
Mark Johnston 4dedcb1bb5 libc/amd64: Disable ASAN for amd64_archlevel.c
The code in this file runs before the sanitizer can initialize its
shadow map.

Fixes:	ad2fac552c ("lib/libc/amd64: add archlevel-based simd dispatch framework")
2024-01-27 22:12:01 -05:00
Dimitry Andric 5c38ea60a0 Add libllvm and liblldb source files to enable WITH_ASAN build
This is another part of fixing the WITH_ASAN build. Some additional
source files had to be added to libllvm and liblldb, since the ASan
instrumentation causes symbols in those files to be referenced.

Reported by:	markj
PR:		276597
MFC after:	3 days
2024-01-27 22:51:08 +01:00
Dimitry Andric d04e03c19a msun: remove fabs from Symbol.map, and adjust comment
We have s_fabs.c, but fabs(3) is already provided by libc due to
historical reasons, so it is not compiled into libm. When the linker
does not use --undefined-version, this leads to a complaint about the
symbol being nonexistent, so remove it from Symbol.map.

While here, adjust the comment about some functions being supplied by
libc: while it is true that all these are indeed in libc, libm still
includes its own versions of frexp(3), isnan(3), isnanf(3), and
isnanl(3).

Reported by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
MFC after:	3 days
2024-01-27 22:24:38 +01:00
Mike Karels 9231c42127 inet(3): clarify syntax accepted by inet_pton
The section INTERNET ADDRESSES describes the acceptance of dotted
values with varying number of parts in multiple bases.  This applies
to inet_aton and inet_addr, but not to inet_pton.  Clarify this
section by listing the functions to which this applies.  Move the
description of what inet_pton accepts into this section from STANDARDS,
where it is easily missed.  Rename the section to clarify that it
applies only to IPv4.  (inet_pton also works with IPv6.)

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43537
2024-01-27 09:40:07 -06:00
Ed Maste ea6a6b63e1 open: make non-POSIX errno value more apparent
In the errno list, add an explicit note and reference to the note in the
STANDARDS section.

When O_NOFOLLOW is specified and the target is a symbolic link FreeBSD
sets errno to a value different than that specified by POSIX.  Commit
295159dfa3 added a note to this effect, but I missed it when reading
through the list of errno values.

PR:		214633
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43618
2024-01-26 10:36:32 -05:00
Dimitry Andric ecf4106237 Merge libcxxrt master 03c83f5a57be8c5b1a29a68de5638744f17d28ba
Interesting fixes (* were already cherry-picked):
- 03c83f5 add __cxa_init_primary_exception (#23)
* 5d8a158 Fix two bugs in __cxa_end_cleanup()
* b00c6c5 Insert padding in __cxa_dependent_exception
* 45ca8b1 Insert padding in __cxa_exception struct for compatibility
* f2e5509 Fix unlock in two-word version and add missing comment.
- 6229590 Add an option for disabling emergency buffers. (#14)

MFC after:	2 weeks
2024-01-25 18:43:23 +01:00
Mark Johnston af0d437dd3 kcmp: Add a manual page
Reviewed by:	kib, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D43562
2024-01-24 09:42:15 -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
Kyle Evans 009db0d40c ncurses: serialize the tinfo build a little bit
Move ncurses_dll.h to GENHDRS to start with; it's been generated from
ncurses_dll.h.in for years, so it's not actually in a different category
than all of the other GENHDRS.  Slap an .ORDER on it to ensure that we
build ncurses_dll.h and curses.h before any *.c gets compiled.

This should sufficiently address a build race seen downstream where
ncurses_dll.h is present but not yet populated.

Reviewed by:	bapt
Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D43540
2024-01-23 23:00:36 -06:00
Gordon Bergling 8593b5b2ad pkru.3: Fix a typo in the manual page
- s/successfull/successful/

MFC after:	3 days
2024-01-20 19:55:08 +01:00
Gordon Bergling a70008e95b sigfastblock.2: Fix a typo in the manual page
- s/successfull/successful/

MFC after:	3 days
2024-01-20 19:54:33 +01:00
Gordon Bergling b2ec175fca _umtx_op.2: Fix a typo in the manual page
- s/interpeted/interpreted/

MFC after:	3 days
2024-01-20 17:26:34 +01:00
Brooks Davis 60b2e2d3ee libc: stop exposing __fcntl_compat
It was exposed (under FBSDprivate_1.0) for forward compatability in
threading libraries in 2008 by commit cd7d66a21f.  The last consumer
was removed in 2015 by commit 8495e8b1e9.  I missed this among the _
and __sys_ symbols in commit e2417a21a0.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D43408
2024-01-13 00:01:13 +00:00
Steve Kargl 7385a7f67c system(3): fix typo santized -> sanitized
PR: 276262
Reviewed by: imp
2024-01-12 11:29:22 -07:00
Brooks Davis e2417a21a0 libc: separate syscall and non-syscall symbols
Put declerations of _ and __sys_ prefixed stubs at the top and
everything else at the bottom.  Sort the bottom list with sort(1).
This paves the way to generate the syscall symbol list.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43386
2024-01-11 18:27:20 +00:00
Brooks Davis 6597ea4481 powerpc/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Reviewed by:	jhibbits
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43323
2024-01-11 18:27:20 +00:00
Olivier Certner aadb4a1b3f
pthread_attr_get_np(): Use malloc(), report ENOMEM, don't tamper on error
Similarly as in the previous commit, using calloc() instead of malloc()
is useless here in the regular case since the subsequent call to
cpuset_getaffinify() is going to completely fill the allocated memory.

However, there is an additional complication.  This function tries to
allocate memory to hold the cpuset if it previously wasn't, and does so
before the thread lock is acquired, which can fail on a bad thread ID.
In this case, it is necessary to deallocate the memory allocated in this
function so that the attributes object appears unmodified to the caller
when an error is returned.  Without this, a subsequent call to
pthread_attr_getaffinity_np() would expose uninitialized memory (not
a security problem per se, since it comes from the same process) instead
of returning a full mask as it would before the failing call to
pthread_attr_get_np().  So the caller would be able to notice a change
in the state of the attributes object even if pthread_attr_get_np()
reported failure, which would be quite surprising.  A similar problem
that could occur on failure of cpuset_setaffinity() has been fixed.

Finally, we shall always report memory allocation failure.  This already
goes for pthread_attr_init(), so, if for nothing else, just be
consistent.

Reviewed by:            emaste, kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43329
2024-01-10 18:50:19 +01:00
David E. O'Brien dafd0d6855 History for arc4random_*() 2024-01-09 22:09:47 -08:00
Brooks Davis 13f345cdec powerpc64/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Reviewed by:	jhibbits
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43322
2024-01-09 22:59:29 +00:00
Olivier Certner 15bb0300ee
libhtr: pthread_attr_setaffinity_np(): Replace calloc() with malloc()
Using calloc() instead of malloc() is useless here since the allocated
memory is to be wholly crushed by the memcpy() call that follows.

Suggested by:           kib
Reviewed by:            emaste, kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Differential Revision:  https://reviews.freebsd.org/D43328
2024-01-09 14:29:26 +01:00
Olivier Certner 4d312aa051
libthr: thr_attr.c: More style and clarity fixes
The change of argument for sizeof() (from a type to an object) is to be
consistent with the change done for the malloc() code just above in the
preceding commit touching this file.

Consider bit flags as integers and test whether they are set with an
explicit comparison with 0.

Use an explicit flag value (PTHREAD_SCOPE_SYSTEM) in place of a variable
that has this value at point of substitution.

All other changes are straightforward.

Suggested by:           kib
Reviewed by:            kib
Approved by:            emaste (mentor)
MFC after:              2 weeks
Differential Revision:  https://reviews.freebsd.org/D43327
2024-01-09 14:29:25 +01:00
Tom Hukins ba719a0fec Fix "version introduced" in numerous manual pages
MFC after:	1 week
Pull request:	https://github.com/freebsd/freebsd-src/pull/853
2024-01-08 11:35:16 -05: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
David E. O'Brien 6f55a4e24c timingsafe_bcmp(3) was MFC'ed to 11.1 2024-01-05 20:54:13 -08:00
Kristof Provost 324fd7ec40 libpfctl: introduce a handle-enabled variant of pfctl_add_rule()
Introduce pfctl_add_rule_h(), which takes a pfctl_handle rather than a
file descriptor (which it didn't use). This means that library users can
open the handle while they're running as root, but later drop privileges
and still add rules to pf.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-04 23:10:44 +01:00
Kristof Provost 66cacc141d libpfctl: introduce pfctl_handle
Consumers of libpfctl can (and in future, should) open a handle. This
handle is an opaque object which contains the /dev/pf file descriptor
and a netlink handle. This means that libpfctl users can open the handle
as root, then drop privileges and still access pf.

Already add the handle to pfctl_startstop() and pfctl_get_creatorids()
as these are new in main, and not present on stable branches. Other
calls will have handle-enabled alternatives implemented in subsequent
commits.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-01-04 23:10:24 +01:00
Olivier Certner 0eccb45979
libthr: thr_attr.c: EINVAL, not ENOTSUP, on invalid arguments
On first read, POSIX may seem ambiguous about the return code for some
scheduling-related pthread functions on invalid arguments.  But a more
thorough reading and a bit of standards archeology strongly suggests
that this case should be handled by EINVAL and that ENOTSUP is reserved
for implementations providing only part of the functionality required by
the POSIX option POSIX_PRIORITY_SCHEDULING (e.g., if an implementation
doesn't support SCHED_FIFO, it should return ENOTSUP on a call to, e.g.,
sched_setscheduler() with 'policy' SCHED_FIFO).

This reading is supported by the second sentence of the very definition
of ENOTSUP, as worded in CAE/XSI Issue 5 and POSIX Issue 6: "The
implementation does not support this feature of the Realtime Feature
Group.", and the fact that an additional ENOTSUP case was added to
pthread_setschedparam() in Issue 6, which introduces SCHED_SPORADIC,
saying that pthread_setschedparam() may return it when attempting to
dynamically switch to SCHED_SPORADIC on systems that doesn't support
that.

glibc, illumos and NetBSD also support that reading by always returning
EINVAL, and OpenBSD as well, since it always returns EINVAL but the
corresponding code has a comment suggesting returning ENOTSUP for
SCHED_FIFO and SCHED_RR, which it effectively doesn't support.

Additionally, always returning EINVAL fixes inconsistencies where EINVAL
would be returned on some out-of-range values and ENOTSUP on others.

Reviewed by:            markj
Approved by:            markj (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43006
2024-01-04 11:42:08 +01:00
Olivier Certner bd61c1e89d
libthr: thr_attr.c: Clarity, whitespace and style
Also, remove most comments, which don't add value.

Reviewed by:            emaste
Approved by:            markj (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43005
2024-01-04 11:42:03 +01:00
Mark Johnston ee7d5ba1b5 setfib.2: Consistently capitalize "FIB"
MFC after:	1 week
Sponsored by:	Klara, Inc.
2024-01-03 16:24:56 -05:00
Brooks Davis 85c9d36497 acl_equiv_mode_np: zero mode on just inited ACL
You can't return 0 and not write the mode if mode_p is non-NULL.  That
violates the API contract and in common usage leaves stack trash in
*mode_p.

The acl_equiv_mode_test test passed by accident.

Reviewed by:	kevans, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43278
2024-01-03 16:34:39 +00:00
Rick Macklem 84b4342c0d copy_file_range.2: Clarify that only regular files work
PR#273962 reported that copy_file_range(2) did not work
on shared memory objects and returned EINVAL.
Although the reporter felt this was incorrect, it is what
the Linux copy_file_range(2) syscall does.

Since there was no collective agreement that the FreeBSD
semantics should be changed to no longer be Linux compatible,
copy_file_range(2) still works on regular files only.

This man page update clarifies that. If, someday, copy_file_range(2)
is changed to support non-regular files, then the man page will
need to be updated to reflect that.

PR:	273962
Reviewed by:	karels, pauamma_gundo.com (manpages)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43227
2023-12-29 14:59:00 -08:00
Dimitry Andric e77a1bb275 Reorganize libclang_rt Makefile and make more lib/arch combos available
Upstream has made more clang runtime libraries available for more
architectures, so add them. To make this easier, split up subdir lists
into functional parts (asan, tsan, etc), and put each architecture into
its own .if block.

Effectively, this adds the following libraries for aarch64: asan, cfi,
fuzzer, msan, safestack, stats, tsan, ubsan, xray.

PR:		262706
MFC after:	3 days
2023-12-28 13:57:41 +01:00
Jose Luis Duran 1860341347 libdevdctl: Fix typo (triple S)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/955
2023-12-27 20:24:30 -07:00
Jose Luis Duran b9bb04c167 libcasper: Fix typo (triple T)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/954
2023-12-27 20:24:30 -07:00
Robert Clausecker fb197a4f77 lib/libc/amd64/string: add memrchr() scalar, baseline implementation
The scalar implementation is fairly simplistic and only performs
slightly better than the generic C implementation. It could be
improved by using the same algorithm as for memchr, but it would
have been a lot more complicated.

The baseline implementation is similar to timingsafe_memcmp.  It's
slightly slower than memchr() due to the more complicated main
loop, but I don't think that can be significantly improved.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925
2023-12-25 15:00:05 +01:00
Robert Clausecker 691ff1832e lib/libc/tests/string: add memrchr unit tests
The "values" test case is specifically crafted to detect the off-by-one
error previous discovered in the scalar strchrnul implementation.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925
2023-12-25 14:59:58 +01:00
Robert Clausecker e0d4f419ac lib/libc/string: document restrict qualification of memccpy() arguments
POSIX.1-2004 and the upcoming C23 agree that memccpy()'s arguments
are restrict qualified and must not overlap.  In 2002, restrict
qualifiers were added to <string.h>'s declaration of the function.
Make things official and document that the arguments must not
overlap.

See also:	61b60edfd3
Approved by:	kib
MFC after:	1 month
MFC to:		stable/14
2023-12-25 14:59:50 +01:00
Robert Clausecker ea7b13771c lib/libc/amd64/string: implement strncat() by calling strlen(), memccpy()
This picks up the accelerated implementation of memccpy().

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42902
2023-12-25 14:59:48 +01:00
Robert Clausecker fc0e38a7a6 lib/libc/amd64/string: add memccpy scalar, baseline implementation
Based on the strlcpy code from D42863, this patch adds a SIMD-enhanced
implementation of memccpy for amd64. A scalar implementation calling
into memchr and memcpy to do the job is provided, too.

Please note that this code does not behave exactly the same as the C
implementation of memccpy for overlapping inputs. However, overlapping
inputs are not allowed for this function by ISO/IEC 9899:1999 and neither
has the C implementation any code to deal with the possibility. It just
proceeds byte-by-byte, which may or may not do the expected thing for
some overlaps. We do not document whether overlapping inputs are
supported in memccpy(3).

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42902
2023-12-25 14:59:42 +01:00
Robert Clausecker e4b7b0bcbc lib/libc/tests/string: add unit tests for memccpy()
Adapted from the strlcpy() unit tests.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
2023-12-25 14:59:40 +01:00
Robert Clausecker 2b7b03b7ae lib/libc/amd64/string: implement strlcat() through strlcpy()
This should pick up our optimised memchr(), strlen(), and strlcpy()
when strlcat() is called.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42863
2023-12-25 14:59:31 +01:00
Robert Clausecker 74d6cfad54 lib/libc/amd64/string: add strlcpy scalar, baseline implementation
Somewhat similar to stpncpy, but different in that we need to compute
the full source length even if the buffer is shorter than the source.

strlcat is implemented as a simple wrapper around strlcpy.  The scalar
implementation of strlcpy just calls into strlen() and memcpy() to do
the job.

Perf-wise we're very close to stpncpy.  The code is slightly slower as
it needs to carry on with finding the source string length even if the
buffer ends before the string.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42863
2023-12-25 14:56:05 +01:00
Robert Clausecker f7098b8659 lib/libc/tests/string: add unit test for strlcpy
A straightforward derivation from the stpncpy unit test.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42863
2023-12-25 14:56:02 +01:00
Robert Clausecker aff9143a24 lib/libc/amd64/string/strcat.S: enable use of SIMD
strcat has a bespoke scalar assembly implementation we
inherited from NetBSD.  While it performs well, it is
better to call into our SIMD implementations if any SIMD
features are available at all.  So do that and implement
strcat() by calling into strlen() and strcpy() if these
are available.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Reviison: https://reviews.freebsd.org/D42600
2023-12-25 14:55:53 +01:00
Robert Clausecker e19d46c808 lib/libc/amd64/string: implement strncpy() by calling stpncpy()
Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42519
2023-12-25 14:55:48 +01:00
Robert Clausecker 90253d49db lib/libc/amd64/string: add stpncpy scalar, baseline implementation
This was surprisingly annoying to get right, despite being such a simple
function.  A scalar implementation is also provided, it just calls into
our optimised memchr(), memcpy(), and memset() routines to carry out its
job.

I'm quite happy with the performance.  glibc only beats us for very long
strings, likely due to the use of AVX-512.  The scalar implementation
just calls into our optimised memchr(), memcpy(), and memset() routines,
so it has a high overhead to begin with but then performs ok for the
amount of effort that went into it.  Still beats the old C code, except
for very short strings.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42519
2023-12-25 14:55:42 +01:00
Robert Clausecker 6fa9e7d873 lib/libc/tests/string/stpncpy_test.c: extend for upcoming SSE implementation
This adds additional unit tests validating the function for
All possible alignment offsets of source and destination.

Also extend the test to allow testing of an external stpncpy
implementation, which greatly simplifies the development of
custom implementations.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42519
2023-12-25 14:55:37 +01:00
Robert Clausecker fd2ecd91ae lib/libc/amd64/string: implement strsep() through strcspn()
The strsep() function is basically strcspn() with extra steps.
On amd64, we now have an optimised implementation of strcspn(),
so instead of implementing the inner loop manually, just call
into the optimised routine.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42346
2023-12-25 14:55:30 +01:00
Robert Clausecker 2ed514a220 lib/libc/amd64/string: add strrchr scalar, baseline implementation
The baseline implementation is very straightforward, while the scalar
implementation suffers from register pressure and the need to use SWAR
techniques similar to those used for strchr().

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42217
2023-12-25 14:55:22 +01:00
Robert Clausecker 14289e973f lib/libc/amd64/string: add strncmp scalar, baseline implementation
The scalar implementation is fairly straightforward and merely unrolled
four times.  The baseline implementation closely follows D41971 with
appropriate extensions and extra code paths to pay attention to string
length.

Performance is quite good.  We beat both glibc (except for very long
strings, but they likely use AVX which we don't) and Bionic (except for
medium-sized aligned strings, where we are still in the same ballpark).

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42122
2023-12-25 14:55:13 +01:00
Robert Clausecker 459ddefcc9 lib/libc/tests/string: add unit tests for strncmp(3)
These are patterned after the previously added (D41970)
strcmp tests, but are extended to check for various length
conditions.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42122
2023-12-25 14:55:08 +01:00
Robert Clausecker f4fc317c36 lib/libc/amd64/string: implement strpbrk() through strcspn()
This lets us use our optimised strcspn() routine for strpbrk() calls.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D41980
2023-12-25 14:54:58 +01:00
Robert Clausecker bca25680b9 lib/libc/amd64/string/strcmp.S: add baseline implementation
This is the most complicated one so far.  The basic idea is to process
the bulk of the string in aligned blocks of 16 bytes such that one
string runs ahead and the other runs behind.  The string that runs ahead
is checked for NUL bytes, the one that runs behind is compared with the
corresponding chunk of the string that runs ahead.  This trades an extra
load per iteration for the very complicated block-reassembly needed in
the other implementations (bionic, glibc).  On the flip side, we need
two code paths depending on the relative alignment of the two buffers.

The initial part of the string is compared directly if it is known not
to cross a page boundary.  Otherwise, a complex slow path to avoid
crossing into unmapped memory commences.

Performance-wise we beat bionic for misaligned strings (i.e. the strings
do not share an alignment offset) and reach comparable performance for
aligned strings.  glibc is a bit better as it has a special kernel for
AVX-512, where this stuff is a bit easier to do.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D41971
2023-12-25 14:54:33 +01:00
Bill Sommerfeld 8f7ed58a15 regex: mixed sets are misidentified as singletons
Fix "singleton" function used by regcomp() to turn character set matches
into exact character matches if a character set has exactly one
element.

The underlying cset representation is complex; most critically it
records"small" characters (codepoint less than either 128
or 256 depending on locale) in a bit vector, and "wide" characters in
a secondary array.

Unfortunately the "singleton" function uses to identify singleton sets
treated a cset as a singleton if either the "small" or the "wide" sets
had exactly one element (it would then ignore the other set).

The easiest way to demonstrate this bug:

	$ export LANG=C.UTF-8
	$ echo 'a' | grep '[abà]'

It should match (and print "a") but instead it doesn't match because the
single accented character in the set is misinterpreted as a singleton.

Reviewed by:	kevans, yuripv
Obtained from:	illumos
Differential Revision:	https://reviews.freebsd.org/D43149
2023-12-22 12:19:59 +07:00
Brooks Davis 5d21ac643b Revert "power*/SYS.h: implement _SYSCALL_BODY() macro"
bapt reports build errors on powerpc/powerpc so this is the most likely
culprit.

This reverts commit e88e127279.
2023-12-21 21:37:09 +00:00
Kristof Provost 881bf8814a pf: export missing state information
We did not export all of the information pfctl expected to print via the
new netlink code. This manifested as pfctl printing 'rtableid: 0', even
when there is no rtable set.

While we're addressing that also export other missing fields such as
dummynet, min_ttl, max_mss, ..

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-21 19:21:17 +01:00
Brooks Davis e88e127279 power*/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Reviewed by:	jhibbits
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43056
2023-12-21 17:57:14 +00:00
Michael Gmelin 3d36053ca6 libifconfig: Fix bridge status member list
When this functionality was moved to libifconfig in 3dfbda3401,
the end of list calculation was modified for unknown reasons, practically
limiting the number of bridge member returned to (about) 102.

This patch changes the calculation back to what it was originally and
adds a unit test to verify it works as expected.

Reported by:	Patrick M. Hausen (via ML)
Reviewed by:	kp
Approved by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43135
2023-12-21 16:50:27 +01:00
Vincenzo Maffione ad874544d9 libnetmap: remove interface name validation
When trying to use a VLAN device (e.g. "em0.123") with a dot
the library fails to parse the interface correctly. The former
pattern is much too restrictive given that almost all characters
can be coerced into a device name via ifconfig.

Remove the particularly restrictive validation.  Some characters
still cannot be used as an interface name as they are used as
delimiters in the syntax, but this allows to be able to use most
of them without an issue.

Submitted by:	franco@opnsense.org
Differential Revision:	https://reviews.freebsd.org/D42485
Reviewed by:	vmaffione
2023-12-21 14:43:57 +00:00
Robert Clausecker c91cd7d03a lib/libc/amd64/string/strcspn.S: always return earliest match in 17--32 char case
When matching against a set of 17--32 characters, strcspn() uses two
invocations of PCMPISTRI to match against the first 16 characters
of the set and then the remaining characters.  If a match was found in
the first half of the set, the code originally immediately returned
that match.  However, it is possible for a match in the second half of
the set to occur earlier in the vector, leading to that match being
overlooked.

Fix the code by checking if there is a match in the second half of the
set and taking the earlier of the two matches.

The correctness of the function has been verified with extended unit
tests and test runs against the glibc test suite.

Approved by:	mjg (implicit, via IRC)
MFC after:	1 week
MFC to:		stable/14
2023-12-21 03:17:17 +01:00
Robert Clausecker a0ecf2224e lib/libc/tests/string/strcspn_test.c: add test for correct match order
This new unit test verifies that if there are multiple
matches, the first match is returned, ignoring later
matches.

Approved by:	mjg (blanket, via IRC)
MFC after:	1 week
MFC to:		stable/14
2023-12-21 03:16:57 +01:00
Dimitry Andric 87eea35e3f Add missing /usr/include/c++/v1/__mdspan/mdspan.h header
I missed this header while updating the Makefile for libc++ 17.

PR:		273753
MFC after:	1 month
2023-12-20 20:16:57 +01:00
Dimitry Andric 0c3af23961 Add missing sources to libclang_rt Makefiles, clean up unneeded ones
During the llvm-17 merge, a few new source files were not added to the
libclang_rt Makefiles, in particular sanitizer_thread_arg_retval.cpp
which is now required for AddressSanitizer and MemorySanitizer. Also,
MemorySanitizer now requires msan_dl.cpp.

While here, clean out a number of source files that compile into nothing
(because they only contain non-FreeBSD parts). Also, remove a duplicated
instance of tsan_new_delete.cpp from libclang_rt.tsan, since it is only
supposed to live in libclang_rt.tsan_cxx.

PR:		275854
Reported by:	jbeich
MFC after:	1 month
2023-12-20 17:08:26 +01:00
Brooks Davis 8a1b84f861 arm/SYS.h: align with other arches
Rename SYSTRAP() macro to _SYSCALL() and add _SYSCALL_BODY() which invokes
the syscall via _SYCALL() and then calls cerror as required.  Use to
implement PSEUDO() and RSYSCALL() removing _SYSCALL_NOERROR().

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43061
2023-12-18 22:28:42 +00:00
Brooks Davis d444ef5393 arm/SYS.h: remove unused CURBRK macro
The last use was removed in 2018 as part of a reimplementation of brk()
and sbrk() in commit 9d9fd255d6.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43060
2023-12-18 22:28:42 +00:00
Brooks Davis 8f465f509b {amd64,i386}/SYS.h: add _SYSCALL and _SYSCALL_BODY
Add a _SYSCALL(name) which calls the SYS_name syscall.  Use it to add a
_SYSCALL_BODY() macro which invokes the syscall and calls cerror as
required.  Use the latter to implement PSEUDO() and RSYSCALL().

Reviewed by:	imp, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43059
2023-12-18 22:28:42 +00:00
Brooks Davis 300bbb3a43 riscv/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Reviewed by:	imp, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43057
2023-12-18 22:28:42 +00:00
Alan Somers 18e2c4175f Remove _POSIX_PRIORITIZED_IO references from man pages
We don't support it, so there's no need to tell readers what would
happen if we did.  Also, don't remind the user that a certain field is
ignored by aio_read.  Mentioning every ignored field would make the man
pages too verbose.

MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	Pau Amma <pauamma@gundo.com>
Differential Revision: https://reviews.freebsd.org/D42622
2023-12-18 08:06:55 -07:00
Peter Eriksson 7aa375dcc6 libc: correct some memory leaks in acl_to_text(3) and acl_to_text_np(3)
PR:	275232
MFC after:	1 week
2023-12-18 00:06:03 +02:00
Brooks Davis 5c7a909271 libc/i386/SYS.h: Remove unused LCALL macro
It appears that the only user of this macro was removed
with support for building a.out binaries in 2002 by commit
66422f5b7a.

Reviewed by:	imp, kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42997
2023-12-12 22:53:09 +00:00
Brooks Davis 9aaf4e3be6 libc/*/SYS.h: remove SYCALL macro
This has not been a univerally available interface since it was removed
from amd64 by commit efbef97de9 in 2004.
I removed the last consumers in 2016 when I replaced pipe(2) with
pipe2(2) in commit b60998c633.

Reviewed by:	imp, jhibbits
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42996
2023-12-12 22:52:41 +00:00
Alex Richardson 60e845ceef jevents: fix bootstrapping on Linux with Clang 16
The glibc fts_open() callback type does not have the second const
qualifier and it appears that Clang 16 errors by default for mismatched
function pointer types. Add an ifdef to handle this case.

Reviewed By:	imp, emaste
Differential Revision: https://reviews.freebsd.org/D43000
2023-12-11 21:14:56 -08: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
Kristof Provost 99bcbef25a libpfctl: remove stray debug printf()
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-11 16:53:38 +01:00
Mariusz Zaborski a7100ae23a capsicum: introduce cap_rights_is_empty Function
Before this commit, we only had the capability to check if a specific
capability was set (using cap_rights_is_set function). However, there
was no efficient method to determine if a cap_rights_t structure doesn't
contain any capability. The cap_rights_is_empty function addresses
this gap.

PR:		275330
Reported by:	vini.ipsmaker@gmail.com
Reviewed by:	emaste, markj
Differential Revision:	https://reviews.freebsd.org/D42780
2023-12-11 12:15:46 +01:00
Konstantin Belousov 86e2bcbf47 strfmon.c: Use the restrict keyword directly
libc sources assume C99 or even C11 compiler already, unlike headers.
There is no reason to obfuscate the basic C constructs.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-10 23:28:25 +02:00
Jose Luis Duran 56a0d5444d strfmon: style fixes
Check style(9) with checkstyle9.pl and clang-format.
No functional change intended.

MFC after:	1 week
2023-12-10 23:28:16 +02:00
Stéphane Rochoy 4b9d605768 libsecureboot: be more verbose about validation failures
Reviewed by:	imp, sjg
Pull Request:	https://github.com/freebsd/freebsd-src/pull/916
2023-12-10 15:13:56 -05:00
Jose Luis Duran 6abee52e0d strfmon: Silence scan-build warning
The value stored to 'value' is never read.

Reported by:	Jenkins (scan-build)
MFC after:	1 week
2023-12-09 03:06:28 +02:00
Jose Luis Duran 2a163c3649 strfmon.3: Cleanup example code
- xlocale.h would have been required if using strfmon_l().  Here,
  setlocale() just requires locale.h.
- ANSIfy function declaration.
- Add a final return().

MFC after:	1 week
2023-12-09 03:06:13 +02:00
Dimitry Andric 5c16e71d30 Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.6-0-g6009708b4367.

PR:		273753
MFC after:	1 month
2023-12-08 18:35:59 +01:00
Dimitry Andric b121cb0095 Merge llvm-project release/17.x llvmorg-17.0.5-0-g98bfdac5ce82
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.5-0-g98bfdac5ce82.

PR:		273753
MFC after:	1 month
2023-12-08 18:35:50 +01:00
Dimitry Andric bdb86d1a85 Merge llvm-project release/17.x llvmorg-17.0.3-0-g888437e1b600
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.3-0-g888437e1b600.

PR:		273753
MFC after:	1 month
2023-12-08 18:35:41 +01:00
Dimitry Andric 3bd749dbd9 Merge llvm-project release/17.x llvmorg-17.0.2-0-gb2417f51dbbd
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.2-0-gb2417f51dbbd.

PR:		273753
MFC after:	1 month
2023-12-08 18:35:33 +01:00
Dimitry Andric 4542f901cb Merge llvm-project release/17.x llvmorg-17.0.1-25-g098e653a5bed
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.1-25-g098e653a5bed.

PR:		273753
MFC after:	1 month
2023-12-08 18:35:22 +01:00
Dimitry Andric 8a4dda33d6 Merge llvm-project release/17.x llvmorg-17.0.0-rc4-10-g0176e8729ea4
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.0-rc4-10-g0176e8729ea4.

PR:		273753
MFC after:	1 month
2023-12-08 18:35:11 +01:00
Dimitry Andric 06c3fb2749 Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the
last commit before the upstream release/17.x branch was created.

PR:		273753
MFC after:	1 month
2023-12-08 18:34:50 +01:00
Alan Somers cf037972ea libcasper: document that most libcasper functions are not thread-safe
And neither are most libcasper services' functions, because internally
they all use cap_xfer_nvlist.  cap_xfer_nvlist sends and then receives
data over a unix domain socket and associated with the cap_channel_t
argument.  So absent synchronization, two threads may not use the same
cap_channel_t argument or they risk receiving the other's reply.

MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	oshogbo
Differential Revision: https://reviews.freebsd.org/D42928
2023-12-08 09:22:39 -07:00
Brooks Davis fc0288993c libc: simplify MDASM/NOASM checks
Use boolean evaluation of :M matches and a single if statement.

Reviewed by:	imp, kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42915
2023-12-06 20:49:08 +00:00
Brooks Davis ec27c0bb3e libc: don't needlessly add vfork.o to NOASM
For architectures where vfork.S was named Ovfork.S this was needed, but
it was always pointless here as an entry in either MDASM or NOASM is
equivalent.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42914
2023-12-06 20:49:08 +00:00
Brooks Davis 0ea469bcd5 libc: rename arm and i386 Ovfork.S to vfork.S
While this has been Ovfork.S forever on i386 it differs from other
syscalls that require wrappers for no obvious reason so fix that.

Reviewed by:	kib
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42909
2023-12-06 20:49:08 +00:00
Alan Somers 6b96125afd cap_net.3: remove a copypasta
This line appears to have been copied from cap_sysctl.3.  While I'm
here, reorder and reword the description of cap_net_limit a bit.

[skip ci]

MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	oshogbo
Differential Revision: https://reviews.freebsd.org/D42919
2023-12-06 09:51:37 -07:00
Brooks Davis 7893419d49 Remove never implemented sbrk and sstk syscalls
Both system calls were stubs returning EOPNOTSUPP and libc did not
provide _ or __sys_ prefixed symbols.  The actual implementation of
sbrk(2) is on top of the undocumented break(2) system call.

Technically this is a change in ABI, but no non-contrived program ever
called these syscalls.

Reviewed by:	kib, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42872
2023-12-04 20:36:08 +00:00
Ka Ho Ng ebb1e0f193 libclang_rt: Update Makefile.depend
MFC after:	3 days
2023-12-02 04:18:54 -05:00
Alan Somers c2ed7a6360 sigaction.2: clarify that fork isn't async-signal-safe, but _Fork is
[skip ci]

MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42865
2023-12-01 08:59:36 -07:00
Jamie Gritton ed31b3f4a1 jail: Don't allow jail_set(2) to resurrect dying jails.
Currently, a prison in "dying" state (removed but still holding
resources) can be brought back to alive state via "jail -d", or
the JAIL_DYING flag to jail_set(2).  This seemed like a good idea
at the time.

Its main use was to improve support for specifying the jid when
creating a jail, which also seemed like a good idea at the time.
But resurrecting a jail that was partway through thr process of
shutting down is trouble waiting to happen.

This patch deprecates that flag, leaving it as a no-op for creating
jails (but still useful for looking at dying jails).  It sill allows
creating a new jail with the same jid as a dying one, but will renumber
the old one in that case.  That's imperfect, but allows for current
behavior.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D28150
2023-11-29 16:12:13 -08:00
Brooks Davis c96772227b memfd_create: don't allocate heap memory
Rather than calling calloc() to allocate space for a page size array to
pass to getpagesizes(), just follow the getpagesizes() implementation
and allocate MAXPAGESIZES elements on the stack.  This avoids the need
for the allocation.

While this does mean that a new libc is required to take advantage of a
new huge page size, that was already true due to getpagesizes() using a
static buffer of MAXPAGESIZES elements.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42710
2023-11-28 17:09:27 +00:00
Brooks Davis c3207e2d25 memfd_create: move implementation to libc/gen
Due to memfd_create(3)'s construction of a path to pass to shm_open2(2),
it has a much larger than typical dependency footprint for a system
call wrapper (the list currently includes calloc, memset, sprintf, and
strlen).  As such, split it off into its own file under libc/gen to
lighten libc/sys's dependency list.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42709
2023-11-28 17:09:27 +00:00
Brooks Davis ea180bb379 getpagesize(3): drop support for non-ELF kernels
AT_PAGESZ was introduced with ELF support in 1996 (commit
e1743d02cd) so we can safely count on
being able to use it to get our page size via elf_aux_info().  As such
we don't need a fallback sysctl query.

Save a few bytes of bss by dropping caching as elf_aux_info() runs
in constant time for a given query.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42708
2023-11-28 17:09:26 +00:00
Brooks Davis df65c89375 getpagesizes(3): drop support for kernels before 9.0
AT_PAGESIZES and elf_aux_info where added prior to FreeBSD 9.0 in commit
ee235befcb.  It's safe to say that a
FreeBSD 15 libc won't work on a 8.x kernel so drop sysctl fallback.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42707
2023-11-28 17:09:26 +00:00
Kristof Provost 44f323ecde pf: implement DIOCGETRULES via netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-27 21:36:49 +01:00
Warner Losh a2f733abcf lib: 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 0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -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 dc36d6f9bb lib: 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
Ka Ho Ng 3244c9c673 dirdeps: Remove $FreeBSD$
There was a $FreeBSD$ line in lib/liblua/Makefile.depend.

MFC after:	3 days
2023-11-26 15:47:54 -05:00
Xin LI ca6a6373bd MFV: xz 5.4.5
MFC after:	2 weeks
2023-11-25 17:02:59 -08:00
Gordon Bergling 637e4ef1a6 libcasper: Fix a typo in a source code comment
- s/mutiple/multiple/

MFC after:	3 days
2023-11-23 09:58:15 +01:00
Brooks Davis 9fc0ff9d85 libc: remove some obsolete VCS data
These wide char support files were copied from the previous versions
with expanded $FreeBSD$ strings in #if 0 blocks.  Remove them and the
scssid definitions in the same #if 0 blocks.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42688
2023-11-21 22:46:43 +00:00
Alan Somers 04cfe6c12c aio_read.2: correct the description of aio_buf
Looks like a copypasta from aio_write.2.

[skip ci]

Reported by:	Paul Floyd <pjfloyd@wanadoo.fr>
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	jilles (manpages)
Differential Revision: https://reviews.freebsd.org/D42621
2023-11-21 09:52:02 -07:00
Andrew Turner fd5aaf2ea0 libc: Teach libc about the BTI elf note
Add the Branch Target Identification (BTI) note to libc assembly
sources. As all obect files need the note for the library to have it
we need to insert it in all asm files.

Reviewed by:	emaste, markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D42228
2023-11-21 10:02:51 +00:00
Warner Losh 1b681154f5 math: Move to const instead of __const
There's no reason to use the __const construct here. This is a left-over
from supporting K&R and ANSI compilers in the original Sun msun. All
other K&R crutches have been removed. Remove these as well. There's no
semantic difference. And there's already several others in math.h.

Sponsored by:		Netflix
2023-11-19 20:55:57 -07:00
Gordon Bergling 8c8ffe541e Add a HISTORY section for memcpy(3) and mempcpy(3)
The memcpy() function first appeared in AT&T System V UNIX and was
reimplemented for 4.3BSD-Tahoe. The mempcpy() function first appeared in
FreeBSD 13.1.

PR:	272227
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42630
2023-11-18 10:09:40 +01:00
Gordon Bergling fa9f742201 getpeerid.3: Clarify the 's' argument
The argument 's' of getpeerid(3) must be a connected UNIX-domain socket,
so document it.

PR:	248614
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42629
2023-11-18 10:02:12 +01:00
Kirk McKusick 772430dd67 Ensure I/O buffers in libufs(3) are 128-byte aligned.
Various disk controllers require their buffers to be aligned to a
cache-line size (128 bytes). For buffers allocated in structures,
ensure that they are 128-byte aligned. Use aligned_malloc to allocate
memory to ensure that the returned memory is 128-byte aligned.

While we are here, we replace the dynamically allocated inode buffer
with a buffer allocated in the uufsd structure just as the superblock
and cylinder group buffers do.

This can be removed if/when the kernel is fixed. Because this problem
has existed on one I/O subsystem or another since the 1990's, we
are probably stuck with dealing with it forever.

The problem most recent showed up in Azure, see:
    https://reviews.freebsd.org/D41728
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267654
Before these fixes were applied, it was confirmed that the changes
in this commit also fixed the issue in Azure.

Reviewed-by: Warner Losh, kib
Tested-by:   Souradeep Chakrabarti of Microsoft (earlier version)
PR:          267654
Differential Revision: https://reviews.freebsd.org/D41724
2023-11-17 14:11:24 -08:00
Ka Ho Ng b1538e8fc4 dirdeps: Fix libpcap Makefile.depend.options
This prevents libpcap's Makefile.depend from flip-flopping when OFED is
enabled.

Sponsored by :	Juniper Networks, Inc.
MFC after:	7 days
Reviewed by:	sjg
Differential Revision:	https://reviews.freebsd.org/D42649
2023-11-17 11:34:57 -05:00
Kristof Provost 498934c5ff libpfctl: handle pfctl_do_ioctl() failures better
Ensure that we free nvlists and other allocations if pfctl_do_ioctl()
fails.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-17 13:21:14 +01:00
Kristof Provost 33d55d0d0f libpfctl: handle allocation failure
While it's unlikely for userspace to fail to allocate memory it is still
possible. Handle malloc() returning NULL.

Reported by:	Bill Meeks <bill@themeeks.net>
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-17 13:21:14 +01:00
Alexander Motin d282baddb0 Add interface NVME to devstat
This allows to list only NVMe devices in systat, iostat, vmstat, etc.
Previously those were counted as OTHER.
2023-11-15 23:03:40 -05:00
Brooks Davis 500bf0592c libc: remove unused stub vdso timecounter implementations
All supported architectures have shared page support so remove this
unused stub.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42619
2023-11-15 23:43:56 +00:00
Brooks Davis c704518681 libc: centralize a few numeric symbols
fabs, __infinity, and __nan are universally implemented so declare them
in gen/Symbol.map.

We would also include __flt_rounds, but  it's under FBSD_1.3 on arm so
until that's gone we're stuck with it.  Likewise, everyone but i386
implements fp[gs]etmask.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42618
2023-11-15 23:42:37 +00:00
Brooks Davis 5d79b5445e libc: centralize makecontext symbols
Declare makecontext() and __makecontext() symbols centrally as they are
always implemented.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42617
2023-11-15 23:42:18 +00:00
Brooks Davis 1c656143be libc: centralize {_,sig,}{set,long}jmp symbols
These symbols are universally exposed and documented so declare them
centrally.  Double- and triple-underscore versions exist on some
platforms, but leave those alone for now.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42616
2023-11-15 23:41:35 +00:00
Brooks Davis ff3a9d8e29 libc: centralize ntoh symbols
These are implemented by net/ntoh.c via headers and compiler intrinsics
so declare them in net/Symbol.map.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42615
2023-11-15 23:40:54 +00:00
Brooks Davis e4a1800f06 libc: further centralize syscall symbols
All architectures necessarily implement _exit(2) and vfork(2) so
declare them in sys/Symbol.map.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42614
2023-11-15 23:40:33 +00:00
Brooks Davis e3e9c205ff lib{c,lzma,z}: remove -DSYMBOL_VERSIONING from CFLAGS
This was part of a libkse and libpthread transition aide when libc
gained symbol versions in e62165c8b0
(March 2006).  The code that cared about this macro was removed in
commit 00fb440c1a (May 2007) when symbol
versioning was enabled by default and libthr became the default
threading library.  For unknown reasons, it stayed in libc (which
seemingly never used it) and seems to have been copied to liblzma and
libz.

Reviewed by:	imp, kib, emaste
Differential Revision:	https://reviews.freebsd.org/D42613
2023-11-15 23:39:46 +00: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
Alan Somers a5c2f4e939 libc/libc/rpc: refactor some global variables
* Combine dg_fd_locks and dg_cv into one array.
* Similarly for vc_fd_locks and vc_cv
* Turn some macros into inline functions

This is a mostly cosmetic change to make refactoring these strutures in
a future commit easier.

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
Brooks Davis 1ca63a8219 libc: Remove empty comments in Symbol.map
These were left over from $FreeBSD$ removal.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42612
2023-11-15 17:51:03 +00:00
Brooks Davis b73eace889 libc/<arch>/sys/Makefile.inc: remove cruft
Remove stray blank lines left over from $FreeBSD$ removal as well as
some CVS-era (perhaps pre-repocopy) version comments.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42611
2023-11-15 17:50:53 +00:00
John Baldwin 0355ecace8 libgpio: Fix type mismatch for gpio_pin_[gs]et
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42577
2023-11-14 18:34:21 -08:00
John Baldwin b7f7cc25c0 libcasper: Neuter false positive -Wuse-after-free warnings from GCC 13
GCC 13 incorrectly thinks a call to free after a failed realloc is a
use after free.

lib/libcasper/services/cap_grp/cap_grp.c: In function 'group_resize':
lib/libcasper/services/cap_grp/cap_grp.c:65:17: error: pointer 'buf' may be used after 'realloc' [-Werror=use-after-free]
   65 |                 free(buf);
      |                 ^~~~~~~~~
lib/libcasper/services/cap_grp/cap_grp.c:63:19: note: call to 'realloc' here
   63 |         gbuffer = realloc(buf, gbufsize);
      |                   ^~~~~~~~~~~~~~~~~~~~~~

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42576
2023-11-14 18:34:01 -08:00
Robert Clausecker b49596de26 lib/libc/tests/string: add extended unit tests for strcmp()
This changeset add a new set of tests that comprehensively test strcmp() on
various alignments of the input. This made it easy to smoke out many
exciting new bugs in the new SSE strcmp() implementation from D41971.

MFC after:	1 week
Reviewed by:	ngie
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41970
2023-11-14 12:37:06 -05:00
Cy Schubert 6726773431 Unbound: Manually update version strings
This was missed earlier today.

Reported by:	"Herbert J. Skuhra" <herbert@gojira.at>
Fixes:		16fd0b2491
MFC:		2 weeks
2023-11-13 16:46:12 -08:00
Brooks Davis da8238d6cf libc: fix typo in Makefile comment
MFC after:	1 week
2023-11-13 23:05:11 +00:00
R. Christian McDonald 6e5b1ff71e libc: enable initial-exec (IE) as default thread-local storage model on arm
As suggested by jrtc27@ in https://reviews.freebsd.org/D42415, this
patch enables IE as default thread-local storage model in libc on arm.

Reviewed by:	kib
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42445
2023-11-09 21:24:23 +01:00
Ka Ho Ng 5fb425aa00 dirdeps: Update liblldb dependencies
Sponsored by:	Juniper Networks, Inc.
MFC after:	3 days
Reviewed by:	sjg
Differential Revision:	https://reviews.freebsd.org/D42480
2023-11-08 19:43:25 -05:00
Ed Maste 4e0e01bf65 fflush: correct buffer handling in __sflush
Two additional stdio changes followed 86a16ada1e and need to be
reverted as part of the fflush fix.

This reverts commit 6e13794fbe.
This reverts commit bafaa70b6f.

Fixes: d09a3bf72c ("fflush: correct buffer handling in __sflush")
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42491
2023-11-07 11:03:34 -05:00
Ed Maste 418f026bd5 libc: remove unused errno.h include
errno.h was added in 44cf1e5eb4, which has been reverted.

Fixes: d09a3bf72c ("fflush: correct buffer handling in __sflush")
Sponsored by: The FreeBSD Foundation
2023-11-07 10:23:20 -05:00
Dag-Erling Smørgrav b8dbfb0a6c fflush: Add test for buffer handling in __sflush
Sponsored by:	Klara, Inc.
2023-11-07 08:21:12 -05:00
Dag-Erling Smørgrav d09a3bf72c fflush: correct buffer handling in __sflush
This fixes CVE-2014-8611 correctly.

The commit that purported to fix CVE-2014-8611 (805288c2f0) only hid
it behind another bug.  Two later commits, 86a16ada1e and
44cf1e5eb4, attempted to address this new bug but mostly just confused
the issue.  This commit rolls back the three previous changes and fixes
CVE-2014-8611 correctly.

The key to understanding the bug (and the fix) is that `_w` has
different meanings for different stream modes.  If the stream is
unbuffered, it is always zero.  If the stream is fully buffered, it is
the amount of space remaining in the buffer (equal to the buffer size
when the buffer is empty and zero when the buffer is full).  If the
stream is line-buffered, it is a negative number reflecting the amount
of data in the buffer (zero when the buffer is empty and negative buffer
size when the buffer is full).

At the heart of `fflush()`, we call the stream's write function in a
loop, where `t` represents the return value from the last call and `n`
the amount of data that remains to be written.  When the write function
fails, we need to move the unwritten data to the top of the buffer
(unless nothing was written) and adjust `_p` (which points to the next
free location in the buffer) and `_w` accordingly.  These variables have
already been set to the values they should have after a successful
flush, so instead of adjusting them down to reflect what was written,
we're adjusting them up to reflect what remains.

The bug was that while `_p` was always adjusted, we only adjusted `_w`
if the stream was fully buffered.  The fix is to also adjust `_w` for
line-buffered streams.  Everything else is just noise.

Fixes: 805288c2f0
Fixes: 86a16ada1e
Fixes: 44cf1e5eb4
Sponsored by:	Klara, Inc.
2023-11-07 08:21:12 -05:00
Kristof Provost a6173e9463 pf: expose more syncookie state information to userspace
Allow userspace to retrieve low and high water marks, as well as the
current number of half open states.

MFC after:	1 week
Sponsored by:	Modirum MDPay
2023-11-06 22:22:24 +01:00
Kristof Provost 497ccc21ef libpfctl: handle the 'pfctl' netlink family not being supported
If we fail to find the pfctl family we should not attempt to make the
call. That means that either pf is not loaded, or it's a very old (i.e.
pre-netlink) version.

Reported by: manu
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-06 13:53:56 +01:00
Ed Maste 5f4c09dd85 Track upstream project rename in contrib/blocklistd
Upstream is now https://github.com/zoulasc/blocklist/.  Rename the
contrib directory and update Makefiles to match, in advance of the next
vendor branch update.

Sponsored by:	The FreeBSD Foundation
2023-11-03 16:53:04 -04:00
Dag-Erling Smørgrav 1f90b4edff fflush: Split a temporary variable in two.
It is clearer to avoid reusing temporary variables for different
purposes.

Sponsored by:	Klara, Inc.
2023-11-03 13:38:12 -04:00
Warner Losh 559a218c9b libc: Purge unneeded cdefs.h
These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42385
2023-11-01 16:44:30 -06:00
Warner Losh 0527c9bdc7 ino64: Remove 'forward compat' code for this
Forward compatibility code was added for running newer ino64 binaries on
older kernels as a transition aide. Now that ino64 has been in the tree
6 years, this code is no longer useful and should have been removed long
ago.  Remove it now. Should be no user-visible changes at this point as
all the 'upgrade' scenarios it was intended for are long since past.

Also need to remove this stuff from rtld since the _foo versions
no longer exist.

Sponsored by:		Netflix
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D42382
2023-10-31 15:26:44 -06:00
Kenneth D. Merry 83823d063a Add IBM TS1170 density codes and specs.
These were obtained from a drive, but they agree with the IBM
documentation.

The bpi/bpmm values are the same as TS1160, but the number of
tracks is much larger (18944 tracks vs 8704 for TS1160).  The tapes
are also longer, 1337m total.  (According to the MAM on a sample JF
tape.  I don't have a JE tape handy to compare.)  The end result
is a 50TB raw capacity (150TB compressed) for TS1170 with a JF
cartridge vs 20TB raw capacity (60TB compressed) for TS1160 with
a JE cartridge.

lib/libmt/mtlib.c:
	Add the TS1170 density codes to the denstiy table in libmt.

usr.bin/mt/mt.1:
	Add the TS1170 density codes and specs to the density table
	in the mt(1) man page.  As usual for TS drives, there is an
	encrypted and non-encrypted density code (0x79 and 0x59
	respectively).

MFC after:	3 days
Sponsored by:	Spectra Logic
2023-10-31 15:20:36 -04:00
Kristof Provost 2b1eb63fc9 libpfctl: be more tolerant of kernel extensions
Allow the kernel to supply more array elements than expected, but cut
off when we hit what we think the maximum is. This will improve forward
compatibility (i.e. old userspace with newer kernel).

Reviewed by:	zlei
MFC after:	1 week
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D42392
2023-10-31 16:03:22 +01:00
Kristof Provost 87c5032353 libpfctl: remove unused field from struct pfctl_states
We never populate this, or use it, so remove it.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-10-30 19:05:03 +01:00
Kristof Provost 1c824f430a libpfctl: add missing pfctl_status_lcounter() function
We already had accessors for the other types of counters, but not this
one.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-10-30 19:05:03 +01:00
Andrew Turner 522126fea7 csu: Teach csu about PAC and BTI
Add the Branch Target Identification (BTI) note to libc assembly
sources and Pointer Authentication Code (PAC) instructions to _init and
_fini.

_init and _fini may be called indirectly so need a BTI landing pad. As
they are non-leaf functions use the appropriate PAC instruction that
also guards against changing the link register.

As all object files need the note for any binary using these object files
we need to insert it in all asm files.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D42227
2023-10-30 17:55:44 +00:00
Stephen J. Kiernan e5b786625f dirdeps: Add missing dependency files
Some leaf directories were missing Makefile.depend files or needed
architecture-specific Makefile.depend.* files.
2023-10-29 17:08:29 -04:00
Stephen J. Kiernan 5e3190f700 dirdeps: Update Makefile.depend* files with empty contents
Some Makefile.depend* files were committed with no contents or empty
DIRDEPS list, but they should have DIRDEPS with some contents.
2023-10-29 17:01:04 -04:00
Enji Cooper 61b15e6dfc lib/libcrypt: another trivial style change
Normalize on hard tabs.

I didn't catch this before pushing the previous commit.

No functional changes intended.

MFC after:	2 weeks
MFC with:	8ef8da882f
2023-10-27 18:59:23 -07:00
Jessica Clarke 1c1f229e91 libc: Strip plentiful trailing whitespace from aarch64+arm makecontext.c 2023-10-28 02:45:06 +01:00
Enji Cooper 8ef8da882f lib/libcrypt: remove trailing whitespace
No functional change intended.

MFC after:	2 weeks
2023-10-27 18:28:01 -07:00
Warner Losh 314542de6d clock_gettime: Minor clarification
Add a note saying that the CLOCK_BOOTTIME is unrelated to FreeBSD's
kern.boottime sysctl. Make a minor tweak to markup.

Feedback from:		pauammu
Sponsored by:		Netflix
Differential Revsion:	https://reviews.freebsd.org/D36037
2023-10-27 11:20:28 -06:00
Warner Losh 5e50a0f39f strlcpy/strlcat: Remove references to snprintf
While strlcpy and snprintf are somewhat similar, there's big differences
between strlcat and snprintf which leads to confusion. Remove the
comparison, since it's ultimately not that useful: the snprintf man page
has similar language to strlcpy, so it doesn't provide a better
reference. The two implementations are otherwise unrelated.

Reviewed by:		bcr
Sponsored by:		Netflix
Differential Revision:  https://reviews.freebsd.org/D27228
2023-10-27 10:13:50 -06:00
Brooks Davis 4894205482 procctl.2: improve phrasing for ASLR disable
Reported by:	jrtc27
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D42364
2023-10-26 18:40:08 +01:00
Kristof Provost 4abc3b482e libpfctl: fix Coverity issues
- handle snl_finalize_msg() returning NULL
 - insert the correct data into the states list
 - add missing nvlist_destroy()
 - incorrect order for array bounds

Coverity:	1522929, 1522925, 1522923, 1522921, 1522780, 1522770, 1522764, 1487785, 1471250
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42330
2023-10-24 09:50:47 +02:00
Kristof Provost 2cffb52514 libpfctl: fix pfctl_do_ioctl()
pfctl_do_ioctl() copies the packed request data into the request buffer
and then frees it. However, it's possible for the buffer to be too small
for the reply, causing us to allocate a new buffer. We then copied from
the freed request, and freed it again.

Do not free the request buffer until we're all the way done.

PR:		274614
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42329
2023-10-24 09:50:31 +02:00
Mariusz Zaborski afd74c4000 cap_net: correct capability name from addr2name to name2addr
Previously, while checking name2addr capabilities, we mistakenly used
the addr2name set. This error could cause a process to inadvertently
reset its limitations.

Reported by:	Shawn Webb <shawn.webb@hardenedbsd.org>
2023-10-23 23:11:23 +02:00
Kristof Provost 4f33755051 pf: allow states to be killed by their pre-NAT address
If a connection is NAT-ed we could previously only terminate it by its
ID or the post-NAT IP address. Allow users to specify they want look for
the state by its pre-NAT address. Usage: `pfctl -k nat -k <address>`.

See also:	https://redmine.pfsense.org/issues/11556
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42312
2023-10-23 16:37:05 +02:00
Kristof Provost 044eef6ab9 pf: support basic filters for state listing
Allow users(pace) to specify a protocol, interface, address family and/
or address and mask, allowing the state listing to be pre-filtered in
the kernel.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42280
2023-10-23 16:24:52 +02:00
Kristof Provost ffbf25951e pf: convert rule addition to netlink
The nvlist-based version will be removed in FreeBSD 16.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42279
2023-10-23 16:24:51 +02:00
Dag-Erling Smørgrav ca57a343e8 libc: More missing MLINKS.
Differential Revision:	https://reviews.freebsd.org/D42292
2023-10-20 12:29:40 +02:00
Mitchell Horne b293497146 pmc.amd(3): rename from pmc.k8(3)
This is the first step in recognizing that the K8 microarchitecture
represents a small and aged subset of AMD CPUs supported by this class.
Future changes will update the code and documentation details to better
reflect this.

Keep the old filename as an alias.

Reviewed by:	jkoshy
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41279
2023-10-18 15:05:45 -03:00
Mitchell Horne 82d6d46d0d pmc: remove last bits of AMD K7 CPU support
This includes event definitions from sys/pmc_events.h, definitions from
sys/pmc.h, and the man pages.

Reviewed by:	jkoshy
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41275
2023-10-18 15:05:45 -03:00
Dag-Erling Smørgrav dc41de36ab libc: Fix missing or misspelled MLINKS.
Differential Revision:	https://reviews.freebsd.org/D42192
2023-10-18 16:07:46 +02:00
Dag-Erling Smørgrav a66d27e22f memory(3): Mention more functions.
Differential Revision:	https://reviews.freebsd.org/D42191
2023-10-18 16:07:46 +02:00
Dag-Erling Smørgrav 64fc8a936c hesiod: Modernize.
Reviewed by:	zlei
Differential Revision:	https://reviews.freebsd.org/D42190
2023-10-18 16:05:55 +02:00
Kristof Provost 4f8f43b06e netlink: cope with growing requests
If a request ends up growing beyong the initially allocated space the
netlink functions (such as snl_add_msg_attr_u32()) will allocate a
new buffer. This invalidates the header pointer we can have received
from snl_create_msg_request(). Always use the hdr returned by
snl_finalize_msg().

Reviewed by:	melifaro
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42223
2023-10-17 08:47:52 +02:00
Brooks Davis 248fe3d348 libprocstat: improve conditional for 32-bit compat
Include support for translating 32-bit auxv vectors on non-64-bit
platforms that aren't riscv (which has no 32-bit ABI support and
probably never will).

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42201
2023-10-16 17:58:49 +01:00
Brooks Davis 8f06fabe39 libprocstat: copy all the 32-bit auxv entries
Use source struct size not the destination struct size so we copy all
the auxv entries, not just the first half of them.

Fix a style issue on an adjacent line.

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42200
2023-10-16 17:58:43 +01:00
Brooks Davis 72a4ee26a7 libprocstat: make sv_name not static
Making this variable static makes is_elf32_sysctl() and callers thread
unsafe.

Use a less absurd length for sv_name.  The longest name in the system is
"FreeBSD ELF64 V2" which tips the scales at 16+1 bytes.  We'll almost
certainly have other problems if we exceed 32 characters.

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42199
2023-10-16 17:58:37 +01:00
Brooks Davis 9735cc0e41 libprocstat: simplify auxv value conversion
Avoid a weird dance through the union and treat all 32-bit values as
unsigned integers.  This avoids sign extension of flags and userspace
pointers.

Reviewed by:	markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42198
2023-10-16 17:58:27 +01:00
Robert Clausecker 5048c1b855 lib/libc/amd64/string: add timingsafe_memcmp() assembly implementation
Conceptually very similar to timingsafe_bcmp(), but with comparison
logic inspired by Elijah Stone's fancy memcmp. A baseline (SSE)
implementation was omitted this time as I was not able to get it to
perform adequately.  Best I got was 8% over the scalar version for
long inputs, but slower for short inputs.

Sponsored by:	The FreeBSD Foundation
Approved by:	security (cperciva)
Inspired by:	https://github.com/moon-chilled/fancy-memcmp
Differential Revision:	https://reviews.freebsd.org/D41696
2023-10-15 15:25:53 -04:00
Robert Clausecker 76c2b331bc lib/libc/amd64/string: add timingsafe_bcmp(3) scalar, baseline implementations
Very straightforward and similar to memcmp(3). The code has
been written to use only instructions specified as having
data operand independent timing by Intel.

Sponsored by:	The FreeBSD Foundation
Approved by:	security (cperciva)
Differential Revision:	https://reviews.freebsd.org/D41673
2023-10-15 15:19:04 -04:00
Ed Maste a5ed6a815e ptsname.3: accommodate upcoming POSIX Issue 8 ptsname_r
POSIX has accepted a proposal[1] to add glibc-compatible ptsname_r.  It
indicates an error by returning the error number, rather than returning
-1 and setting errno.  Update RETURN VALUES in ptsname_r's man page now
to encourage folks to test that the return value != 0 rather than == -1.

[1] https://www.austingroupbugs.net/bug_view_page.php?bug_id=508

Reported by:	Collin Funk
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42204
2023-10-13 22:10:21 -04:00
Kristof Provost 81647eb60e pf: implement start/stop calls via netlink
Implement equivalents to DIOCSTART and DIOCSTOP in netlink. Provide a
libpfctl implementation and add a basic test case, mostly to verify that
we still return the same errors as before the conversion

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42145
2023-10-13 09:53:22 +02:00
Alfonso S. Siciliano d287d3282f
libbsddialog: delete formw dependency
libbsddialog >= 0.3 has a built-in form implementation so delete
formw dependency.

Approved by:		bapt (share/mk maintainer)
Differential Revision:	https://reviews.freebsd.org/D42167
2023-10-12 22:44:15 +02:00
Emmanuel Vadot 0983e80a9a pkgbase: Move blacklist utilities to a new package
Unbloat a bit FreeBSD-utilities.
The only package that will depends on this new one is FreeBSD-ssh
which not anyone have in some setup.
And this will allow to have small pkgbase setup with ssh without
having to bring the bloated FreeBSD-utilities package
Name the package blocklist to reflect upstream futur changes.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D42148
2023-10-11 21:07:05 +02:00
Ed Maste a572dfa1bf ktrace.2: correct kern.ktrace.genio_size sysctl name
The man page had `kern.ktrace.geniosize` but the sysctl node contains an
underscore.

PR:		274274
Reported by:	Ivan Rozhuk
Sponsored by:	The FreeBSD Foundation
2023-10-10 21:23:02 -04: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
Kristof Provost a7191e5d7b pf: add a way to list creator ids
Allow userspace to retrieve a list of distinct creator ids for the
current states.

This is used by pfSense, and used to require dumping all states to
userspace. It's rather inefficient to export a (potentially extremely
large) state table to obtain a handful (typically 2) of 32-bit integers.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42092
2023-10-10 11:48:21 +02:00
Kristof Provost f218b851da libpfctl: introduce state iterator
Allow consumers to start processing states as the kernel supplies them,
rather than having to build a full list and only then start processing.
Especially for very large state tables this can significantly reduce
memory use.

Without this change when retrieving 1M states time -l reports:

    real 3.55
    user 1.95
    sys 1.05
        318832  maximum resident set size
           194  average shared memory size
            15  average unshared data size
           127  average unshared stack size
         79041  page reclaims
             0  page faults
             0  swaps
             0  block input operations
             0  block output operations
         15096  messages sent
        250001  messages received
             0  signals received
            22  voluntary context switches
            34  involuntary context switches

With it it reported:

    real 3.32
    user 1.88
    sys 0.86
          3220  maximum resident set size
           195  average shared memory size
            11  average unshared data size
           128  average unshared stack size
           260  page reclaims
             0  page faults
             0  swaps
             0  block input operations
             0  block output operations
         15096  messages sent
        250001  messages received
             0  signals received
            21  voluntary context switches
            31  involuntary context switches

Reviewed by:	mjg
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42091
2023-10-10 11:48:21 +02:00