Commit graph

10022 commits

Author SHA1 Message Date
Kyle Evans
25512b1fca libc: locale: fix EUC shift check
wchar_t is unsigned on ARM platforms, and signed pretty much everywhere
else.  On signed platforms, `nm` ends up with bogus upper bits set if we
did in-fact have a valid CS2 or CS3 (MSB set).  Mask just the low byte
to avoid sign bit garbage.

Bare basic test of converting a CS2 widechar in eucCN, which would
previously kick back an EILSEQ.

Reviewed by:	bapt, rew
Sponsored by:	Klara, Inc.

(cherry picked from commit c4c562eadf3b790fa221e220d6a442f0cb84ca35)
2025-04-25 22:19:49 -05:00
Konstantin Belousov
81fc946931 sysctl.3: put KERN_PROC_RLIMIT_USAGE in the right spot
(cherry picked from commit 199a2be029e835c3b284d948e8168af378b06efc)
2025-04-24 03:28:31 +03:00
Ricardo Branco
0ad5308987 Add POSIX psiginfo(3) call
PR:	286133

(cherry picked from commit 3b2f0bfc35167724a41c969c1823be6b1ede15ab)
2025-04-24 03:27:57 +03:00
Kyle Evans
df4b8eff7b libc: tests: add some tests for __cxa_atexit handling
This adds a basic test that __cxa_atexit works, and also adds some tests
for __cxa_atexit handlers registered in the middle of __cxa_finalize.

PR:		285870

(cherry picked from commit ee9ce1078c596f5719f312feedd616ab0fb41dc9)
2025-04-16 20:01:46 -05:00
Aurélien Croc de Suray
c43ae65b4b libc: allow __cxa_atexit handlers to be added during __cxa_finalize
science/dlib-cpp reveals an interesting scenario that works fine on
other platforms but not on FreeBSD; notably, it ends up creating a new
global object from some destructor which is called during
__cxa_finalize.  This breaks when libdlib is dlopen()ed and then
subsequently dlclose()ed, as we never end up invoking the created
object's dtor until program exit when the shlib is already unmapped.

Fix it by noting when we're in the middle of __cxa_finalize for a dso,
and then restarting the search if __cxa_atexit() was called in the
middle somewhere.

We wait until we've processed the initial set before starting over and
processing the newly added handlers as if it were a complete set of
handlers added during runtime.  The alternative is calling them as
they're added to maintain a LIFO in terms of total ordering, but in
theory a constructor could add another global object that also needs to
be destroyed, and that object needs to be destroyed after the one that
constructed it to avoid creating unexpected lifetime issues.

This manifests in the pdlib PHP extension for dlib crashing, see [0].

[0] https://github.com/goodspb/pdlib/issues/39

PR:		285870
Reviewed by:	kevans (also supplied commit message)

(cherry picked from commit 23427c8e1fedb9fc68ad0bd27a59c7ffd2b3008c)
2025-04-16 20:01:36 -05:00
Konstantin Belousov
f9afcbff02 libc/compat-ino64.h: rename st_padding0
This is a direct fix for stable/14.
2025-04-10 13:25:55 +03:00
Dag-Erling Smørgrav
9c84aea414 fts: Stop abusing the comma operator.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D49624

(cherry picked from commit 5abef29833d32d257a20b61732993987dd2a6056)
2025-04-08 10:19:43 +00:00
Konstantin Belousov
1795bfc315 Document KERN_PROC_KQUEUE
(cherry picked from commit 4cf6cae879f93856fd3d932574b4f154e8dc5367)
2025-04-07 04:28:21 +03:00
Olivier Certner
e286a03736
setcred(2): Add manual page
Reviewed by:    Alexander Ziaee <concussious@runbox.com>
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D48063

(cherry picked from commit b6f4027ad9a2ede69a7ec11137cc4ea69ec2f0a0)
2025-04-03 21:31:07 +02:00
Olivier Certner
c1d7552ddd
New setcred() system call and associated MAC hooks
This new system call allows to set all necessary credentials of
a process in one go: Effective, real and saved UIDs, effective, real and
saved GIDs, supplementary groups and the MAC label.  Its advantage over
standard credential-setting system calls (such as setuid(), seteuid(),
etc.) is that it enables MAC modules, such as MAC/do, to restrict the
set of credentials some process may gain in a fine-grained manner.

