Commit Graph

24615 Commits

Author SHA1 Message Date
Christos Margiolis
1ab62c8d06 mixer.3: Fix mandoc -Tlint warnings
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45290
2024-05-23 02:57:49 +02:00
Christos Margiolis
67c89b21b9 mixer(3): Implement mixer_get_path() function
This is better than hardcoding device paths in mixer applications.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45275
2024-05-23 02:57:36 +02:00
Christos Margiolis
5d980fadf7 sound: Handle unavailable devices in various OSS IOCTLs
mixer(8)'s -a option is used to print information about all mixer
devices in the system. To do this, it loops from 0 to
mixer_get_nmixers(), and tries to open "/dev/mixer%d". However, this
approach doesn't work when there are disabled/unregistered mixers in the
system, or when an audio device simply doesn't have a mixer.

mixer_get_nmixers() calls SNDCTL_SYSINFO and returns
oss_sysinfo->nummixers, whose value is the number of currently _enabled_
mixers only. Taking the bug report mentioned below (277615) as an
example, suppose a system with 8 mixer devices total, but 3 of them are
either disabled or non-existent, which means they will not show up under
/dev, meaning we have 5 enabled mixer devices, which is also what the
value of oss_sysinfo->nummixers will be. What mixer(8) will do is loop
from 0 to 5 (instead of 8), and start calling mixer_open() on
/dev/mixer0, up to /dev/mixer4, and as is expected, the first call will
fail right away, hence the error shown in the bug report.

To fix this, modify oss_sysinfo->nummixers to hold the value of the
maximum unit in the system, which, although not necessarily "correct",
is more intuitive for applications that will want to use this value to
loop through all mixer devices.

Additionally, notify applications that a device is
unavailable/unregistered instead of skipping it. The current
implementations of SNDCTL_AUDIOINFO, SNDCTL_MIXERINFO and
SNDCTL_CARDINFO break applications that expect to get information about
a device that is skipped. Related discussion can be found here:
https://reviews.freebsd.org/D45135#1029526

It has to be noted, that other applications, apart from mixer(8), suffer
from this.

PR:		277615
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45256
2024-05-23 02:57:17 +02:00
Andrew Turner
82854693ae arm64: Allow userspace to be built with PAC and BTI
Add the WITH/WITHOUT_BRANCH_PROTECTION build flags. This can be used
to enable the use of pointer authentication (FEAT_PAuth) and branch
target identification (FEAT_BTI) in userspace.

The kernel already handles both of these is userspace, we just need
to enable it.

Leave disabled for a short period for this to settle before enabling.

Reviewed by:	emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D42596
2024-05-22 17:02:26 +00:00
Andrew Turner
53120fbb68 csu: Find the main pointer through the GOT
Use the Global Offset Table to find the location of main in crt1. With
lld the old code would point to main@plt, however ld.bfd fails to link
when main is in a shared library.

Fix this by using the GOT address to find main as it works with both
lld and bfd.

Reviewed by:	jrtc27
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45259
2024-05-22 08:18:10 +00:00
Pierre Pronchery
408572a24e libnvmf: avoid resource leak
In nvmf_host_fetch_discovery_log_page(), the log variable may have been
allocated on the heap during the first loop cycle, and should be
free()'d before exiting upon errors.

Reported by:	Coverity
CID:		1545034
Sponsored by:	The FreeBSD Foundation

Reviewed by: imp,jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1239
2024-05-21 17:41:04 -06:00
Dag-Erling Smørgrav
a4be1eb211 access(2): Discourage use of these system calls.
Fixes:		421025a274
PR:		262895
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45240
2024-05-22 00:35:22 +02:00
Chris Moerz
c80c104cbd
glabel.8: Describe cases related to permissions / existing mounts
Specially, note some requirements for label changes:

- glabel requires write permission on device
- filesystems first need to be unmounted for new labels to persist
  across reboots
- if the affected device node holds the filesystem root, single-user
  mode with r/o mount will be required.

Also, while here, apply some formatting tweaks.

PR:		276724
Reported by:	Alex Matei <matei35@yahoo.com>
Reviewed by:	gbe, jrm, Alexander Ziaee <concussious@runbox.com>
Differential Revision:	https://reviews.freebsd.org/D44394
2024-05-21 15:49:17 -03:00
Dag-Erling Smørgrav
9c7f83bbb4 diff: Nits in tests.
Sponsored by:	Klara, Inc.
2024-05-20 16:27:50 +02:00
Dag-Erling Smørgrav
02d98d1850 libdiff: Add a test for the truncation issue.
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D45218
2024-05-20 15:26:42 +02:00
Brooks Davis
1062db3070 libcxxrt: allow build with gcc13 and --no-undefined-version
GCC 13 supports _Float16 and __int128 on fewer architectures than clang
and thus libcxxrt compiled with gcc13 is sometimes missing related
symbols.  Hack around this by explicitly appending --undefined-version
to LDFLAGS in problematic cases.

