Commit graph

24685 commits

Author SHA1 Message Date
Jessica Clarke
b162fc3f30 gpart: Add u-boot-env alias for U-Boot's environment GPT partition UUID
This is a platform-independent UUID, and this is the name U-Boot uses.

MFC after:	1 week
2024-09-02 23:21:18 +01:00
Olivier Certner
06986e8999
pam_xdg: Fix user xdg runtime directory's descriptor leak
Fixes:          6e69612d5d ("pam: Add pam_xdg module")
MFC after:      3 days
Sponsored by:   The FreeBSD Foundation
2024-08-30 16:08:14 +02:00
Steve Kargl
41e016289f Improve accuracy of asinf(3) and acosf(3)
This uses a better rational approximation to improve the accuracy of
both functions. For exhaustive testing of asinf(3) in the interval, the
current libm gives:

    % ./tlibm asin -fPED -x 0x1p-12f -X 1
    Interval tested for asinf: [0.000244141,1]
           ulp <= 0.5:  97.916% 98564994 |  97.916% 98564994
    0.5 <  ulp <  0.6:  2.038% 2051023 |  99.953% 100616017
    0.6 <  ulp <  0.7:  0.047%   47254 | 100.000% 100663271
    0.7 <  ulp <  0.8:  0.000%      25 | 100.000% 100663296
    Max ulp: 0.729891 at 5.00732839e-01

which isn't too bad given that much of the computation is actually done
in double floating point.

With the new rational approximation, exhaustive testing yields:

    % ./tlibm asin -fPED -x 0x1p-12f -X 1
    Interval tested for asinf: [0.000244141,1]
           ulp <= 0.5:  99.711% 100372643 |  99.711% 100372643
    0.5 <  ulp <  0.6:  0.288%  290357 | 100.000% 100663000
    0.6 <  ulp <  0.7:  0.000%     296 | 100.000% 100663296
    Max ulp: 0.636344 at 5.09706438e-01

Similarly, for exhaustive testing of asinf(3) in the interval, the
current libm gives:

    % ./tlibm acos -fPED -x -1 -X -0x1p-12f
    Interval tested for acosf: [-1,-0.000244141]
           ulp <= 0.5:  97.008% 97651921 |  97.008% 97651921
    0.5 <  ulp <  0.6:   2.441%  2457242 |  99.450% 100109163
    0.6 <  ulp <  0.7:   0.472%   475503 |  99.922% 100584666
    0.7 <  ulp <  0.8:   0.071%    71309 |  99.993% 100655975
    0.8 <  ulp <  0.9:   0.007%     7319 | 100.000% 100663294
    0.9 <  ulp <  1.0:   0.000%        2 | 100.000% 100663296
    Max ulp: 0.914007 at -5.01484931e-01

    % ./tlibm acos -fPED -x 0x1p-12f -X 1
    Interval tested for acosf: [0.000244141,1]
           ulp <= 0.5:  97.317% 97962530 |  97.317% 97962530
    0.5 <  ulp <  0.6:   2.340%  2355182 |  99.657% 100317712
    0.6 <  ulp <  0.7:   0.314%   316134 |  99.971% 100633846
    0.7 <  ulp <  0.8:   0.029%    29450 | 100.000% 100663296
    Max ulp: 0.796035 at 4.99814630e-01

With the new rational approximation, exhaustive testing yields:

    % ./tlibm acos -fPED -x -1 -X -0x1p-12f
    Interval tested for acosf: [-1,-0.000244141]
           ulp <= 0.5:  97.010% 97653245 |  97.010% 97653245
    0.5 <  ulp <  0.6:   2.442%  2458373 |  99.452% 100111618
    0.6 <  ulp <  0.7:   0.473%   476012 |  99.925% 100587630
    0.7 <  ulp <  0.8:   0.068%    68603 |  99.993% 100656233
    0.8 <  ulp <  0.9:   0.007%     7063 | 100.000% 100663296
    Max ulp: 0.896189 at -5.04511118e-01

    % ./tlibm acos -fPED -x 0x1p-12f -X 1
    Interval tested for acosf: [0.000244141,1]
           ulp <= 0.5:  97.650% 98298175 |  97.650% 98298175
    0.5 <  ulp <  0.6:   2.028%  2041709 |  99.679% 100339884
    0.6 <  ulp <  0.7:   0.292%   293555 |  99.970% 100633439
    0.7 <  ulp <  0.8:   0.030%    29857 | 100.000% 100663296
    Max ulp: 0.775875 at 4.91849005e-01