Traditionally, credential changes rely on setuid binaries that call
multiple credential system calls and in a specific order (setuid() must
be last, so as to remain root for all other credential-setting calls,
which would otherwise fail with insufficient privileges).  This
piecewise approach causes the process to transiently hold credentials
that are neither the original nor the final ones.  For the kernel to
enforce that only certain transitions of credentials are allowed, either
these possibly non-compliant transient states have to disappear (by
setting all relevant attributes in one go), or the kernel must delay
setting or checking the new credentials.  Delaying setting credentials
could be done, e.g., by having some mode where the standard system calls
contribute to building new credentials but without committing them.  It
could be started and ended by a special system call.  Delaying checking
could mean that, e.g., the kernel only verifies the credentials
transition at the next non-credential-setting system call (we just
mention this possibility for completeness, but are certainly not
endorsing it).

We chose the simpler approach of a new system call, as we don't expect
the set of credentials one can set to change often.  It has the
advantages that the traditional system calls' code doesn't have to be
changed and that we can establish a special MAC protocol for it, by
having some cleanup function called just before returning (this is
a requirement for MAC/do), without disturbing the existing ones.

The mac_cred_check_setcred() hook is passed the flags received by
setcred() (including the version) and both the old and new kernel's
'struct ucred' instead of 'struct setcred' as this should simplify
evolving existing hooks as the 'struct setcred' structure evolves.  The
mac_cred_setcred_enter() and mac_cred_setcred_exit() hooks are always
called by pairs around potential calls to mac_cred_check_setcred().
They allow MAC modules to allocate/free data they may need in their
mac_cred_check_setcred() hook, as the latter is called under the current
process' lock, rendering sleepable allocations impossible.  MAC/do is
going to leverage these in a subsequent commit.  A scheme where
mac_cred_check_setcred() could return ERESTART was considered but is
incompatible with proper composition of MAC modules.

While here, add missing includes and declarations for standalone
inclusion of <sys/ucred.h> both from kernel and userspace (for the
latter, it has been working thanks to <bsm/audit.h> already including
<sys/types.h>).

Reviewed by:    brooks
Approved by:    markj (mentor)
Relnotes:       yes
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D47618

(cherry picked from commit ddb3eb4efe55e57c206f3534263c77b837aff1dc)
2025-04-03 21:31:03 +02:00
Mark Johnston
bcd9c0cfb6 getentropy tests: Update after commit 473681a1a506da
- Use GETENTROPY_MAX instead of hard-coding the value.
- Check for EINVAL instead of EIO

Fixes:	473681a1a506 ("libc: Fix getentropy POSIX 2024 conformance issues")
(cherry picked from commit c5056a3931b41a803a24b89400d38d5c5f843612)
2025-03-31 18:52:46 -07:00
Gleb Smirnoff
1bda3fae78 tcp: don't ever return ECONNRESET on close(2)
The SUS doesn't mention this error code as a possible one [1]. The FreeBSD
manual page specifies a possible ECONNRESET for close(2):

[ECONNRESET]	The underlying object was a stream socket that was
		shut down by the peer before all pending data was
		delivered.

In the past it had been EINVAL (see 21367f630d), and this EINVAL was
added as a safety measure in 623dce13c6.  After conversion to
ECONNRESET it had been documented in the manual page in 78e3a7fdd5, but
I bet wasn't ever tested to actually be ever returned, cause the
tcp-testsuite[2] didn't exist back then.  So documentation is incorrect
since 2006, if my bet wins.  Anyway, in the modern FreeBSD the condition
described above doesn't end up with ECONNRESET error code from close(2).
The error condition is reported via SO_ERROR socket option, though.  This
can be checked using the tcp-testsuite, temporarily disabling the
getsockopt(SO_ERROR) lines using sed command [3].  Most of these
getsockopt(2)s are followed by '+0.00 close(3) = 0', which will confirm
that close(2) doesn't return ECONNRESET even on a socket that has the
error stored, neither it is returned in the case described in the manual
page.  The latter case is covered by multiple tests residing in tcp-
testsuite/state-event-engine/rcv-rst-*.

