Commit graph

24034 commits

Author SHA1 Message Date
Olivier Certner
b018679002 ptrace(2): Disabling: Describe influence of security.bsd.see_jail_proc
Reviewed by:            mhorne, emaste, pauamma_gundo.com
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41109

(cherry picked from commit d952820105d6a2ad87ddf3bdc6c5fc5215d13b87)
2023-10-17 16:42:59 -03:00
Ed Maste
6eae573dc2 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

(cherry picked from commit a5ed6a815e38d6c622cd97a6020592ded579cf7a)
2023-10-16 13:50:10 -04:00
Olivier Certner
af632cc56b setusercontext(): Fix gap when setting a realtime-class priority
The login.conf's "priority" capability allows to set priorities in the
idle or realtime classes in addition to the classical nice values (-20
to 20), through a natural extension where values greater than 20 put the
processes in the idle class (with priority adjusted within RTP_PRIO_MIN
and RTP_PRIO_MAX, 21 being converted to 0, 22 to 1, etc.) and values
lower than -20 put the process in the realtime class (with priority
adjusted within RTP_PRIO_MIN and RTP_PRIO_MAX, -21 being converted to
RTP_PRIO_MAX (31), -22 to 30, etc.).

Before this fix, in the latter case (realtime class), -21 was converted
to 30, and RTP_PRIO_MAX (31) could never be specified.

While here, change the priority computation for the idle-class case to
be symmetrical and use RTP_PRIO_MIN (in practice, this changes nothing
at all, since RTP_PRIO_MIN is 0; but this is the correct theoretical
formula, which would work as well with other values of RTP_PRIO_MIN).

PR:                     271727
Reviewed by:            imp, kib
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40339

(cherry picked from commit bd572be78436473a2ad4c1b78728b739c74ef238)
2023-10-16 08:29:46 -04:00
Olivier Certner
83bcaf3b2d login_cap.c: Don't set errno to ERANGE on memory allocation failure
Modified functions: login_getcaptime(), login_getcapnum(),
login_getcapsize().

They all call cgetstr(), which returns -2 on such conditions and already
sets errno to ENOMEM, arguably the appropriate value for these functions
as well.

No in-tree consumer currently checks for errno on error reported by
these functions, so this change has no other code impact.

Reviewed by:            kib
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40342

(cherry picked from commit b8c1aadef9d80786daf731300c33d3a001261422)
2023-10-13 10:13:38 -04:00
Ed Maste
2fe06dda0a 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

(cherry picked from commit a572dfa1bfe00cec93b27d8848ca49562cab5e3c)
2023-10-13 10:12:34 -04:00
Michael Osipov
fb058a9a40 libfetch: don't rely on ca_root_nss for certificate validation
Before certctl(8), there was no system trust store, and libfetch
relied on the CA certificate bundle from the ca_root_nss port to
verify peers.

We now have a system trust store and a reliable mechanism for
manipulating it (to explicitly add, remove, or revoke certificates),
but if ca_root_nss is installed, libfetch will still prefer that to
the system trust store.

With this change, unless explicitly overridden, libfetch will rely on
OpenSSL to pick up the default system trust store.

PR:		256902
MFC after:	3 days
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42059

(cherry picked from commit 09f5c1e118bb4eca77b83a0d08f559b20f60aa59)
2023-10-05 02:03:16 +02:00
Dag-Erling Smørgrav
b9c361e4af libc: Rewrite quick_exit() and at_quick_exit() using C11 atomics.
Compiler memory barriers do not prevent the CPU from executing the code
out of order.  Switch to C11 atomics.  This also lets us get rid of the
mutex; instead, loop until the compare_exchange succeeds.

While here, change the return value of at_quick_exit() on failure to
the more traditional -1, matching atexit().

Sponsored by:	Klara, Inc.
Reviewed by:	Olivier Certner, kevans, kib
Differential Revision:	https://reviews.freebsd.org/D41936