PR:		281001
MFC after:	1 week
2024-08-29 21:44:48 +02:00
Konstantin Belousov
37bb988410 open(2): devfs is in section 4 on HEAD
Noted by:	yuripv
Fixes:	f5a37f8dd3
2024-08-28 01:23:20 +03:00
Jose Luis Duran
02c23c3b5a open(2): Extend EINVAL's description
If O_CREAT is specified, the last component of the path argument can
contain invalid characters, and return EINVAL on some file systems.

PR:	281033
Differential revision:	https://reviews.freebsd.org/D46450
MFC after:   1 week
2024-08-28 01:09:33 +03:00
Jose Luis Duran
33f58ac079 rename(2): Extend EINVAL's description
On some file systems, the last component of the destination path can
contain invalid characters and return EINVAL.

PR:	281033
Differential revision:	https://reviews.freebsd.org/D46450
MFC after:   1 week
2024-08-28 01:09:33 +03:00
Jose Luis Duran
f5a37f8dd3 open(2): mandoc -T lint
Lint the manual, addressing almost all requests.

Differential revision:	https://reviews.freebsd.org/D46450
MFC after:   1 week
2024-08-28 01:09:33 +03:00
Edward Tomasz Napierala
d0675399d0 capsicum: allow subset of wait4(2) functionality
The usual way of handling process exit exit in capsicum(4) mode is
by using process descriptors (pdfork(2)) instead of the traditional
fork(2)/wait4(2) API. But most apps hadn't been converted this way,
and many cannot because the wait is hidden behind a library APIs that
revolve around PID numbers and not descriptors; GLib's
g_spawn_check_wait_status(3) is one example.

Thus, provide backwards compatibility by allowing the wait(2) family
of functions in Capsicum mode, except for child processes created by
pdfork(2).

Reviewed by:	brooks, oshogbo
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D44372
2024-08-27 17:22:12 +02:00
Maxim Konovalov
6aee1dc480 pam_xdg.8: the module option name corrected
PR:	280994
2024-08-22 21:07:10 +00:00
Brooks Davis
5680cf6dc6 jemalloc: don't expose 3.0 compat symbols
Don't provide default linkage for jemalloc 3.0 compatability symbols.
We stopped declaring these interfaces with the introduction of jemalloc
4.0 prior to FreeBSD 11.0.  Any code using them would have had to
declare them manually so stop declaring them and export the symbols
directly for compatability.  Arguably they should be x86 only as they
were never declared on other Tier-1 architectures.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D46407
2024-08-22 17:08:24 +01:00
John Baldwin
297a9e552b libcxxrt: Add a stub implementation of __cxa_call_terminate
This function is called by GCC 14 if a destructor invoked during
exception unwinding throws an exception.

Reviewed by:	emaste
Obtained from:	libcxxrt commit 391a3dcc1054e18c2f0dff4e14d6d79ac95399d7
Differential Revision:	https://reviews.freebsd.org/D46004
2024-08-21 13:37:48 -04:00
Pietro Cerutti
1af7d5f389 libfetch: don't include fragments in HTTP requests
Summary:
Fragments are reserved for client-side processing, see
https://www.rfc-editor.org/rfc/rfc9110.html#section-7.1

Also, some servers don't like to receive HTTP requests with fragments.

```
$ fetch 'https://dropbox.com/a/b'
fetch: https://dropbox.com/a/b: Not Found

$ fetch 'https://dropbox.com/a/b#'
fetch: https://dropbox.com/a/b#: Bad Request
```

This is a real-world scenario, where some download link from dropbox
(eventually) redirects to an URL with a fragment:

```
$ fetch -v 'https://www.dropbox.com/sh/<some>/<thing>?dl=1' 2>&1 | grep requesting
requesting https://www.dropbox.com/sh/<some>/<thing>?dl=1
requesting https://www.dropbox.com/scl/fo/<foo>/<bar>?rlkey=<baz>&dl=1
requesting https://<boo>.dl.dropboxusercontent.com/zip_download_get/<some-long-strig>#
```

See how the last redirect ends with a `#`.

Currently, libfetch includes the ending fragment and makes it impossible
to download the file.