However, the deleted block of code could be entered in a race condition
between close(2) and processing of incoming packet, when connection had
already been half-closed with shutdown(SHUT_WR) and sits in TCPS_LAST_ACK.
This was reported in the bug 146845.  With the block deleted, we will
continue into tcp_disconnect() which has proper handling of INP_DROPPED.

The race explanation follows.  The connection is in TCPS_LAST_ACK.  The
network input thread acquires the tcpcb lock first, sets INP_DROPPED,
acquires the socket lock in soisdisconnected() and clears SS_ISCONNECTED.
Meanwhile, the syscall thread goes through sodisconnect() which checks for
SS_ISCONNECTED locklessly(!).  The check passes and the thread blocks on
the tcpcb lock in tcp_usr_disconnect().  Once input thread releases the
lock, the syscall thread observes INP_DROPPED and returns ECONNRESET.

- Thread 1: tcp_do_segment()->tcp_close()->in_pcbdrop(),soisdisconnected()
- Thread 2: sys_close()...->soclose()->sodisconnect()->tcp_usr_disconnect()

Note that the lockless operation in sodisconnect() isn't correct, but
enforcing the socket lock there will not fix the problem.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/
[2] https://github.com/freebsd-net/tcp-testsuite
[3] sed -i "" -Ee '/\+0\.00 getsockopt\(3, SOL_SOCKET, SO_ERROR, \[ECONNRESET\]/d' $(grep -lr ECONNRESET tcp-testsuite)

PR:			146845
Reviewed by:		tuexen, rrs, imp
Differential Revision:	https://reviews.freebsd.org/D48148

(cherry picked from commit 053a988497342a6fd0a717cc097d09c23f83e103)
2025-03-31 10:31:21 -07:00
Ahmad Khalifa
2ce4f02182 libc/stdio: Increase BUF in vfprintf.c and vfwprintf.c
With the %b format specifier we need enough space to write a uintmax_t
in binary.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1400

(cherry picked from commit d4f9e326393e3298062a58338e2c94ef6baff8b5)
2025-03-25 19:28:39 -06:00
Konstantin Belousov
0f78d64334 open.2: minor editing
(cherry picked from commit e2dd73cf45a6a8d97131bdbe512ab1ff63121d85)
2025-03-07 07:23:08 +02:00
artembunichev
3416ed9d07 open.2: add separate paragraph for O_CREAT
PR:	284353

(cherry picked from commit 8cebb0630046a8eb10c551a856397ed230e73833)
2025-03-07 07:23:08 +02:00
Stefan Eßer
2d1b1c1aaa libc/gen/fts.c: fix assignment
Fixes:		e59991206b fts(3): be less strict when automount does its job under us walking autofs mount

(cherry picked from commit ab6a311c720e93c860d3dd4a335264d725db7a0d)
2025-03-04 06:19:08 +02:00
Konstantin Belousov
9460df3573 fts(3): be less strict when automount does its job under us walking autofs mount
PR:	284914

(cherry picked from commit e59991206b1463b7e85cc8aafde7f1dc03fcedcf)
2025-03-04 06:19:08 +02:00
Konstantin Belousov
69b6dc0b92 libc/gen: split user-visible opendir()-like functions into separate source files
(cherry picked from commit d40daefca64750c1076822bdbd3c409a9519f513)
2025-03-04 06:19:08 +02:00
John Baldwin
f31e3922bd open.2: Editorial pass
- Use a typical tagged list for the open flags instead of a literal
  block.  This permits using markup in the flag descriptions.  Also,
  drop the offset to avoid indenting the entire list.

- Note that O_RESOLVE_BENEATH only applies to openat(2)

- Use a clearer description of O_CLOEXEC (what it means, not the
  internal flag it sets)

- Note that exactly one permission flag is required.

- Split up a paragraph on various flags so that each flag gets its own
  paragraph.  Some flags already had their own paragraph, so this is
  more consistent.  It also makes it clearer which flag a sentence is
  talking about when a flag has more than one sentence.

- Appease some errors from igor and man2ps

- In the discussion about a returned directory descriptor opened with
  O_SEARCH, avoid the use of Fa fd since the descriptor in question is
  a return value and not an argument to open or openat.

- Various and sundry markup and language tweaks

Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D48253