(cherry picked from commit 1dc3abb052430279e47c8922d22b30922adcf0f6)

libc: Add a rudimentary test for quick_exit(3).

Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41937

(cherry picked from commit c7dd4601aeebbc1bbe131cbe6747476c124b47fe)
2023-10-05 01:59:43 +02:00
Mark Johnston
b11568083f glabel.8: Warn against using generic labels on a shared device
Also suggest against creating a generic label on a device which already
contains a filesystem.

PR:		264166
Reviewed by:	imp, delphij, Pau Amma <pauamma@gundo.com>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35326

(cherry picked from commit 81f36fbc98dd74ca923938e0329919d426811b0c)
2023-10-04 09:41:29 -04:00
Cy Schubert
1b5982339c unbound: Vendor import 1.18.0
Release notes at
    https://www.nlnetlabs.nl/news/2023/Aug/30/unbound-1.18.0-released/

Merge commit '401770e05c71ecb5ae61a59d316069b4b78bf622' into main

(cherry picked from commit 8f76bb7dad48538c6832c2fb466a433d2a3f8cd5)
2023-10-03 18:01:06 -07:00
Christos Zoulas
56b09feb23 regcomp: use unsigned char when testing for escapes
- cast GETNEXT to unsigned where it is being promoted to int to prevent
  sign-extension (really it would have been better for PEEK*() and
  GETNEXT() to return unsigned char; this would have removed a ton of
  (uch) casts, but it is too intrusive for now).
- fix an isalpha that should have been iswalpha

PR:		264275, 274032
Reviewed by:	kevans, eugen (previous version)
Obtained from:	NetBSD

(cherry picked from commit 3fb80f1476c7776f04ba7ef6d08397cef6abcfb0)
2023-09-29 20:40:59 -05:00
Dag-Erling Smørgrav
b9b207e4ec Remove mention of defunct mailing list from acl / mac man pages.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41923

(cherry picked from commit b653faaa19c47a4a7e488e5ead738b7ae44ffe8b)

Fix typos in acl_get_entry(3) manual page.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41924

(cherry picked from commit c34fce8a039935e06ed84db1395d7d2c551e5a7c)
2023-09-29 02:28:18 +02:00
John Hein
fd8bf2ecc0 libprocstat: use elf_getphdrnum rather than deprecated elf_getphnum
PR:             273966
Reviewed by:	emaste

(cherry picked from commit 633094c27f0ac1b1001d5bd24a883240b4bce1dc)
2023-09-25 09:45:06 -04:00
Robert Clausecker
efbccec3e0 lib/libc/tests/string/strcspn_test.c: extend tests to catch previous bug
This extends the strcspn() unit tests to catch mistakes in the
implementation that only appear when a mismatch occurs in a certain
position of the string against a certain position of the set.

See also:	52d4a4d4e0dedc72bc33082a3f84c2d0fd6f2cbb
Sponsored by:	The FreeBSD Foundation
Approved by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41821

(cherry picked from commit 601fd768cfd599518f7f9d30592763d1279d336d)
2023-09-23 14:21:42 -04:00
Robert Clausecker
0666c6fc03 lib/libc/amd64/string/memcmp.S: harden against phony buffer lengths
When memcmp(a, b, len) (or equally, bcmp) is called with a phony length
such that a + len < a, the code would malfunction and not compare the
two buffers correctly.  While such arguments are illegal (buffers do not
wrap around the end of the address space), it is neverthless conceivable
that people try things like memcmp(a, b, SIZE_MAX) to compare a and b
until the first mismatch, in the knowledge that such a mismatch exists,
expecting memcmp() to stop comparing somewhere around the mismatch.
While memcmp() is usually written to confirm to this assumption, no
version of ISO/IEC 9899 guarantees this behaviour (in contrast to
memchr() for which it is).