Reviewed by:	theraven, dim
Differential Revision:	https://reviews.freebsd.org/D45233
2024-05-17 21:50:57 +01:00
Brooks Davis
25db7bd2fa libgcc_s: fix nonsense defines
These symbols are present on amd64 or i386.

Reported by:	kaktus, jhibbits
Fixes:		98c8caafff libgcc_s: 80-bit long double function are x86-only
2024-05-17 20:05:36 +01:00
Mariusz Zaborski
3cb6c6c9ee libcapsicum: document return values
Reviewed by:	emaste
Requested by:	des
Differential Revision:	https://reviews.freebsd.org/D45222
2024-05-16 20:29:18 +02:00
Alexander Ziaee
1a720cbec5 man filesystems: fix xrefs after move to section 4
Reviewed by: des, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1077
2024-05-16 10:25:29 -06:00
Kyle Evans
8b0682644e Fix the GCC build after _FORTIFY_SOURCE import
We haven't exposed gets(3) in a long time, rip out __gets_chk before
it's too late and something builds a gets(3) user with it enabled.
2024-05-13 11:21:38 -05:00
Gordon Bergling
421025a274 access.2: Mention that lstat(2) should be used for symbolic links
access(), eaccess() and faccessat() will always dereference
symbolic links.

So add a note in the manual page, that lstat(2) should be
used in the case of symbolic links.

PR:	262895
Reviewed by:	gbe, pauamma_gundo.com
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44890
2024-05-13 10:40:12 +02:00
Kyle Evans
9bfd3b4076 Add a build knob for _FORTIFY_SOURCE
In the future, we will Default to _FORTIFY_SOURCE=2 if SSP is enabled,
otherwise default to _FORTIFY_SOURCE=0.  For now we default it to 0
unconditionally to ease bisect across older versions without the new
symbols, and we'll put out a call for testing.

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

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

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

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

Reviewed by:	imp, pauamma_gundo.com (both previous versions), kib
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32306
2024-05-13 00:23:49 -05:00
Cy Schubert
335c7cda12 unbound: Vendor import 1.20.0
Release notes at
	https://www.nlnetlabs.nl/news/2024/May/08/unbound-1.20.0-released/

Security:	The DNSBomb vulnerability CVE-2024-33655

Merge commit 'c2a80056864d6eda0398fd127dc0ae515b39752b' into main
2024-05-10 14:23:43 -07:00
Simon J. Gerraty
f77b5b295d Allow -DNO_STRICT_REGEX to restore historic regex behavior
Allow restoring the behavior of '{' as described in regex(3).
Ie. only treat it as start of bounds if followed by a digit.

If NO_STRICT_REGEX is not defined, the behavior introduced by
commit a4a801688c is retained,
otherwise the previous behavior is restored.

Differential Revision:	https://reviews.freebsd.org/D45134
2024-05-09 18:29:43 -07:00
Kristof Provost
f1612e7087 libpfctl: fix file descriptor leak
pfctl_get_rules_info() opened a netlink socket, but failed to close it again.
Fix this by factoring out the netlink-based function into a _h variant that
takes struct pfctl_handle, and implement pfctl_get_rules_info() based on that,
remembering to close the fd.

While here migrate all in-tree consumers to the _h variant.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-05-09 14:07:07 +02:00
Brooks Davis
ec2b6b16aa libthr: avoid varargs in fcntl and openat interposers
Align these signatures with the ones in syscalls.master (and thus
libsys.h).  There's no reason to do va_args twice and in some ABIs
(e.g,, CheriABI) you can't access fixed arguments as varargs if you
weren't called with varargs signature.

Reviewed by:	imp, kib, jhibbits
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D45126
2024-05-08 15:49:13 +01:00
Kristof Provost
3711515467 carp: support VRRPv3
Allow carp(4) to use the VRRPv3 protocol (RFC 5798). We can distinguish carp and
VRRP based on the protocol version number (carp is 2, VRRPv3 is 3), and support
both from the carp(4) code.

Reviewed by:	glebius
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D44774
2024-05-08 13:19:03 +02:00
John Baldwin
6ca0468a2f libcbor: Ignore errors for unknown #pragmas
libcbor embeds clang-specific #pragmas that GCC then warns about.

