Commit graph

2271 commits

Author SHA1 Message Date
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
Ed Maste
d45fb7b612 getentropy: Add Git hashes corresponding to SVN references
getentropy has a comment about a special case to support kernels between
SVN revisions r331280 and r337999.  Add the corresponding Git hashes so
there's a usable reference after Subversion infrastructure disappears.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4ef07eb0802a6353faf79d58719d8008decabae0)
2024-11-19 08:57:43 -05:00
Konstantin Belousov
a2d4e8b93e rtld_get_var.3: fix typo
(cherry picked from commit e434c56fcd4f9eee04ac6bb5e0cf028db3006be3)
2024-11-14 02:42:17 +02:00
Konstantin Belousov
cc3978cb74 Document rtld_get_var(3)
(cherry picked from commit 3820f784597cf87deb42522f108c5ee477a1f282)
2024-11-14 02:42:17 +02:00
Konstantin Belousov
86a2abab0a rtld: add rtld_{get,set}_var
(cherry picked from commit c56df6ce71ae96f00b088790d3ad2e0ebebdd59a)
2024-11-14 02:42:17 +02:00
Graham Percival
ddf4df54a7 manuals: Fix "unusual .Xr" warnings with a script
These were reported by `mandoc -T lint ...` as warnings:
- unusual Xr order
- unusual Xr punctuation

Fixes made by script in https://github.com/Tarsnap/freebsd-doc-scripts

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Reviewed by:	mhorne, Alexander Ziaee <concussious.bugzilla@runbox.com>
Sponsored by:	Tarsnap Backup Inc.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1464

(cherry picked from commit 6e1fc0118033f42b7c0d3623c8f67a89ebecabb2)
2024-11-04 12:13:13 -04:00
Graham Percival
c0bd4ec70b manuals: Fix "missing end of block" errors
These were reported by `mandoc -T lint ...` as errors.

The rendered output (in ascii and html) is not affected by this commit.

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Reviewed by:	mhorne
MFC after:	3 days
Sponsored by:	Tarsnap Backup Inc.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1448

(cherry picked from commit d21e322d563e0fd1f92c22205c2ced4bcd22dc23)
2024-11-04 12:07:50 -04:00
Graham Percival
3a75b41bd9 manuals: Misc syntax fixes
These were reported by `mandoc -T lint ...` as errors.

The rendered output (in ascii and html) is not affected by this commit.

Additional clarification: there was a non-breaking space in
lib/libcasper/services/cap_grp/cap_grp.3.

Signed-off-by:	Graham Percival <gperciva@tarsnap.com>
Reviewed by:	mhorne
MFC after:	3 days
Sponsored by:	Tarsnap Backup Inc.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1449

(cherry picked from commit c8b31033c3971b2b7349804ffda0cea5e4835b40)
2024-11-04 11:56:24 -04:00
Konstantin Belousov
d19c86f203 sysctl.3: document missing oids from kern.proc. node
(cherry picked from commit cdd9629921c6551abac583aeafc5c6bd380ccac2)
2024-10-10 12:10:33 +03:00
Konstantin Belousov
387094ca8a sysctl.3: document missing fixed oids from the kern. node
(cherry picked from commit 4e2803878f547f2036d8e9bde4633e0ed96bc46c)
2024-10-10 12:10:32 +03:00
Konstantin Belousov
90f2414a00 sysctl.3: Remove KERN_QUANTUM
(cherry picked from commit 2918dbc1ccd899865fc6e5854fc056800617944f)
2024-10-10 12:10:32 +03:00
Ed Maste
f2109683ce 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

(cherry picked from commit d84fd89ecd404ffbf629381d2dde14fd79b39402)
2024-05-13 10:22:34 -04:00
Konstantin Belousov
f8b5e5320e libc posix_spawn(): explain why rtld can be used after fork
(cherry picked from commit 2ce23b1f76721e44646fc98ba4e24a113a6d5972)
2024-03-11 02:25:58 +02:00
Konstantin Belousov
8e9963d7b0 posix_spawn.c: fix typo in comment
(cherry picked from commit ebaf907114aa6bda49be4204185072571396bb0d)
2024-03-11 02:25:58 +02:00
Konstantin Belousov
7178cd5f81 posix_spawn(3): document POSIX_SPAWN_DISABLE_ASLR_NP
(cherry picked from commit a725a7a24de585e996f21e190b5af41261ebc774)
2024-03-11 02:25:58 +02:00
Konstantin Belousov
b5e95d17ec posix_spawn(3): add POSIX_SPAWN_DISABLE_ASLR_NP
(cherry picked from commit 822042fdfca79faada89e67110b01dd9ecc05996)
2024-03-11 02:25:58 +02:00
Konstantin Belousov
eb36277dc9 posix_spawnattr_setflags(3): validate argument
(cherry picked from commit 80ac36c3a2a87a19790eba487466bf70d55f566e)
2024-03-11 02:25:58 +02:00
Dag-Erling Smørgrav
e257a38de4 Update tzcode to 2024a.
MFC after:	3 weeks
Sponsored by:	Klara, Inc.

(cherry picked from commit 46c599340f187db577b9212ab18022f3c7380c68)
2024-02-21 21:33:23 +01:00
Konstantin Belousov
e331ce2d60 aio_read2/aio_write2: add AIO_OP2_VECTORED
(cherry picked from commit 8dfc788b8480a13f1f945f0a94d8b1e327af5c6f)
2024-02-18 12:01:46 +02:00
Konstantin Belousov
e9014ead57 libc: add aio_read2() and aio_write2() functions
(cherry picked from commit 06cb1c3f9528f088bdaf10d28dcfe7eeaad726d3)
2024-02-18 12:01:46 +02:00
Brooks Davis
0667d0e0e3 libc: expose execvpe for Linux compat
PR:		275370