Neverthless it appears sensible to at least not grossly misbehave on
phony lengths.  This change hardens memcmp() against this case by
comparing at least until the end of the address space if a + len
overflows a 64 bit integer.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg (blanket, via IRC)
See also:	b2618b651b28fd29e62a4e285f5be09ea30a85d4
MFC after:	1 week

(cherry picked from commit 953b93cf24d8871c62416c9bcfca935f1f1853b6)
2023-09-23 14:21:42 -04:00
Robert Clausecker
62f73a711e lib/libc/amd64/string: implement strnlen(3) trough memchr(3)
Now that we have an optimised memchr(3), we can use it to implement
strnlen(3) with better perofrmance.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41598

(cherry picked from commit 331737281c1929c29e679e48783055351ac4fbd9)
2023-09-23 14:21:37 -04:00
Robert Clausecker
3f78bde932 lib/libc/amd64/string: add memchr(3) scalar, baseline implementation
This is conceptually similar to strchr(3), but there are
slight changes to account for the buffer having an explicit
buffer length.

this includes the bug fix from b2618b6.

Sponsored by:	The FreeBSD Foundation
Reported by:	yuri, des
Tested by:	des
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
PR:		273652
Differential Revision:	https://reviews.freebsd.org/D41598

(cherry picked from commit de12a689fad271f5a2ba7c188b0b5fb5cabf48e7)
(cherry picked from commit b2618b651b28fd29e62a4e285f5be09ea30a85d4)
2023-09-23 14:20:28 -04:00
Robert Clausecker
39d500190b lib/libc/amd64/string: add strspn(3) scalar, x86-64-v2 implementation
This is conceptually very similar to the strcspn(3) implementations
from D41557, but we can't do the fast paths the same way.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41567

(cherry picked from commit 7084133cde6a58412d86bae9f8a55b86141fb304)
2023-09-23 14:20:28 -04:00
Robert Clausecker
73883def32 lib/libc/tests/string: derive strspn(3) tests from strcspn(3) tests
To cover the new optimised amd64 strspn(3) SIMD implementation, extend
the previously written strcspn(3) unit test to also cover strspn(3).

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41567

(cherry picked from commit 468adddd75f6461fcdd2151122d85879ec592a5b)
2023-09-23 14:20:28 -04:00
Robert Clausecker
08eab36169 lib/libc/tests/string: add unit tests for strcspn(3)
We currently use the NetBSD test suite to cover strcspn(3).  It only
contains a very rudimentary test of this function.  This all new set
of unit tests for the FreeBSD test suite should cover many more edge
cases relating to alignment issues.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision: https://reviews.freebsd.org/D41557

(cherry picked from commit 35a5359406fe779186d1fd7131c95927fefe20be)
2023-09-23 14:20:28 -04:00
Robert Clausecker
feda2297b7 lib/libc/amd64/string: add strcspn(3) scalar, x86-64-v2 implementation
This changeset adds both a scalar and an x86-64-v2 implementation
of the strcspn(3) function to libc. A baseline implementation does not
appear to be feasible given the requirements of the function.

The scalar implementation is similar to the generic libc implementation,
but expands the bit set into a byte set to reduce latency, improving
performance. This approach could probably be backported to the generic
C version to benefit other platforms.

The x86-64-v2 implementation is built around the infamous pcmpistri
instruction. An alternative implementation based on the Muła/Langdale
algorithm [1] was prototyped, but performed worse than the pcmpistri
approach except for sets of more than 16 characters with long input
strings.