Reviewed by:	emaste
2024-05-07 11:44:52 -07:00
Ed Maste
d84fd89ecd dlopen(3): mention fdlopen for capsicum(4)
Capsicum-sandboxed applications generally cannot use dlopen, as absolute
and cwd-relative paths cannot be accessed.  Mention that fdlopen is
useful for sandboxed applications.

PR:		277169
Reviewed by:	markj, oshogbo
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45108
2024-05-07 09:09:59 -04:00
Poul-Henning Kamp
66bee50af7 Remove cross-references to GBDE 2024-05-07 07:35:33 +00:00
Ed Maste
2d29d2eceb clock_gettime.2: fix markup
The CLOCK_* constants are "defined variable or preprocessor constants"
and so use .Dv.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45106
2024-05-06 17:52:22 -04:00
John Baldwin
a7db82cfd9 nvmf_tcp: Correct tests for PDU direction
Add parentheses to ensure the correct order of operations.

Reported by:	GCC
2024-05-06 14:03:48 -07:00
Dimitry Andric
6f44401900 lib/clang: clean out old llvm/clang Sparc target remnants
The WITH_LLVM_TARGET_ENABLE_SPARC option was removed a long time ago,
but some ifdefs were still laying around, so clean them up.

PR:		276104
MFC after:	3 days
2024-05-04 19:34:18 +02:00
Ed Maste
60a517b66a libfido2: update to 1.14.0
Sponsored by:	The FreeBSD Foundation
2024-05-04 12:51:08 -04:00
Dimitry Andric
894cb08f0d Fixup: Merge llvm-project release/18.x llvmorg-18.1.5-0-g617a15a9eac9
Update version numbers, config headers, etc. Git tricked me into losing
these before pushing.

PR:		276104
Fixes:		d67fc74b9249
MFC after:	3 days
2024-05-04 17:49:57 +02:00
Alexander Ziaee
9a62cdc013 intro.2 as errno.2: Use the name macro for errno
Reviewed by: imp
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1192
2024-05-04 08:56:10 -06:00
Alexander Ziaee
69ff2d754c intro.2: Add sys/syscall.h to SYNOPSIS
MFC after:	1 week
Co-authored-by: brooks
Reviewed by:	brooks, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1192
2024-05-04 08:56:06 -06:00
Alexander Ziaee
6dfbe695c3 intro.2 as errno.2: Update maximum hard link limit
MFC after:	1 week
Co-authored-by: brooks
Reviewed by:	brooks, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1192
2024-05-04 08:55:59 -06:00
Konstantin Belousov
b27eb9ce96 __cxa_thread_call_dtors(3): fix dtor pointer validity check
When checking for the destructor pointer belonging to some still
loaded dso, do not limit the possible dso to the one instantiated the
destructor. For instance, dso could set up the dtr pointer to a function
from libcxx.

PR:	278701
Reported by:	vd
Reviewed by:	dim, emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45074
2024-05-04 02:23:15 +03:00
Baptiste Daroussin
a25e0ba57e libarchive: fix thread autodetermination for zstd compression format
The libarchive code uses sysconf(3) to determine the number of threads
when 0 has been given as the number of thread to use

MFC after:	3 days
2024-05-03 15:39:37 +02:00
John Baldwin
2da066ef6d libnvmf: Add internal library to support NVMe over Fabrics
libnvmf provides APIs for transmitting and receiving Command and
Response capsules along with data associated with NVMe commands.
Capsules are represented by 'struct nvmf_capsule' objects.

Capsules are transmitted and received on queue pairs represented by
'struct nvmf_qpair' objects.

Queue pairs belong to an association represented by a 'struct
nvmf_association' object.

libnvmf provides additional helper APIs to assist with constructing
command capsules for a host, response capsules for a controller,
connecting queue pairs to a remote controller and optionally
offloading connected queues to an in-kernel host, accepting queue pair
connections from remote hosts and optionally offloading connected
queues to an in-kernel controller, constructing controller data
structures for local controllers, etc.

libnvmf also includes an internal transport abstraction as well as an
implementation of a userspace TCP transport.

libnvmf is primarily intended for ease of use and low-traffic use cases
such as establishing connections that are handed off to the kernel.
As such, it uses a simple API built on blocking I/O.