Differential Revision:	https://reviews.freebsd.org/D46318
MFC after:		2 weeks
2024-08-21 12:35:27 +00:00
Andrew Turner
024248c933 libc/aarch64: Remove an unneeded weak symbol
The index symbol doesn't belong in memcpy.S as it is already in
strchr.S where it belongs.

Sponsored by:	Arm Ltd
2024-08-21 10:16:10 +00:00
Steve Kargl
213eb102ae
msun: Fix typo in comment
PR:		280965
MFC after:	3 days
2024-08-21 14:59:07 +08:00
Mark Johnston
d06fe346ec libgeom: Avoid fixed remappings of the devstat device
libgeom maintains a quasi-private mapping of /dev/devstat, which might
grow over time if new devices appear.  When the mapping needs to be
expanded, the old mapping is passed as a hint, but this appears to be
unnecessary.

Simplify and improve things a bit:
- stop passing a hint when remapping,
- don't creat a mapping in geom_stats_open(), as geom_stats_resync() will
  create it for us,
- check for errors from munmap().

Reviewed by:	imp, asomers
Tested by:	asomers
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D46294
2024-08-19 16:02:59 +00:00
Cy Schubert
5685098846 unbound: Vendor import 1.21.0
Release notes at
	https://nlnetlabs.nl/news/2024/Aug/15/unbound-1.21.0-released/

MFC after:	1 week

Merge commit '96ef46e5cff01648c80c09c4364d10bc6f58119d'
2024-08-16 10:03:34 -07:00
Fernando Apesteguía
5ab6ed93cd faccessat(2): Honor AT_SYMLINK_NOFOLLOW
Make the system call honor `AT_SYMLINK_NOFOLLOW`.

Also enable this from `linux_faccessat2` where the issue arised the first time.
Update manual pages accordingly.

PR:			275295
Reported by:		kenrap@kennethraplee.com
Approved by:		kib@
Differential Revision:	https://reviews.freebsd.org/D46267
2024-08-11 17:49:06 +02:00
Mark Johnston
c0946aee5b libc tests: Add some test cases for recursive exiting
Derived from tests posted by kib in D46108.  I made one of them use a
pthread barrier instead of sleeping.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D46176
2024-08-07 16:06:11 +00:00
Mark Johnston
5132e16e1f libc tests: Rename the quick_exit test file, fix style
Call it libc_exit_test instead of exit_test because the NetBSD test
suite already has a file with the latter name.  This is in preparation
for adding other exit()-related tests.

MFC after:	2 weeks
2024-08-07 16:05:16 +00:00
Konstantin Belousov
0c00dbfeb0 msun/ld80/e_powl.c: make powl() thread-safe by making static variables thread-local
Reported and tested by:	Paul Zimmermann <Paul.Zimmermann@inria.fr>
Reviewed by:	imp
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:	https://reviews.freebsd.org/D46237
2024-08-07 11:46:48 +03:00
Konstantin Belousov
10ac6c48a3 msun/ld80/e_powl.c: add const qualifiers to the static immutable values
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D46237
2024-08-07 11:46:48 +03:00
Christos Margiolis
6e744de1a3 mixer.3: Fix mixer_get_mode() description
Improve wording and also fix the constants' names.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D46220
2024-08-05 14:13:44 +03:00
John Baldwin
8da89a177d libsys: Add MLINKs for recvmmsg.2 and sendmmsg.2
These were accidentally lost when moving recvmmsg and sendmmsg back
from libc to libsys.

Reported by:	Mark Millard <marklmi@yahoo.com>
Reviewed by:	brooks, imp
Fixes:		29d079c964 libsys: move __libsys_interposer consumers
Differential Revision:	https://reviews.freebsd.org/D46200
2024-08-03 10:57:57 -04:00
Ed Maste
5c2bc3db20 Remove "All Rights Reserved" from FreeBSD Foundation copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder.

Sponsored by:	The FreeBSD Foundation
2024-07-30 12:16:36 -04:00
Konstantin Belousov
c4269e63ec exit(3): clarify how to obtain full exit status of the exited process
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-07-30 02:57:34 +03:00
Konstantin Belousov
3f3ec4b99f exit(3): make it thread-safe
It was explained by Rich Felker <dalias@libc.org> on libc-coord.
See https://austingroupbugs.net/view.php?id=1845.