All implementations provide special cases for the empty set (reduces to
strlen as well as single-character sets (reduces to strchr). The
x86-64-v2 kernel falls back to the scalar implementation for sets of
more than 32 characters. This limit could be raised by additional
multiples of 16 through the use of additional pcmpistri code paths, but
I consider this case to be too rare to be of importance.

This includes the bug fix from 52d4a4d.

[1]: http://0x80.pl/articles/simd-byte-lookup.html

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg
MFC after:	1 week
MFC to:		stable/14
Differential Revision:	https://reviews.freebsd.org/D41557

(cherry picked from commit 474408bb7933f0383a0da2b01e717bfe683ae77c)
(cherry picked from commit 52d4a4d4e0dedc72bc33082a3f84c2d0fd6f2cbb)
2023-09-23 14:19:28 -04:00
Ed Maste
5bfbde817c libfido2: update to 1.13.0
Some highlights from NEWS entries:

 ** Improved OpenSSL 3.0 compatibility.
 ** Support for hidraw(4) on FreeBSD; gh#597.
 ** Improved support for FIDO 2.1 authenticators.

PR:		273596
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2ccfa855b2fc331819953e3de1b1c15ce5b95a7e)
2023-09-22 07:03:36 -04:00
Ed Maste
f4bb052a78 swapon.2: correct FreeBSD release that introduced swapoff
It was introduced in 92da00bb24, after 5.0 and beforen 5.1.  Reported
in https://github.com/ziglang/zig/issues/16590.

(cherry picked from commit b15f6400376a90d3b00aa3ac00666f683f975376)
2023-09-21 12:52:46 -04:00
Li-Wen Hsu
75e7075fca powerpcspe: Fix build
Copy _fpmath.h from powerpc, which is the same as the one in powerpc64.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 604f6bf022cea7e48f3675aa82e756a440716fd9)
2023-09-17 08:43:26 -06:00
Warner Losh
1972e2eba4 msun: LIBCSRCDIR is too fragile, use ${SRCTOP}/lib/libc instead
LIBCSRCDIR is defined in bsd.libnames.mk, which is read in later in the
Makefile than the line:

.if exists(${LIBCSRCDIR}/${MACHINE_ARCH})

so we test to see if /${MARCHIN_ARCH} exists which it usually doesn't
(but did for me since I mounted 13.2R SD image there).  Move to defining
our own LIBC_SRCTOP in terms of SRCTOP to treat these uniformily.

Sponsored by:		Netflix
Reviewed by:		sjg
Differential Revision:	https://reviews.freebsd.org/D41661

(cherry picked from commit b19d8afe4dd205f7d4bfa3282f58b73d504926db)

Approved by: re (cperciva@)
2023-09-17 08:34:41 -06:00
Xin LI
acdad1f1cb MFC: MFV: file 5.45.
(cherry picked from commit 898496ee09ed2b7d25f6807edc4515628196ec0a)

Disable byteswap.h for now.

(cherry picked from commit 90474518912f5e5f49bc5325b7f88e94eba64d6a)
2023-09-14 15:01:08 -07:00
Dag-Erling Smørgrav
c1335a776b libc: Don't assume signed char.
MFC after:	3 days
Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D41814

(cherry picked from commit 88a9b6e1ed82b562f52bae26b3de257495cd1983)
2023-09-14 08:56:45 +00:00
Mateusz Piotrowski
d2557f02d1 getdirentries.2: Reference dir(5)
As a note, parts of manual pages getdirentries(2) and dir(5) should
probably be consolidated.

MFC after:	3 days

(cherry picked from commit 5b7a776f481891f10820a0b4838d0e0feb60b8ad)
2023-09-12 13:48:18 +02:00
Mateusz Piotrowski
f4960baf80 getdirentries.2: Improve readability of dirent members
MFC after:	3 days

(cherry picked from commit 52d374a067002fc42409b32059ec8b8506a70429)
2023-09-12 13:48:11 +02:00
Mateusz Piotrowski
29a28b9940 getdirentries.2: Reference directory(3)
MFC after:	3 days