(cherry picked from commit 826509a3c3642db6a110f8f43ae8860c40c72ad2)
2025-03-03 11:56:20 -05:00
John Baldwin
8e8058b737 kqueue.2: Editorial pass
- Use consistent language to describe user values unchanged by the
  kernel.

- Replace passive language with active in a few places.

- Add a history note for kqueuex() and kqueue1().

- Add an MLINK and synopsis for kqueue1().

- Various wording and markup tweaks.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D48203

(cherry picked from commit 9b1585384d53d0f9cc4585a6efd8cc95116407d7)
2025-03-03 11:56:20 -05:00
Alexander Ziaee
6875767cf2
recv.2: Improve style in RETURN VALUES
Reported by:		des
MFC after:		3 days
Fixes:			571df2c64a3c1 (Explain how recv functions can)
Reviewed by:		mhorne, des
Approved by:		mhorne (mentor)
Differential Revision:	https://reviews.freebsd.org/D48995

(cherry picked from commit 7c3c8605d62f5d27a5228a3787aae6e573f77d59)
2025-02-26 20:44:37 -05:00
Felix Johnson
2200da5fe0
recv.2: Explain how recv functions can return 0
Clarify the RETURN VALUES section with improved structure,
the condition of the return value 0, and the setting of errno.

PR:			174581
Reviewed by:		jhb, ziaee
Approved by:		mhorne (mentor)
Differential Revision:	https://reviews.freebsd.org/D48955

(cherry picked from commit 571df2c64a3c1af1fe011303ec08e391e887ecbc)
2025-02-26 20:44:28 -05:00
Konstantin Belousov
b69399170b statfs.2: document missing user-visible MNT flags
(cherry picked from commit e951247a983daf7814d06e9e49bdd503ceaa0b68)
2025-02-23 02:30:51 +02:00
Konstantin Belousov
28b1a5a6cd statfs.2: order MNT flags alphabetically
(cherry picked from commit 0738cd9766a570e085831f6241387baa35cd64a3)
2025-02-23 02:30:51 +02:00
Konstantin Belousov
743cd4c1af statfs.2: remove dead comment
(cherry picked from commit 13b92ae9655deb22c3ad89f1e90e26f2f1da9961)
2025-02-23 02:30:51 +02:00
Konstantin Belousov
efa0994821 statfs.2: uncomment and describe MNT_IGNORE
(cherry picked from commit 270542d95d0d931ebdd369f4f78871828502d486)
2025-02-23 02:30:50 +02:00
Mark Johnston
b0f2df45e7 socket: Add an option to retrieve a socket's FIB number
The SO_SETFIB option can be used to set a socket's FIB number, but there
is no way to retrieve it.  Rename SO_SETFIB to SO_FIB and implement a
handler for it for getsockopt(2).

Reviewed by:	glebius
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D48834

(cherry picked from commit ee951eb59f2136a604e3fbb12abf8d8344da0c99)
2025-02-21 01:04:50 +00:00
Ed Maste
6789b9f630 libc: Fix getentropy POSIX 2024 conformance issues
GETENTROPY_MAX should be defined in limits.h.  EINVAL is the return
value for buflen > GETENTROPY_MAX.

PR:		282783
Reviewed by:	markj, asomers, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47689
2025-02-20 09:13:25 -05:00
Li-Wen Hsu
ef3ed0726f Canonicalize the name of the FreeBSD Foundation
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit dab59af3bcc7cb7ba01569d3044894b3e860ad56)
2025-02-19 09:58:47 -05:00
Mark Johnston
028323d616 setfib.2: Note that the number of FIBs can be adjusted after boot
Reviewed by:	zlei, imp
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D48545

(cherry picked from commit 010ee8215f5c899e23250828402af5b7bb354328)
2025-02-07 14:46:53 +00:00
Alan Somers
3dc01440a0 Fix lib/libc/nss/getgr_test with large numbers of groups
These tests create a linked list with one entry for every group on the
running system.  On a system with about 30,000 groups, the test took 69
seconds to run, and crashed Kyua with the below error:

kyua: E: string or blob too big (sqlite op: sqlite3_bind_blob) (sqlite db: /root/.kyua/store/results.usr_tests.20241231-203317-570235.db).