Reviewed by:	imp, markj
Tested by:	antoine (exp-run)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D46108
2024-07-30 02:57:34 +03:00
Konstantin Belousov
31f688a26d rtld: avoid division in __thr_map_stacks_exec()
The function is called by rtld with the rtld bind lock write-locked,
when fixing the stack permission during dso load.  Not every ARMv7 CPU
supports the div, which causes the recursive entry into rtld to resolve
the  __aeabi_uidiv symbol, causing self-lock.

Workaround the problem by using roundup2() instead of open-coding less
efficient formula.

Diagnosed by:	mmel
Based on submission by:	John F Carr <jfc@mit.edu>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-07-30 02:57:33 +03:00
Robert Clausecker
9082398090 lib/libc/amd64/string: fix overread condition in memccpy
An overread condition in memccpy(dst, src, c, len) would occur if
src does not cross a 16 byte boundary and there is no instance of
c between *src and the next 16 byte boundary.  This could cause a
read fault if src is just before the end of a page and the next page
is unmapped or unreadable.

The bug is a consequence of basing memccpy() on the strlcpy() code:
whereas strlcpy() assumes that src is a nul-terminated string and
hence a terminator is always present, c may not be present at all in
the source string.  It was not caught earlier due to insufficient
unit test design.

As a part of the fix, the function is refactored such that the runt
case (buffer length from last alignment boundary between 1 and 32 B)
is handled separately.  This reduces the number of conditional
branches on all code paths and simplifies the handling of early
matches in the non-runt case.  Performance is improved slightly.

os: FreeBSD
arch: amd64
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
        │ memccpy.unfixed.out │        memccpy.fixed.out           │
        │       sec/op        │   sec/op     vs base               │
Short             66.76µ ± 0%   62.45µ ± 1%  -6.44% (p=0.000 n=20)
Mid               7.938µ ± 0%   7.967µ ± 0%  +0.36% (p=0.001 n=20)
Long              3.577µ ± 0%   3.577µ ± 0%       ~ (p=0.429 n=20)
geomean           12.38µ        12.12µ       -2.08%

        │ memccpy.unfixed.out │         memccpy.fixed.out           │
        │         B/s         │     B/s       vs base               │
Short            1.744Gi ± 0%   1.864Gi ± 1%  +6.89% (p=0.000 n=20)
Mid              14.67Gi ± 0%   14.61Gi ± 0%  -0.36% (p=0.001 n=20)
Long             32.55Gi ± 0%   32.55Gi ± 0%       ~ (p=0.429 n=20)
geomean          9.407Gi        9.606Gi       +2.12%

Reported by:	getz
Reviewed by:	getz
Approved by:	mjg (blanket, via IRC)
See also:	D46051
MFC:		stable/14
Event:		GSoC 2024
Differential Revision:	https://reviews.freebsd.org/D46052
2024-07-29 21:36:10 +02:00
Mark Johnston
ec84a986ba vm: Remove kernel stack swapping support, part 11
- Remove sysctls that control stack swapping, update documentation.
- Remove vm_swapout_dummy.c, which serves no purpose now.

Tested by:	pho
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D46129
2024-07-29 01:43:59 +00:00
Steve Kargl
34f746cc7f libm: fma: correct zero sign with small inputs
This is a fixed version of 888796ade2.

PR:		277783
Reported by:	Victor Stinner
Reviewed by:	emaste
MFC after:	1 week
2024-07-28 17:37:45 -04:00
Bjoern A. Zeeb
c179937b98 libc/getnameinfo: stop adding NI_NUMERICHOST where inappropriate
Checking the first nibble of the IPv6 address to be 0 and then
excluding two well known cases (v4-mapped, loopback) leaves us with
more cases where the first nibble could be 0, e.g., the RFC 6052,
2.1 Well-Known Prefix 64:ff9b::/96.
It is not practical to track them all and it is not clear what lead
to this special casing originally, so remove them.

While here also remove the IN6_IS_ADDR_LINKLOCAL() + NI_NUMERICHOST
case as link-local address resolution does exist.

We do leave the IN6_IS_ADDR_MULTICAST() case for now as I could
not find any references to any official reverse lookups for these.

Adding comments for more case (and some historic behaviour) in order
to make it easier to follow the logic.