(cherry picked from commit 3a02df5e27d2eeabffd761ff5cb79496a6d796ea)
2023-09-12 13:48:03 +02:00
Jessica Clarke
2f269a3532 Merge commit 4bb2416d42eb from llvm-project (by Jessica Clarke):
[builtins][AArch64] Implement _sync out-of-line atomics

  Whilst Clang does not use these, recent GCC does, and so on systems such
  as FreeBSD that wish to use compiler-rt as the system runtime library
  but also wish to support building programs with GCC these interfaces are
  needed.

  This is a light adaptation of the code committed to GCC by Sebastian Pop
  <spop@amazon.com>, relicensed with permission for use in compiler-rt.

  Fixes https://github.com/llvm/llvm-project/issues/63483

  Reviewed By: sebpop, MaskRay

  Differential Revision: https://reviews.llvm.org/D158536

Reviewed by:	dim
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41716

(cherry picked from commit 8524dc53fd4c6b79d75b82cb82f3ac72fc25e85f)
2023-09-11 22:46:57 +01:00
Mitchell Horne
5adb91c729 pmc: better distinguish pmu-events allocation path
Background:

The pm_ev field of struct pmc_op_pmcallocate and struct pmc
traditionally contains the index of the chosen event, corresponding to
the __PMC_EVENTS array in pmc_events.h. This is a static list of events,
maintained by FreeBSD.

In the usual case, libpmc translates the user supplied event name
(string) into the pm_ev index, which is passed as an argument to the
allocation syscall. On the kernel side, the allocation method for the
relevant hwpmc class translates the given index into the event code that
will be written to an event selection register.

In 2018, a new source of performance event definitions was introduced:
the pmu-events json files, which are maintained by the Linux kernel. The
result was better coverage for newer Intel processors with a reduced
maintenance burden for libpmc/hwpmc. Intel and AMD CPUs were
unconditionally switched to allocate events from pmu-events instead of
the traditional scheme (959826ca1b, 81eb4dcf9e).

Under the pmu-events scheme, the pm_ev field contains an index
corresponding to the selected event from the pmu-events table, something
which the kernel has no knowledge of. The configuration for the
performance counting registers is instead passed via class-dependent
fields (struct pmc_md_op_pmcallocate).

In 2021 I changed the allocation logic so that it would attempt to
pull from the pmu-events table first, and fall-back to the traditional
method (dfb4fb4116). Later, pmu-events support for arm64 and power8
CPUs was added (28dd6730a5 and b48a2770d4).

The problem that remains is that the pm_ev field is overloaded, without
a definitive way to determine whether the event allocation came from the
pmu-events table or FreeBSD's statically-defined PMC events. This
resulted in a recent fix, 21f7397a61.

Change:

To disambiguate these two supported but separate use-cases, add a new
flag, PMC_F_EV_PMU, to be set as part of the allocation, indicating that
the event index came from pmu-events.

This is useful in two ways:
 1. On the kernel side, we can validate the syscall arguments better.
    Some classes support only the traditional event scheme (e.g.
    hwpmc_armv7), while others support only the pmu-events method (e.g.
    hwpmc_core for Intel). We can now check for this. The hwpmc_arm64
    class supports both methods, so the new flag supersedes the existing
    MD flag, PM_MD_EVENT_RAW.

 2. The flag will be tracked in struct pmc for the duration of its
    lifetime, meaning it is communicated back to userspace. This allows
    libpmc to perform the reverse index-to-event-name translation
    without speculating about the meaning of the index value.

Adding the flag is a backwards-incompatible ABI change. We recently
bumped the major version of the hwpmc module, so this breakage is
acceptable.

Reviewed by:	jkoshy
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40753

(cherry picked from commit c190fb35f35cc163b61e582a49115680b0d49dcc)
2023-09-11 12:19:58 -07:00
Mitchell Horne
196bb0e152 libpmc: make pmc_pmu_pmcallocate() machine-independent
Have it call the platform-dependent version. For better layering, move
the reset logic inside the new function. This is mainly to facilitate an
upcoming change.

Reviewed by:	jkoshy
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40752