For a host, a consumer first populates an 'struct
nvmf_association_params' with a set of parameters shared by all queue
pairs for a single association such as whether or not to use SQ flow
control and header and data digests and creates a 'struct
nvmf_association' object.  The consumer is responsible for
establishing a TCP socket for each queue pair.  This socket is
included in the 'struct nvmf_qpair_params' passed to 'nvmf_connect' to
complete transport-specific negotiation, send a Fabrics Connect
command, and wait for the Connect reply. Upon success, a new 'struct
nvmf_qpair' object is returned.  This queue pair can then be used to
send and receive capsules.  A command capsule is allocated, populated
with an SQE and optional data buffer, and transmitted via
nvmf_host_transmit_command.  The consumer can then wait for a reply
via nvmf_host_wait_for_response.  The library also provides some
wrapper functions such as nvmf_read_property and nvmf_write_property
which send a command and wait for a response synchronously.

For a controller, a consumer uses a single association for a set of
incoming connections.  A consumer can choose to use multiple
associations (e.g. a separate association for connections to a
discovery controller listening on a different port than I/O
controllers).  The consumer is responsible for accepting TCP sockets
directly, but once a socket has been accepted it is passed to
nvmf_accept to perform transport-specific negotiation and wait for the
Connect command.  Similar to nvmf_connect, nvmf_accept returns a newly
construct nvmf_qpair.  However, in contrast to nvmf_connect,
nvmf_accept does not complete the Fabrics negotiation.  The consumer
must explicitly send a response capsule before waiting for additional
command capsules to arrive.  In particular, in the kernel offload
case, the Connect command and data are provided to the kernel
controller and the Connect response capsule is sent by the kernel once
it is ready to handle the new queue pair.

For userspace controller command handling, the consumer uses
nvmf_controller_receive_capsule to wait for a command capsule.
nvmf_receive_controller_data is used to retrieve any data from a
command (e.g. the data for a WRITE command).  It can be called
multiple times to split the data transfer into smaller sizes.
nvmf_send_controller_data is used to send data to a remote host in
response to a command.  It also sends a response capsule indicating
success, or an error if an internal error occurs.  nvmf_send_response
is used to send a response without associated data.  There are also
several convenience wrappers such as nvmf_send_success and
nvmf_send_generic_error.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44710
2024-05-02 16:28:16 -07:00
Brooks Davis
723e60a278 libgcc_s: __extendxftf2 and __trunctfxf2 are amd64-only
__extendxftf2 and __trunctfxf2 build on amd64 not aarch64 and riscv.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45052
2024-05-02 18:13:23 +01:00
Michael Tuexen
eee88ef45f sctp: document sctp_recvmsg as implemented
PR:		275990
MFC after:	3 days
2024-05-02 15:17:43 +02:00
Brooks Davis
98c8caafff libgcc_s: 80-bit long double function are x86-only
Don't try to expose them on other architectures.

Reviewed by:	arichardson
Differential Revision:	https://reviews.freebsd.org/D45028
2024-05-01 21:49:47 +01:00
Brooks Davis
397d8f3c36 libsys: don't try to expose freebsd7___semctl
This has always been in libc and never exported directly.  I accidently
included it along side some freebsd11_* symbols based on a tree where I
moved semctl(2).

Fixes:		df1a09ba52 libsys: expose a few more symbols for libc's use
2024-04-30 19:06:10 +01:00
Kristof Provost
5824df8d99 pf: convert DIOCGETSTATUS to netlink
Introduce pfctl_get_status_h() because we need the pfctl_handle. In this variant
use netlink to obtain the information.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-04-29 16:32:23 +02:00
Kristof Provost
044243fcc9 libpfctl: allow access to the fd
pfctl_open() opens both /dev/pf and a netlink socket. Allow access to the /dev/
pf fd via pfctl_fd().
This means that libpfctl users no longer have to open /dev/pf themselves for any
calls that are not yet available in libpfctl.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
MFC after:	2 weeks
2024-04-29 16:32:23 +02:00
Kristof Provost
a3f7176523 libpfctl: fix incorrect pcounters array size
The array is 2 x 2 x 2, not 2 x 2 x 3.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
MFC after:	2 weeks
2024-04-29 16:32:23 +02:00
Dag-Erling Smørgrav
c28253ecde libulog: Make sure ut_line, ut_user, ut_host are terminated.
MFC after:	3 days
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D45004
2024-04-29 12:11:37 +02:00
Martin Matuska
13d826ff94 libarchive: merge from vendor branch
Libarchive 3.7.4 + three fixes from master

Security fixes:
 #2135 rar: Fix OOB in rar e8 filter (CVE-2024-26256)
 #2145 zip: Fix out of boundary access
 #2148 rar: Fix OOB in rar delta filter
 #2149 rar: Fix OOB in rar audio filter