Fix the test by limiting it to operating on the first 1024 groups.
Apply the same change to getpw_test and getserv_test too, which are
vulnerable to the same problem.

Sponsored by:	ConnectWise
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D48275

(cherry picked from commit d11904b350214943dedb64c7121d4602799d7afd)
2025-01-20 09:54:45 -07:00
Ed Maste
e2cbfa1f50 munmap.2: Remove EINVAL for negative len
len is unsigned (it is size_t), so cannot be negative.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit fab411c4fd5224e3dd44e0eb288d60b27480e2d1)
2025-01-20 09:25:14 -05:00
Ed Maste
61c5090935 munmap.2: Unaligned addresses do not return error
We previously claimed that non-page-aligned addresses would return
EINVAL, but the address is in fact rounded down to the page boundary.

Reported by:	Harald Eilertsen <haraldei@anduin.net>
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Fixes: dabee6fecc ("kern_descrip.c: add fdshare()/fdcopy()")
Differential Revision: https://reviews.freebsd.org/D48465

(cherry picked from commit 9e36aaf0c24cf158e83c69c1d2312c000c3c36f3)
2025-01-20 09:25:14 -05:00
Graham Percival
334e641d38 fgets.3: document gets_s() __STDC_WANT_LIB_EXT1__
This matches the man page for qsort_s().

PR:		281828
Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Sponsored by:	Tarsnap Backup Inc.

(cherry picked from commit d0a3fd34a05794bc5cbf48709001a78e9f85169a)
2024-12-27 10:48:27 -05:00
John Baldwin
66cb373c8f procctl.2: Editing pass
- Add some missing .Pp macros after the end of literal blocks and some
  lists to ensure there is a blank line before the following text.

- Use an indent of Ds for nested lists to reduce excessive indentation and
  make the bodies of the nested list items easier to read.

- Various and sundry rewordings and clarifications.

Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D47782

(cherry picked from commit 8277c790179304159c2e4dcb1d99552518d5be8e)
2024-12-27 10:43:26 -05:00
Graham Percival
9a15a1fef9 manuals: Misc macro typos
These were reported by `mandoc -T lint` as
    ERROR: skipping unknown macro
When these pages were rendered with `man`, the "unknown macro" meant
that the entire line was omitted from the output.

Obvious typos in:
lib/libsys/swapon.2
lib/libsys/procctl.2
share/man/man9/firmware.9

lib/libcasper/services/cap_net/cap_net.3: 'mode' describes a function
    argument.

lib/libsys/statfs.2: there's no .Tm command ("trademark?"), and
    .Tn ("tradename") is deprecated, so remove the macro entirely.

usr.sbin/mfiutil/mfiutil.8: man was interpreting '/dev/' as a macro
    (which it didn't recognize).

share/man/man4/qat.4: same issue as above, but with '0'.  In this case,
    given the context of the previous line, rewriting as "Value '0'"
    seemed more appropriate.

usr.sbin/mlx5tool/mlx5tool.8: typo in .Xr

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Sponsored by:	Tarsnap Backup Inc.
Reviewed by:	concussious, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1417

(cherry picked from commit 2878d99dfcfbdd7a415a7f31cf95fbd53fc8e581)
2024-12-27 10:40:05 -05:00
Xin LI
97cf82ebe0 Revise qsort(3) reflect POSIX.1-2024 update.
Reviewed by:	emaste, trasz
Differential Revision: https://reviews.freebsd.org/D47262

(cherry picked from commit 3df1abdfd9c309efbdc7884d6b6f6fe25efcb397)
2024-12-21 23:30:52 -08:00
Dag-Erling Smørgrav
259dcedc4a strptime: Fix day-of-week calculation.
The day-of-week calculation used the raw year value without adjusting
for TM_YEAR_BASE, so it was off by one for 300 years out of every 400;
it just happened to be correct for 1901 through 2000.  It also used a
loop where a simple addition would have sufficed.

While here, simplify our version of Gauss's algorithm, and document
that we assume the Gregorian calendar.

MFC after:	1 week
PR:		282916
Reviewed by:	imp, allanjude, philip
Differential Revision:	https://reviews.freebsd.org/D47977

(cherry picked from commit 4285e024baa80f81d13cdcc016fdf0721fe57862)
2024-12-16 10:37:08 +00:00
Ed Maste
f2c09b4f32 cap_rights_is_empty: add MLINK
Fixes: a7100ae23aca ("capsicum: introduce cap_rights_is_empty Function")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 3505e0d6675b332c154e01110456d767e222c5d6)
2024-12-06 10:50:31 -05:00
Ed Maste
25caac4d45 sched_getcpu: Add man page
Moved from libsys to libc for stable/14.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47556