(cherry picked from commit 45dcc17e2fb8f0f9838ba167b311f271a08fcea9)
2023-09-11 12:19:58 -07:00
Trond Endrestøl
d0a5da5c1c scandir.3: Fix several typos
PR:		273480
Reviewed by:	markj
MFC after:	1 week

(cherry picked from commit b7000cadfbf312b6a8acff6b7a3bbbbe55509565)
2023-09-09 11:41:02 -04:00
Kristof Provost
9a9535e4df libpfctl: implement status counter accessor functions
The new nvlist-based status call allows us to easily add new counters.
However, the libpfctl interface defines a TAILQ, so it's not quite
trivial to find the counter consumers are interested in.

Provide convenience functions to access the counters.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41649

(cherry picked from commit e3d3d61a7d94a4155ef70048a8b578985fca8383)
2023-09-09 11:05:50 +02:00
Kristof Provost
be47dc1f71 libpfctl: allow pfctl_free_status(NULL)
Mimic free() and friends, and allow free()ing of NULL.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41648

(cherry picked from commit 0b01878fd00b128ce3dead119b37781048744d39)
2023-09-09 11:05:50 +02:00
Robert Clausecker
7ec2ae8c7c */string.3,arch.7,environ.7: add cross-references to simd(7)
With the new simd-dispatch framework documented in simd(7),
add cross-references to the new man pages to appropriate places.

Sponsored by:	The FreeBSD Foundation
Approved by:	emaste
MFC to:		stable/14
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D41697

(cherry picked from commit d41afb814612ce005d93d2f8d127dcf6ea751cc4)
2023-09-08 17:19:04 -04:00
Ed Maste
99f8ee196d libcasper: reference system.fileargs service
Reviewed by:	oshogbo
Fixes:		cdd6ea94b0 ("libcasper: introduce cap_fileargs...")
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41761

(cherry picked from commit 56e3123fc864b6d08ee5b3752538d2f9be52027b)
2023-09-08 15:39:09 -04:00
Dag-Erling Smørgrav
3c96ab9f1d libc: Implement N2680.
This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41725

(cherry picked from commit bce0bef3c6abab92c7ac8cc23b7cc632a382721e)

libc: Add test cases for N2680.

This adds test cases for %wN and %wfN to the printf(3) and scanf(3) tests.

While here, fix a few nits in the N2630 test cases.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D41743

(cherry picked from commit 12b1c1e3fb446021a881d9815465137843fca50b)

Approved by:	re (gjb)
2023-09-07 20:28:31 +00:00
Dag-Erling Smørgrav
6a629dd2a7 libc: Fix fmemopen(3) prototype in fopen(3) man page.
While here, also update a mention of ANSI C.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans, markj
Differential Revision:	https://reviews.freebsd.org/D41686

(cherry picked from commit 5a57401e7106132b61b16e34365cebf52b773007)

libc: Further nit in fopen(3) man page.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41687

(cherry picked from commit c9f5889d05b5854be033849a4ff9985699071548)

Approved by:	re (gjb)
2023-09-07 20:28:31 +00:00
Dag-Erling Smørgrav
a781134d49 nss_tacplus: Provide dummy setpwent(), getpwent_r(), endpwent().
These aren't really needed, since TACACS+ does not support enumeration, but providing placeholders keeps nsdispatch() from complaining that they're missing.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41658

(cherry picked from commit 56b74a2d856c4d65a4b5c72d1352067b6b469d3b)

Approved by:	re (gjb)
2023-09-07 20:28:30 +00:00
Dag-Erling Smørgrav
bae932999e libc: Implement N2630.
This adds formatted input/output of binary integer numbers to the printf(), scanf(), and strtol() families, including their wide-character counterparts.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41511

(cherry picked from commit d9dc1603d6e48cca84cad3ebe859129131b8387c)

libc: Add unit tests for N2630 and possible collateral damage.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41512

(cherry picked from commit b9385720f34b536ef2568a642e8b1fad0450056f)

libc: Document support for binary integers.