Important bugfixes:
 #2131 7zip: Limit amount of properties
 #2110 bsdtar: Fix error handling around strtol() usages
 #2116 passphrase: Never allow empty passwords
 #2124 rar: Fix "File CRC Error" when extracting specific rar4 archives
 #2123 xar: Avoid infinite link loop
 #2150 xar: Fix another infinite loop and expat error handling
 #2108 zip: Update AppleDouble support for directories
 #2071 zstd: Implement core detectiongit

PR:		278588 (exp-run)
MFC after:	1 day
2024-04-29 10:17:53 +02:00
CismonX
d289382897 rights.4: various corrections on capability rights
- A file descriptor obtained from accept(2), accept4(2) and openat(2)
  is not always assigned all capability rights.  Instead, it inherits
  capability rights from the "parent" socket/dir file descriptor.
- getdents(2) and getdirentries(2) requires CAP_READ.
- openat(2) with O_WRONLY|O_TRUNC does not require CAP_SEEK.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1207
2024-04-28 22:48:31 -06:00
Ricardo Branco
78444b5ade glabel: Add support for Linux swap
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1205
2024-04-28 22:39:47 -06:00
Lexi Winter
1b3c07bed6 package: move OpenBSM auditing into its own package
Move auditing runtime (auditd, etc.) into the new FreeBSD-audit package.
Also move the runtime OpenBSM manual pages from libbsm into auditd so
they get installed with the right package.

Add an UPDATING entry noting the new packages.

Reviewed by: imp, manu
Pull Request: https://github.com/freebsd/freebsd-src/pull/1197
2024-04-28 22:33:06 -06:00
Mateusz Piotrowski
6662c2312e gettimeofday.2: Do mention improbable future removal
As kib@ noted:

> Obviously gettimeofday(2) is not going to be removed
> even in the far future.

Reported by:	kib
Fixes:		4395d3ced5 Document that gettimeofday() is obsolescent
MFC after:	3 days
2024-04-28 20:11:22 +02:00
Dimitry Andric
514773a548 Skip building libclang_rt when WITHOUT_CLANG is used
As noted in bug 277096, when building a pkgbase repository using
WITHOUT_CROSS_COMPILER and WITHOUT_TOOLCHAIN (which sets WITHOUT_CLANG),
the following residual files are left over:

/usr/lib/clang/18/lib/freebsd/libclang_rt.asan-x86_64.so
/usr/lib/clang/18/share/asan_ignore_list.txt
/usr/lib/clang/18/share/cfi_ignore_list.txt
/usr/lib/clang/18/share/msan_ignore_list.txt

This is because the lib/libclang_rt directory is still descended into,
even if WITHOUT_CLANG is used. Fix it by not descending into the
libclang_rt directory in that case.

PR:		277096
Reported by:	Siva Mahadevan <me@svmhdvn.name>
MFC after:	3 days
2024-04-25 17:05:29 +02:00
Mateusz Piotrowski
4395d3ced5 Document that gettimeofday() is obsolescent
Reported by:	kaktus
Reviewed by:	kaktus, pstef
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D23942
2024-04-25 11:42:59 +02:00
Brooks Davis
78101d437a syscalls.master: correct return type of {read,write}v
This was missed when read/write, etc were updated to return ssize_t.

Fixes:		2e83b28161 Fix a few syscall arguments to use size_t instead of u_int.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D44930
2024-04-24 20:48:46 +01:00
Alan Somers
4b7949144c geli.8: add some notes regarding performance tuning
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D44908
2024-04-24 07:53:37 -06:00
Karl Tomlinson
e75a1bbc23 pow,powf(3),__ieee754_rem_pio2(f): Avoid negative integer left shift UB
A compiler clever enough to know that z is positive with a non-zero
biased exponent could, for example, optimize away the scalbnf(z,n) in
pow() because behavior for left shift of negative values is undefined.
`n` is negative when y*log2(|x|) < -0.5.  i.e. |x^y| < sqrt(0.5)

The intended behavior for operator<< in this code is to shift the two's
complement representation of the first operand.

In the pow() functions, the result is added to the IEEE 754 exponent of
z = 2^y'.  n may be negative enough to underflow the biased IEEE 754
exponent below zero, which is manifested in the sign bit of j
(which would correspond to the IEEE 754 sign bit).

The conversion from uint32_t to int32_t for out-of-int32_t-range values
is implementation defined.  The assumed behavior of interpreting the
uint32_t value as a two's complement representation of a signed value
is already assumed in many parts of the code, such as uses of
GET_FLOAT_WORD() with signed integers.

This code passes all the current tests, and makes some out of tree
fuzzing tests pass again rather than hit UB (detailed in the commentary
of the pull request).