(cherry picked from commit 8ccd0b876e67fda6249f294ff484798cc1e1569f)
2024-02-18 12:01:46 +02:00
Tom Hukins
554b8bc907 Fix "version introduced" in numerous manual pages
Pull request:	https://github.com/freebsd/freebsd-src/pull/853

(cherry picked from commit ba719a0fec8f831aef4b23de0ff36fd47bb26651)
2024-01-15 10:20:56 -05:00
Brooks Davis
c6e072f15c memfd_create: don't allocate heap memory
Rather than calling calloc() to allocate space for a page size array to
pass to getpagesizes(), just follow the getpagesizes() implementation
and allocate MAXPAGESIZES elements on the stack.  This avoids the need
for the allocation.

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

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42710

(cherry picked from commit c96772227b7dfcaf4eec4d07acb5c916643aca3a)
2023-12-21 18:13:19 +00:00
Brooks Davis
89ebe0ce1f memfd_create: move implementation to libc/gen
Due to memfd_create(3)'s construction of a path to pass to shm_open2(2),
it has a much larger than typical dependency footprint for a system
call wrapper (the list currently includes calloc, memset, sprintf, and
strlen).  As such, split it off into its own file under libc/gen to
lighten libc/sys's dependency list.

Reviewed by:	kevans, imp, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42709

(cherry picked from commit c3207e2d2554c8e36f9cf5950f8cd52a19fedfd5)
2023-12-21 18:13:18 +00:00
Brooks Davis
f695db9fba libc: centralize a few numeric symbols
fabs, __infinity, and __nan are universally implemented so declare them
in gen/Symbol.map.

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

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

(cherry picked from commit c7045186819dbc64c3f005cb1138a1948868cf5a)
2023-12-13 22:08:14 +00:00
Brooks Davis
01edb548c5 libc: centralize makecontext symbols
Declare makecontext() and __makecontext() symbols centrally as they are
always implemented.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42617

(cherry picked from commit 5d79b5445e12873b316a04de352d12a02bfe2d53)
2023-12-13 22:08:14 +00:00
Brooks Davis
ba1279da0f libc: centralize {_,sig,}{set,long}jmp symbols
These symbols are universally exposed and documented so declare them
centrally.  Double- and triple-underscore versions exist on some
platforms, but leave those alone for now.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D42616

(cherry picked from commit 1c656143be734de4b1e1bac27c0c48ef4d974510)
2023-12-13 22:08:14 +00:00
Brooks Davis
695639d2f4 libc: Remove empty comments in Symbol.map
These were left over from $FreeBSD$ removal.

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

(cherry picked from commit 1ca63a8219b88b752b064d19bd3428c61dbcf1f9)
2023-12-13 22:08:13 +00:00
Warner Losh
4025b5b527 libc: Purge unneeded cdefs.h
These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42385

(cherry picked from commit 559a218c9b257775fb249b67945fe4a05b7a6b9f)
2023-11-26 21:20:09 -07:00
Gordon Bergling
edb6d4f50d getpeerid.3: Clarify the 's' argument
The argument 's' of getpeerid(3) must be a connected UNIX-domain socket,
so document it.

PR:	248614
Differential Revision:	https://reviews.freebsd.org/D42629

(cherry picked from commit fa9f74220146233b7224da7c94870540dc39ae68)
2023-11-21 07:49:28 +01: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
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
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
Konstantin Belousov
89e17c6ea0 libc/gen/_pthread_stubs.c: Remove stray whitespaces
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-21 01:44:18 +03:00
Minsoo Choo
0dc52b7210 libc: export pthread_getname_np stub
pthread_getname_np needs to be provided by libc in order to import
jemalloc 5.3.0.

A stub implementation for libc pthread_getname_np() is added for
_pthread_stubs.c, which always reports empty name for the main thread.

Internal _pthread_getname_np() is not exported, but provided for libc
own use.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41461
2023-08-21 01:44:17 +03:00
Warner Losh
b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh
fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh
d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh
1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh
42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh
b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Warner Losh
c251557621 glob.h: Remove $FreeBSD$
This likely documented where this file was copied, but the $FreeBSD$
tag was lost as soon as it was committed. Just remove it. Also remove
the one that looked like it was intended to track versions. That will
simplify the MFC.

Sponsored by:		Netflix
2023-08-16 01:46:21 -06:00
Konstantin Belousov
21a52f9944 libc dlfcn.c: make dl_iterate_phdr() from libc more useful
Apparently there are applications that resolve dl_iterate_phdr from libc
and try to call the symbol. Our libc only provides stubs for dl* to
satisfy static linker or statically linked binaries, and is not prepared
to this situation.

Add a code to dso libc to find real dl_iterate_phdr and redirect the
call to it.

Reported by:	yuri
PR:	272992
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-08-09 08:07:05 +03:00
Eugene Grosbein
5aee3e14d4 syslog.3: document ident[N] format
When libc switched to generation of logs as per RFC 5424,
that change broke application ability to insert specific process id
using ident[N] format, the feature existed for decades.
Some processes rely on it (including logger and syslogd).

Later the regression was fixed but the feature remained undocumented.
This change documents it.

MFC after:	1 week
2023-07-03 19:46:40 +07:00
Konstantin Belousov
42ceab3ea1 libc.a: implement _rtld_addr_phdr()
to make __cxa_thread_call_dtors() operational for statically linked
binaries.

Noted by:	andrew
Reviewed by:	emaste, dim
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40748
2023-06-25 21:27:25 +03:00
Peter Wemm
e829181c65
libc: Update copyright text to match current templates. 2023-05-18 11:30:10 -07:00
Warner Losh
b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00