Reviewed by:	debdrup, emaste
Differential Revision:	https://reviews.freebsd.org/D41522

(cherry picked from commit 76edfabbecdec686a570b8e009d5ea4112f943e0)

libc: Fix fixed-width case in the new integer parser.

Fixes:		d9dc1603d6e4
Differential Revision:	https://reviews.freebsd.org/D41622

(cherry picked from commit aca3bd1602577591e5cd237c4bb0bb71b3be0c75)

libc: Add a wide version of snprintf_test.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41726

(cherry picked from commit 4ec9ee9912765ac4ca57353999caa92a23283d8e)

libc: Suppress format checks on printf() / scanf() tests.

Reviewed by:	jrtc27, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D41727

(cherry picked from commit 294bd2827e61a78041f6613f4b82235fcc454157)

Approved by:	re (gjb)
2023-09-07 20:28:30 +00:00
Arjan de Vet
134d36676e geli: Fix geli setkey -J for detached providers
Clear cached_passphrase before generating a new key, otherwise the
operation nonsensically tries to reuse the old passphrase.

Approved by:	re (kib)
PR:		254966
Pull Request:	https://github.com/freebsd/freebsd-src/pull/780
MFC after:	1 week

(cherry picked from commit 88d13bf33754bd4b0c5df92eef83d6fadb9b4944)
2023-09-04 10:11:01 -04:00
Mina Galić
4c509ef95c libc: fix history for strverscmp(3) and versionsort(3)
PR:		273401
Approved by:	re (gjb)

(cherry picked from commit 09ec5e67a7a6605e5a58a2e3e82dab243a90609a)
2023-09-03 19:06:36 +03:00
Martin Matuska
f789381671 zfs: merge openzfs/zfs@32949f256 (zfs-2.2-release) into stable/14
Notable upstream pull request merges:
  #15024 Add missed DMU_PROJECTUSED_OBJECT prefetch
  #15029 Do not request data L1 buffers on scan prefetch
  #15036 FreeBSD: catch up to __FreeBSD_version 1400093
  #15039 Fix raw receive with different indirect block size
  #15047 FreeBSD: Fix build on stable/13 after 1302506
  #15049 Fix the ZFS checksum error histograms with larger record sizes
  #15052 Reduce bloat in ereport.fs.zfs.checksum events
  #15056 Avoid extra snprintf() in dsl_deadlist_merge()
  #15061 Ignore pool ashift property during vdev attachment
  #15063 Don't panic if setting vdev properties is unsupported for this
         vdev type
  #15067 spa_min_alloc should be GCD, not min
  #15071 Add explicit prefetches to bpobj_iterate()
  #15072 Adjust prefetch parameters
  #15079 set autotrim default to 'off' everywhere
  #15080 ZIL: Fix config lock deadlock
  #15088 metaslab: tuneable to better control force ganging
  #15096 Avoid waiting in dmu_sync_late_arrival()
  #15097 BRT should return EOPNOTSUPP
  #15103 Remove zl_issuer_lock from zil_suspend()
  #15107 Remove fastwrite mechanism
  #15113 libzfs: sendrecv: send_progress_thread: handle SIGINFO/SIGUSR1
  #15122 ZIL: Second attempt to reduce scope of zl_issuer_lock
  #15129 zpool_vdev_remove() should handle EALREADY error return
  #15132 ZIL: Replay blocks without next block pointer
  #15148 zfs_clone_range should return descriptive error codes
  #15153 ZIL: Avoid dbuf_read() before dmu_sync()
  #15161 Make zoned/jailed zfsprops(7) make more sense
  #15172 copy_file_range: fix fallback when source create on same txg
  #15180 Update outdated assertion from zio_write_compress
  #15216 Relax error reporting in zpool import and zpool split
  #15227 ZIL: Tune some assertions
  #15228 ZIL: Revert zl_lock scope reduction
  #15233 ZIL: Change ZIOs issue order