Signed-off-by: Karl Tomlinson <karlt+@karlt.net>
Reviewed by: imp, steve kargl, dim
Pull Request: https://github.com/freebsd/freebsd-src/pull/1137
2024-04-23 14:04:07 -06:00
Konstantin Belousov
aa66995b4c libc printf_render_errno(): do not use strerror()
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44916
2024-04-23 22:44:07 +03:00
Konstantin Belousov
bac9d7e8f2 libc: minor style, wrap long lines
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44916
2024-04-23 22:44:07 +03:00
Konstantin Belousov
f887667694 __vprintf(): switch from strerror() to strerror_rl()
This eliminates the use of non-thread-safe function in printf*() family,
and make the call locale-aware.  Also, it stops obliterating the
strerror() static buffer, which aligns with the POSIX requirement that
implementations must behave as if no standard-mandated functions call
strerror().

PR:	278556
Reported by:	Jonathan Gruber <jonathan.gruber.jg@gmail.com>
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44916
2024-04-23 22:43:01 +03:00
Konstantin Belousov
92771bc00a libc: make strerror_rl() usable for libc
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44916
2024-04-23 22:40:29 +03:00
Konstantin Belousov
fb2ab7ce52 Add test for pthread_sigqueue(3)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44867
2024-04-23 19:51:31 +03:00
Konstantin Belousov
220aa0f450 libthr: add pthread_sigqueue(3)
PR:	278459
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44867
2024-04-23 19:51:22 +03:00
Konstantin Belousov
dcc180c51b sigqueue(2): Document __SIGQUEUE_TID
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44867
2024-04-23 19:51:10 +03:00
Christopher Davidson
96a2e036b7 Update manual page references and macros to align to mandoc syntax
xlocale.3: Comment out reference to atof_l(3), atoi_l(3), atol_l(3), atoll_l(3)
  These manual page references do not exist.

lagg.4: Change the reference for /etc/rc.conf from a reference link
  .Xr -> .Pa based on the context within the manual page it is used.

buf.9: Remove .Xr entries from the file
  The buf.9 manual page contains a commented out .Xr reference.
  The <filmmein> 9 entry is a placeholder and has been removed for
  clarity.

Reviewed by:	mhorne
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1114
2024-04-23 12:50:54 -03:00
rilysh
bac2eea13a swab.c(libc): use a simplified version of byte swapping
This version of swab function simplifies the logic of swapping adjacent
bytes. Previous version of swab() used an arbitrary unrolling, which was
relevant back in the day but unnecessary for modern compilers, as if the
input size is known at compile time, they can do it automatically.

This version of swab() is inspired by musl.
A similar version can be found at: https://github.com/openbsd/src/blob/master/lib/libc/string/swab.c

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1086
2024-04-22 23:01:54 -06:00
Lexi Winter
7209444a80 package: move cron into its own package
Reviewed by: imp, manu, Mina Galic
Pull Request: https://github.com/freebsd/freebsd-src/pull/1172
2024-04-22 22:36:35 -06:00
Lexi Winter
50ecbc5142 libipsec: make const-correct
- add const to the appropriate places in the libipsec public API and the
  relevant internal functions needed to support that.

- replace caddr_t with c_caddr_t in ipsec_dump_policy()

- update the ipsec_dump_policy manpage to use c_caddr_t (this manpage
  was already wrong as it had "char *" instead of caddr_t previously).

While here, update pfkeyv2.h to not cast away const in the PFKEY_*()
macros.

This should not cause any ABI changes as the actual types have not
changed.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1099
2024-04-22 22:36:34 -06:00
Alan Somers
c0f02dcd4c geli.8: minor proofreading
MFC after:	3 days
Sponsored by:	Axcient
Reviewed by:	imp, pauamma (manpages)
Differential Revision: https://reviews.freebsd.org/D44907
2024-04-22 15:54:56 -06:00
Brooks Davis
6077246e88 libcxxrt: align more with libc/Makefile
Use src.opts.mk instead of bsd.own.mk and define PACKAGE first.

Fixes:		da77a1b4f0 libcxxrt: don't export nonexistant symbols
2024-04-22 21:28:51 +01:00
Brooks Davis
80ffc7398b libsys/arm: make vfork less of an outlier
Following the pattern of other architectures, make __sys_vfork the main
symbol and _vfork and vfork weak aliases.  This avoids the need to
special case vfork in the generated list of symbols.