PR:		279618
Fixes:		6cb9418289
MFC after:	6 weeks
Reviewed by:	hrs
Differential Revision: https://reviews.freebsd.org/D45547
2024-07-26 11:03:56 +00:00
Brooks Davis
f5c894479e Revert "Avoid division in round_up."
This reverts commit 2b229739e7.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/1343
2024-07-26 00:11:11 +01:00
John F. Carr
2b229739e7 Avoid division in round_up.
Division may require a function call, leading to
dynamic function lookup, leading to deadlock in rtld.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/1343
2024-07-26 00:00:28 +01:00
John Baldwin
846d702f23 libnvmf: Reject invalid values of MAXH2CDATA for new associations
Sponsored by:	Chelsio Communications
2024-07-25 15:32:42 -04:00
John Baldwin
fd0e6af5e4 libnvmf: Require MAXH2CDATA to be a multiple of 4
The spec says MAXH2CDATA to is "a multiple of dwords and should be no
less than 4,096".

Sponsored by:	Chelsio Communications
2024-07-25 15:32:38 -04:00
Michal Meloun
5670b8cc36 libthr: Preresolve selected EABI symbols on arm.
Add the ability to pre-resolve architecture-specific EABI symbols and
use it on arm for selected EABI functions. These functions can be called
with rtld bind lock write-locked, so they should be resolved in forward.

Reported by:	Mark Millard <marklmi@yahoo.com>, John F Carr <jfc@mit.edu>
Reviewed by:	kib, imp
MFC after:	1 week
Differential Revision:  https://reviews.freebsd.org/D46104
2024-07-25 18:24:22 +02:00
Kristof Provost
9ae91f59c5 pf: convert DIOCGETADDR to netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-07-22 09:11:49 +02:00
Kristof Provost
644b7b5a2e pf: convert DIOCGETADDRS to netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-07-22 09:11:49 +02:00
John Baldwin
e0649a35a6 libnvmf: Zero controller data template for I/O controllers
This prevents stack garbage from leaking into the cdata used for the
userspace I/O controller in nvmfd(8).

Sponsored by:	Chelsio Communications
2024-07-19 17:06:47 -04:00
John Baldwin
8aadd10a65 lib80211: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, emaste
Differential Revision:	https://reviews.freebsd.org/D46008
2024-07-19 13:06:16 -04:00
John Baldwin
bf3b889a5b libgeom: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D46006
2024-07-19 13:06:03 -04:00
John Baldwin
5275d1ddb4 libcasper: Consistently use item count as the first argument to calloc
Reported by:	GCC 14 -Wcalloc-transposed-args
Reviewed by:	rlibby, emaste
Differential Revision:	https://reviews.freebsd.org/D46005
2024-07-19 13:05:58 -04:00
Kristof Provost
d909f06b90 pf: convert DIOCADDADDR to netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-07-17 07:52:55 +02:00
Kyle Evans
d5f8270917 libc: switch to __weak_symbol for fortified interpose stubs
GCC doesn't like `#pragma weak macro(foo)`, but that's fine; just slap
a __weak_symbol on the definition to more reliably make it weak
anyways.

Reviewed by:	kib (earlier version), markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45976
2024-07-16 00:12:28 -05:00
Kyle Evans
0c47b9c211 include: ssp: don't shadow the mempcpy builtin
GCC emits a warning about shadowing a builtin with our mempcpy
declaration, so switch it to using the same model as memcpy() and
use the apparently-existing __builtin___mempcpy_chk().

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

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Ed Maste
001606523a libm: add parens to clarify expressions in fma, fmal
Obtained from:	NetBSD
2024-07-15 09:30:02 -04:00
Strahinja Stanišić
f0d1236f0f libc: Add memset test for int-to-char conversion
Test case to check if an implementation of memset correctly
handles the value passed being wider than a byte

Approved by:	emaste
Reviewed By:	fuz (GSoC mentor), emaste
Sponsored by:	Google LLC (GSoC 2024)
Differential Revision: https://reviews.freebsd.org/D45738
2024-07-13 15:07:49 +02:00
Kyle Evans
1f155d48f8 include: ssp: fortify <sys/socket.h>
The entire recv*() implementation set is ripe for opportunities to
validate, so do what we can with what we have.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45686
2024-07-13 00:16:26 -05:00
Kyle Evans
2aba0eea3f include: ssp: fortify <sys/select.h>
Notably sanity check indices passed to the FD_*() macros against the
size of the fd_set itself.

Reviewed by:	markj
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D45685
2024-07-13 00:16:25 -05:00