Obtained from:	OpenZFS
OpenZFS commit:	32949f2560
Approved by:	re (gjb)
2023-09-03 09:15:24 +02:00
Umer Saleem
32949f2560 Relax error reporting in zpool import and zpool split
For zpool import and zpool split, zpool_enable_datasets is called
to mount and share all datasets in a pool. If there is an error
while mounting or sharing any dataset in the pool, the status of
import or split is reported as failure. However, the changes do
show up in zpool list.

This commit updates the error reporting in zpool import and zpool
split path. More descriptive messages are shown to user in case
there is an error during mount or share. Errors in mount or share
do not effect the overall status of zpool import and zpool split.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Umer Saleem <usaleem@ixsystems.com>
Closes #15216
2023-09-02 10:30:38 -07:00
Robert Clausecker
8b81116755 lib/libc/amd64/string/strchrnul.S: fix edge case in scalar code
When the buffer is immediately preceeded by the character we
are looking for and begins with one higher than that character,
and the buffer is misaligned, a match was errorneously detected
in the first character.  Fix this by changing the way we prevent
matches before the buffer from being detected: instead of
removing the corresponding bit from the 0x80..80 mask, set the
LSB of bytes before the buffer after xoring with the character we
look for.

The bug only affects amd64 with ARCHLEVEL=scalar (cf. simd(7)).
The change comes at a 2% performance impact for short strings
if ARCHLEVEL is set to scalar.  The default configuration is not
affected.

os: FreeBSD
arch: amd64
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
        │ strchrnul.scalar.0.out │       strchrnul.scalar.2.out       │
        │         sec/op         │   sec/op     vs base               │
Short                57.89µ ± 2%   59.08µ ± 1%  +2.07% (p=0.030 n=20)
Mid                  19.24µ ± 0%   19.73µ ± 0%  +2.53% (p=0.000 n=20)
Long                 11.03µ ± 0%   11.03µ ± 0%       ~ (p=0.547 n=20)
geomean              23.07µ        23.43µ       +1.53%

        │ strchrnul.scalar.0.out │       strchrnul.scalar.2.out        │
        │          B/s           │     B/s       vs base               │
Short               2.011Gi ± 2%   1.970Gi ± 1%  -2.02% (p=0.030 n=20)
Mid                 6.049Gi ± 0%   5.900Gi ± 0%  -2.47% (p=0.000 n=20)
Long                10.56Gi ± 0%   10.56Gi ± 0%       ~ (p=0.547 n=20)
geomean             5.045Gi        4.969Gi       -1.50%

MFC to:		stable/14
MFC after:	3 days
Approved by:	mjg (blanket, via IRC), re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 3d8ef251aa9dceabd57f7821a0e6749d35317db3)
2023-08-28 19:45:51 +02:00
наб
6bdc7259d1 libzfs: sendrecv: send_progress_thread: handle SIGINFO/SIGUSR1
POSIX timers target the process, not the thread (as does SIGINFO),
so we need to block it in the main thread which will die if interrupted.

Ref: https://101010.pl/@ed1conf@bsd.network/110731819189629373
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #15113
2023-08-25 13:33:40 -07:00
Dag-Erling Smørgrav
9b5d724cad libc: Add timespec_getres(3) as per C23.
This also adds support for TIME_MONOTONIC to timespec_get(3).

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D41524
2023-08-24 21:31:54 +00:00
Dag-Erling Smørgrav
b8b6bef43f libc: Fix parsing of hexadecimal numbers in strtol() family.
This had previously been partly fixed in 2571c7f720.

MFC after:	1 week
Reviewed by:	imp, allanjude, emaste
Differential Revision:	https://reviews.freebsd.org/D41510
2023-08-24 21:31:54 +00:00
Jake Freeland
8544651dc5 timerfd: Add manual page.
This manual page accompanies the timerfd system calls.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D40218
2023-08-24 14:29:06 -06:00