Differential Revision:	https://reviews.freebsd.org/D44330
2024-04-22 21:28:51 +01:00
Brooks Davis
7448408656 Make __libsys_interposing_slot libsys only
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44881
2024-04-22 21:28:26 +01:00
Brooks Davis
672464f756 libthr: always use __libc_interposing_slot()
Use __libc_interposing_slot() in favor of __libsys_interposing_slot() so
that the interposing interface is entierly between libc and libthr with
libsys only involved as an implementation detail.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44880
2024-04-22 21:28:26 +01:00
Dimitry Andric
911a6479e1 libcxxrt: define SHLIBDIR before including bsd.own.mk
Otherwise bsd.own.mk overrides it, causing libcxxrt.so.1 to be
erroneously installed into /usr/lib.

Also add an ObsoleteFiles.inc entry, for removing the bad copy.

Reported by:	Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Fixes:		da77a1b4f0
2024-04-22 20:46:45 +02:00
Alexander Motin
278d695094 libpmc: Import AMD Zen 4 PMU events
MFC after:	1 week
2024-04-20 11:54:04 -04:00
Dimitry Andric
dfa39133b3 Merge llvm-project release/18.x llvmorg-18.1.4-0-ge6c3289804a6
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project release/18.x llvmorg-18.1.4-0-ge6c3289804a6.

PR:		276104
MFC after:	3 days
2024-04-20 16:02:57 +02:00
Gordon Bergling
bbef63ec27 timerfd.2: Remove a double word
- s/is is/is/

MFC after:	3 days
2024-04-20 11:31:25 +02:00
Ricardo Branco
a8fd0a5f44 glabel: Remove support for old reiserfs
Reviewed by: imp, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1101
2024-04-19 16:48:28 -06:00
Alexander Ziaee
de525c502a intro.2: Integrate introduction with state of page
Reviewed by: imp, brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/1065
2024-04-19 16:30:32 -06:00
Alexander Ziaee
d846f33bb6 intro.2: Section RETURN VALUES is actually ERRORS
Reviewed by: imp, brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/1065
2024-04-19 16:30:27 -06:00
Alexander Ziaee
4696ca7baf intro.2: Add FILES mentioning table of syscalls
Reviewed by: imp, brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/1065
2024-04-19 16:30:23 -06:00
Alexander Ziaee
9e8df7900f intro.2: Tweak grammar and syntax for consistency
Reviewed by: imp, brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/1065
2024-04-19 16:30:19 -06:00
Alexander Ziaee
bcc57e9715 intro.2: Import HISTORY from OpenBSD but our style
Reviewed by: imp, brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/1065
2024-04-19 16:30:14 -06:00
Brooks Davis
f0bd655a61 libc/quad: further narrow list of i386 symbols
It's unclear to me why lld didn't complain about these are they aren't
present and haven't been.  Instead ld.bfd complained.

Reviewed by:	dim
Fixes:		6e6cd03c91 libc/quad: narrow list of symbols exposed on i386
Differential Revision:	https://reviews.freebsd.org/D44879
2024-04-19 22:56:13 +01:00
Brooks Davis
44e89340fe libgcc_s: expose __divmoddi4 on i386
GCC has used this for some time (since 7.0) and apparently we were
getting away with using the hidden symbol, but when linking with
--no-undefined-version we get an error unless it's properly exported.
(For anyone who wonders at the assymetry, __udivmoddi4 is indeed much
older and was introduced with GCC 3.0.)

MFC after:	3 days
Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D44878
2024-04-19 22:56:13 +01:00
Brooks Davis
0b9e358580 libgcc_{eh,s}: restore __*_frame_info symbols post llvm18
The upstream llvm commit 5eb44df1b64d made the addition of these GCC
compatability symbols dependent on build configuration rather than
hardcoded for amd64, i386, and powerpc.  Reenable them.

Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D44877
2024-04-19 22:56:13 +01:00
Brooks Davis
6e83504c60 Revert "lib{c,sys}: normalize export of openat, setcontext, and swapcontext"
I put the symbols in the wrong file (should have been
lib/libc/sys/Symbol.map), added a duplicate pdfork entry due to a botch
rebase, and there seems to be a issue with gcc13/binutils not exposing
the symbols so revert the whole thing while I debug.

This reverts commit ee632fb9eb.
2024-04-19 22:25:04 +01:00
Brooks Davis
ee632fb9eb lib{c,sys}: normalize export of openat, setcontext, and swapcontext
List them in the symbol map rather than using the __sym_default to
expose them.  This will allow later improvements in the stub
implementations in libc.so.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44113
2024-04-17 23:39:46 +01:00
Brooks Davis
df1a09ba52 libsys: expose a few more symbols for libc's use
These private symbols are used by libc so expose as we do with
auxargs bits rather then relying on duplicate implementations in libc.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D44114
2024-04-17 23:39:46 +01:00
Dimitry Andric
f276adc148 libcompiler_rt Makefile.inc: update _Float16/__bf16 checks
Clang supports __bf16 for riscv from version 18.0 onwards, so update the
checks for it. While here, rewrite the checks so they are hopefully more
readable, and also handle gcc a little better.