(cherry picked from commit 36887e04947fedfebb9b648fadd0dd6cc03142ea)
2024-12-04 13:32:58 -05:00
Mark Johnston
da44138dc2 unix: Add support for atomically setting the socket mode
With this patch, it is possible to call fchmod() on a unix socket prior
to binding it to the filesystem namespace, so that the mode is set
atomically.  Without this, one has to call chmod() after bind(), leaving
a window where threads can connect to the socket with the default mode.
After bind(), fchmod() reverts to failing with EINVAL.

This interface is copied from Linux.

The behaviour of fstat() is unmodified, i.e., it continues to return the
mode as set by soo_stat().

PR:		282393
Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D47361

(cherry picked from commit bfd03046d18776ea70785ca1ef36dfc60822de3b)
2024-12-03 01:03:26 +00:00
Konstantin Belousov
9fb5c02356 fileno(3): set errno when returning -1
PR:	283014

(cherry picked from commit 7cd756ff4fe7e65a9a3f588904998bf6f4b37623)
2024-12-03 02:39:22 +02:00
Konstantin Belousov
fb0014d04e stdio(3): correct summary information for fileno(3)
(cherry picked from commit 35ac34a23bc0e54eb2a2314b906c6e7769dee7f0)
2024-12-03 02:39:22 +02:00
Wolfram Schneider
7efa3a6028 fhreadlink.2: fix old typo in the manpage
PR: 282967

(cherry picked from commit fb4cdd51608f3008f035d01f6a499811cda41735)
2024-11-28 14:53:17 +02:00
Konstantin Belousov
ed4b2d1594 _dl_iterate_phdr_locked(): fix libc and libdl
Add prototype.  Export from libdl.

Fixes:	1426fd6cff0603f0ee275b99f2ba35dc36f3d0c2
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 209fd89a2810419309944f10d11834321f0ebb25)
2024-11-26 19:15:56 -06:00
Kyle Evans
708106fb80 rtld: implement _dl_iterate_phdr_locked
Some sanitizers need to be able to use dl_iterate_phdr() after stopping
the rest of the process, but it's very hard to do so reliably as a
non-participant in the main logic of the program.

Introduce _dl_iterate_phdr_locked to bypass the locking that's normally
required for dl_iterate_phdr() and slap some scary warning on it.  It
will remain undocumented and probably shouldn't be used for anything
else.

Reviewed by:	kib

(cherry picked from commit 1426fd6cff0603f0ee275b99f2ba35dc36f3d0c2)
2024-11-26 19:15:56 -06:00
Ed Maste
93a321b607 libc: Note that getentropy is nearly POSIX 2024
Our implementation currently diverges from POSIX 2024 in a couple of
ways, as now noted in the BUGS section.

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47589

(cherry picked from commit 95b71a659a9bdc6e9071d80c7369a935c2bc16f4)
2024-11-24 11:46:00 -05:00
R. Christian McDonald
f424c4a907 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
Approved by:    kp (mentor)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42445

(cherry picked from commit 6e5b1ff71e01bd48172483cb6df921f84300ea3a)
2024-11-22 10:36:32 -05:00
Ed Maste
2e8ab3d4e9 fork: Document _Fork (and fork) as POSIX 2024
Also remove some information from HISTORY that is no longer needed (and
could be confusing), now that _Fork is part of a standard.

Reported by:	kib
Reviewed by:	imp, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47588

(cherry picked from commit 566c039d1e7555343fcf6439a10e56f5a632c0fe)
2024-11-20 19:45:07 -05:00
Ed Maste
098ed26bf4 libc: indicate existing functions that are POSIX 2024
Reviewed by:	brooks, imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47581

(cherry picked from commit dfa0ac74c2fbc1cde3e8cdb1ab9fe5cbb90a9b16)
2024-11-20 19:45:07 -05:00