In addition, define COMPILER_RT_HAS_FLOAT16 and COMPILER_RT_HAS_BFLOAT16
when these features should be available, since there are some parts in
compiler-rt that check for these defines.

PR:		276104
MFC after:	1 month
2024-04-17 22:20:47 +02:00
Martin Matuska
7d03ec3306 libarchive: add two missing package files to libarchive tests
MFC after:	1 week
2024-04-17 09:58:32 +02:00
Martin Matuska
b9128a37fa libarchive: merge from vendor branch
Libarchive 3.7.3

New features:
  #1941 uudecode filter: support file name and file mode in raw mode
  #1943 7-zip reader: translate Windows permissions into UNIX
        permissions
  #1962 zstd filter now supports the "long" write option
  #2012 add trailing letter b to bsdtar(1) substitute pattern
  #2031 PCRE2 support
  #2054 add support for long options "--group" and "--owner" to tar(1)

Security fixes:
  #2101 Fix possible vulnerability in tar error reporting introduced
        in f27c173

Important bugfixes:
  #1974 ISO9660: preserve the natural order of links
  #2105 rar5: fix infinite loop if during rar5 decompression the last
        block produced no data
  #2027 xz filter: fix incorrect eof at the end of an lzip member
  #2043 zip: fix end-of-data marker processing when decompressing zip
        archives

PR:		278315 (exp-run)
MFC after:	1 week
2024-04-16 23:39:31 +02:00
Brooks Davis
e0919a4bac libc/arm: export __signalcontext not _signalcontext
The former exists and architectures other than aarch64 and riscv provide
it.  The later does not exist.

Differential Revision:	https://reviews.freebsd.org/D44329
2024-04-16 22:14:21 +01:00
Brooks Davis
da77a1b4f0 libcxxrt: don't export nonexistant symbols
Remove version entries that we don't build.

Add an arm specific Version.map and for other targets run the files
through sed to handle int vs long in new and delete.

Ideally we'd use the SYMBOL_MAPS functionality to preprocess with cpp,
but it doesn't currently handle C++ symbols so be annoyingly duplicative
for now.

Differential Revision:	https://reviews.freebsd.org/D44325
2024-04-16 22:14:21 +01:00
Brooks Davis
b457144cea libgcc_s: exclude symbols not present on some arches
arm, aarch64, and riscv lack some/all frame_info interfaces.
arm and powerpc lack some numeric functions.

Differential Revision:	https://reviews.freebsd.org/D44324
2024-04-16 22:14:21 +01:00
Brooks Davis
3f82d8345b libgcc_s: only export 128-bit int APIs when available
These interfaces are only compiled when the platform supports 128-bit
ints.  Use a CRT_HAS_128BIT guard similar to the one used in the
compiler_rt sources.

Reviewed by:	dim
Differential Revision:	https://reviews.freebsd.org/D44323
2024-04-16 22:14:21 +01:00
Brooks Davis
b8df8b0c2e libgcc_s: only export 128-bit long double when available
These functions are only available on aarch64 and riscv so only try to
export them on those architectures.

Differential Revision:	https://reviews.freebsd.org/D44322
2024-04-16 22:14:21 +01:00
Brooks Davis
35b3504ee6 librpcsec_gss: don't export non-existant symbols
rpc_gss_mesh_to_oid was never implemented.

This doesn't seem to be any reason why we would need to export the _stub
functions, but it's also a little unclear to me why the linker thinks
they aren't present.  Perhaps they should be static.

Differential Revision:	https://reviews.freebsd.org/D44248
2024-04-16 22:14:21 +01:00
Brooks Davis
63b179b68d libc: don't try to export __sF
This symbol has been static since 2008 (commit 1e98f88776).

Differential Revision:	https://reviews.freebsd.org/D44188
2024-04-16 22:14:20 +01:00
Brooks Davis
88fcb61799 libc: don't try to export _nsdbtdump
It is only present when compiling nsdispatch.c with -D_NSS_DEBUG and we
provide no mechanism to do so.

Differential Revision:	https://reviews.freebsd.org/D44187
2024-04-16 22:14:20 +01:00
Brooks Davis
4d6722ec69 libc: don't try to export mexitcount
This requires that mcount.c be compiled with -DGUPROF and we provide no
mechanism to do so.

Differential Revision:	https://reviews.freebsd.org/D44186
2024-04-16 22:14:20 +01:00