Commit graph

9924 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
fb18c369c3 access(2): Discourage use of these system calls.
Fixes:		421025a274fb
PR:		262895
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45240

(cherry picked from commit a4be1eb21165d7aedae9dc6634528619ff10d025)
(cherry picked from commit 79b39f23e1)

Approved by:	re (cperciva)
2024-05-23 04:45:55 +02:00
Gordon Bergling
8766ae10d3 access.2: Mention that lstat(2) should be used for symbolic links
access(), eaccess() and faccessat() will always dereference
symbolic links.

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

PR:	262895
Reviewed by:	gbe, pauamma_gundo.com
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44890

(cherry picked from commit 421025a274fb5759b3ecc8bdb30b24db830b45ae)
(cherry picked from commit f075b61137)

Approved by:	re (cperciva)
2024-05-23 04:45:49 +02:00
Alexander Ziaee
839a522e2e intro.2 as errno.2: Update maximum hard link limit
MFC after:	1 week
Co-authored-by: brooks
Reviewed by:	brooks, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1192

(cherry picked from commit 6dfbe695c3223822734dddc926415a3ba347b42c)
(cherry picked from commit 828e648b26)
Approved-by: re (cperciva)
2024-05-21 14:08:58 -06:00
Alexander Ziaee
e59ebcf36f intro.2: Add sys/syscall.h to SYNOPSIS
MFC after:	1 week
Co-authored-by: brooks
Reviewed by:	brooks, emaste, imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1192

(cherry picked from commit 69ff2d754c1c8bd9c2b6cea28aa754e9f92f9613)
(cherry picked from commit cbe2436dda)
Approved-by: re (cperciva)
2024-05-21 14:08:53 -06:00
Konstantin Belousov
a951992d1e libc_private.h: use private namespace name for size_t
This is direct commit to stable/14.
2024-04-30 04:14:52 +03:00
Konstantin Belousov
09bcfbd1ae libc printf_render_errno(): do not use strerror()
(cherry picked from commit aa66995b4c804cbb579f71645d97fe282a798bfc)
2024-04-30 03:48:10 +03:00
Konstantin Belousov
0451d4287a libc: minor style, wrap long lines
(cherry picked from commit bac9d7e8f2931149815c3d5a9ab69594bbdffde6)
2024-04-30 03:48:10 +03:00
Konstantin Belousov
ade62d4062 __vprintf(): switch from strerror() to strerror_rl()
PR:	278556

(cherry picked from commit f887667694632c829b0599b54ff86a072e93df87)
2024-04-30 03:48:10 +03:00
Konstantin Belousov
8f19af4b09 libc: make strerror_rl() usable for libc
(cherry picked from commit 92771bc00ad0f567b27876c34450bef7a0ee61d0)
2024-04-30 03:48:10 +03:00
Konstantin Belousov
afc8b17816 sigqueue(2): Document __SIGQUEUE_TID
(cherry picked from commit dcc180c51b9c13df3d1158d14d450308711fe93c)
2024-04-30 03:48:09 +03:00
Gordon Bergling
499d4a6094 timerfd.2: Remove a double word
- s/is is/is/

(cherry picked from commit bbef63ec27fdb86814e34c4b4013cd92ba86bc42)
2024-04-23 07:22:46 +02:00
Christopher Davidson
ac4ddd8b1f open.2: remove self-reference
Change .Xr reference to .Fn, which quiets a mandoc warning.

Reviewed by:	mhorne
MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1135

(cherry picked from commit d3de1bd429bc51fbbcb37fadaf2581461edf848b)
2024-04-18 15:18:34 -03:00
Dag-Erling Smørgrav
fdde01c5b4 libc: Improve description of mktime() / timegm().
* Mention that mktime() and timegm() set errno on failure.
* Correctly determining whether mktime() / timegm() succeeded with
  arbitrary input (where -1 can be a valid result) is non-trivial.
  Document the recommended procedure.

PR:		277863
MFC after:	1 week
Reviewed by:	pauamma_gundo.com, gbe
Differential Revision:	https://reviews.freebsd.org/D44503

(cherry picked from commit 7534109d13a6cdb22e78d9d4c0a0cd5efd323c45)
2024-04-04 11:41:41 +02:00
Baptiste Daroussin
77205dbc13 pkgbase: install all libc test files into the tests package
(cherry picked from commit 3a9ddfa1ab46b492c861022ea254b3277ef74dde)
2024-03-27 09:37:10 +01:00
Gordon Bergling
87aff05164 xdr(3): Fix a few typos in source code comments
- s/reoutines/routines/
- s/paraemters/parameters/

Obtained from:	NetBSD

(cherry picked from commit 577a721d05aa20f38a615ad1cd5089a51c8571c1)
2024-03-26 06:55:55 +01:00
Konstantin Belousov
e87a6f8860 wmemchr(3): fix prototypes for wcpcpy() and wcpncpy()
PR:	277855

(cherry picked from commit 69d5783ae81b74295118950d01b6dddb3e504a56)
2024-03-24 07:12:39 +02:00
Ed Maste
c3c75c142c open: make non-POSIX errno value more apparent
In the errno list, add an explicit note and reference to the note in the
STANDARDS section.

When O_NOFOLLOW is specified and the target is a symbolic link FreeBSD
sets errno to a value different than that specified by POSIX.  Commit
295159dfa3 added a note to this effect, but I missed it when reading
through the list of errno values.

PR:		214633
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D43618

(cherry picked from commit ea6a6b63e1fd304e790c8ed7627caf5e3ba52bc7)
2024-03-22 09:30:30 -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
Konstantin Belousov
8a7d5d73b8 libc/sys: add errno test
(cherry picked from commit 32fdcff8703da6f2795193acc77ec3c1fb8b723d)
2024-03-02 07:05:05 +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
Andrew Turner
bce8a0ba15 libc: Teach libc about the BTI elf note
Add the Branch Target Identification (BTI) note to libc assembly
sources. As all obect files need the note for the library to have it
we need to insert it in all asm files.

Reviewed by:	emaste, markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D42228

(cherry picked from commit fd5aaf2ea0178b03aa93c35245053247e5d3840c)
2024-02-19 13:17:37 +00:00
Konstantin Belousov
8309579720 Document aio_read2/aio_write2
(cherry picked from commit a52cb4c480f270fc7158a0f58179f7b80d8a5b3c)
2024-02-18 12:01:46 +02: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
Konstantin Belousov
1298ecb6ba lio_listio(2): add LIO_FOFFSET flag to ignore aiocb aio_offset
(cherry picked from commit e4b7bbd6ab77e908a60362aa29e518f224a117b0)
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
Konstantin Belousov
16b1438c73 read.2: Describe debug.iosize_max_clamp
PR:	276937

(cherry picked from commit 3e9515846f8cbff0ecccaab65d9f70890d04429e)
2024-02-14 05:41:54 +02:00
Minsoo Choo
fd15ba7d72 libc: Specify parameter types for function pointer
Reviewed by:	dab
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43726

(cherry picked from commit 6bd60e15b1484c6a3f5a87469e42a8e6ad9ab733)
2024-02-11 10:15:07 -05:00
Mark Johnston
324e914106 libc: Annotate a couple of local functions as such
No functional change intended.

MFC after:	1 week

(cherry picked from commit 8d5353de74471038bd75a6cb39bf58f50a600642)
2024-02-09 09:55:45 -05:00
Konstantin Belousov
14b7cf92e7 open(2): describe *at behavior for dirfd opened without O_SEARCH
(cherry picked from commit a570fe4d0dd979ce099374259ffc45d56ae4e471)
2024-02-01 02:30:40 +02:00
Mark Johnston
ea3197e69b kcmp: Add a manual page
Reviewed by:	kib, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D43562

(cherry picked from commit af0d437dd31f71726f7eb5e9aca9fbd374a8277a)
2024-01-31 09:16:29 -05:00
Yuri Pankov
c0565e7d34 Create namespace for the symbols added during 15-CURRENT cycle
Reviewed by:	kib

(cherry picked from commit 95a4709b2cca726c6b76c6743ba2d665c1730666)
2024-01-31 01:14:38 -06:00
Konstantin Belousov
f8d885c08d Add kcmp(2) userspace bits
(cherry picked from commit 211bdd601ee51f90da9b123807ef68ac122116b9)
2024-01-30 22:24:42 +02:00
Mike Karels
e9e63d77c6 inet(3): clarify syntax accepted by inet_pton
The section INTERNET ADDRESSES describes the acceptance of dotted
values with varying number of parts in multiple bases.  This applies
to inet_aton and inet_addr, but not to inet_pton.  Clarify this
section by listing the functions to which this applies.  Move the
description of what inet_pton accepts into this section from STANDARDS,
where it is easily missed.  Rename the section to clarify that it
applies only to IPv4.  (inet_pton also works with IPv6.)

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

(cherry picked from commit 9231c42127bf8e47588169ecc395f57cae0e15fb)
2024-01-30 14:10:30 -06:00
Mark Johnston
06fc42c0cb libc/amd64: Disable ASAN for amd64_archlevel.c
The code in this file runs before the sanitizer can initialize its
shadow map.

Fixes:	ad2fac552c ("lib/libc/amd64: add archlevel-based simd dispatch framework")

(cherry picked from commit 4dedcb1bb54cbbe8043c79ad733f966b6ffc6972)
2024-01-30 13:01:58 -05:00
Robert Clausecker
ff7799e003 lib/libc/amd64/string: add memrchr() scalar, baseline implementation
The scalar implementation is fairly simplistic and only performs
slightly better than the generic C implementation. It could be
improved by using the same algorithm as for memchr, but it would
have been a lot more complicated.

The baseline implementation is similar to timingsafe_memcmp.  It's
slightly slower than memchr() due to the more complicated main
loop, but I don't think that can be significantly improved.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925

(cherry picked from commit fb197a4f7751bb4e116989e57ba7fb12a981895f)
2024-01-24 20:39:31 +01:00
Robert Clausecker
acb47064d6 lib/libc/tests/string: add memrchr unit tests
The "values" test case is specifically crafted to detect the off-by-one
error previous discovered in the scalar strchrnul implementation.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925

(cherry picked from commit 691ff1832e09a6ccbc8f5b04c88cafc7452b3ce6)
2024-01-24 20:39:30 +01:00
Robert Clausecker
667fa9c404 lib/libc/string: document restrict qualification of memccpy() arguments
POSIX.1-2004 and the upcoming C23 agree that memccpy()'s arguments
are restrict qualified and must not overlap.  In 2002, restrict
qualifiers were added to <string.h>'s declaration of the function.
Make things official and document that the arguments must not
overlap.

See also:	61b60edfd3
Approved by:	kib
MFC after:	1 month
MFC to:		stable/14

(cherry picked from commit e0d4f419ac41aa91b862f3ceadc32a86abf08572)
2024-01-24 20:39:30 +01:00
Robert Clausecker
ddab9e6461 lib/libc/amd64/string: implement strncat() by calling strlen(), memccpy()
This picks up the accelerated implementation of memccpy().

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42902

(cherry picked from commit ea7b13771cc9d45bf1bc6c6edad8d1b7bce12990)
2024-01-24 20:39:30 +01:00
Robert Clausecker
a3ce82e5b8 lib/libc/amd64/string: add memccpy scalar, baseline implementation
Based on the strlcpy code from D42863, this patch adds a SIMD-enhanced
implementation of memccpy for amd64. A scalar implementation calling
into memchr and memcpy to do the job is provided, too.

Please note that this code does not behave exactly the same as the C
implementation of memccpy for overlapping inputs. However, overlapping
inputs are not allowed for this function by ISO/IEC 9899:1999 and neither
has the C implementation any code to deal with the possibility. It just
proceeds byte-by-byte, which may or may not do the expected thing for
some overlaps. We do not document whether overlapping inputs are
supported in memccpy(3).

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42902

(cherry picked from commit fc0e38a7a67a6d43095efb00cf19ee5f95dcf710)
2024-01-24 20:39:30 +01:00
Robert Clausecker
de2d155d2c lib/libc/tests/string: add unit tests for memccpy()
Adapted from the strlcpy() unit tests.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785

(cherry picked from commit e4b7b0bcbc741f0998640c2ba55ec00ba613bb75)
2024-01-24 20:39:29 +01:00
Robert Clausecker
3045c0f198 lib/libc/amd64/string: implement strlcat() through strlcpy()
This should pick up our optimised memchr(), strlen(), and strlcpy()
when strlcat() is called.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42863

(cherry picked from commit 2b7b03b7ae179db465c1ef19a5007f729874916a)
2024-01-24 20:39:29 +01:00
Robert Clausecker
903cb811ff lib/libc/amd64/string: add strlcpy scalar, baseline implementation
Somewhat similar to stpncpy, but different in that we need to compute
the full source length even if the buffer is shorter than the source.

strlcat is implemented as a simple wrapper around strlcpy.  The scalar
implementation of strlcpy just calls into strlen() and memcpy() to do
the job.

Perf-wise we're very close to stpncpy.  The code is slightly slower as
it needs to carry on with finding the source string length even if the
buffer ends before the string.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42863

(cherry picked from commit 74d6cfad54d676299ee5e4695139461876dfd757)
2024-01-24 20:39:28 +01:00
Robert Clausecker
f5d63ae20d lib/libc/tests/string: add unit test for strlcpy
A straightforward derivation from the stpncpy unit test.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42863

(cherry picked from commit f7098b8659923873a7c60b64cb68182e470786f9)
2024-01-24 20:39:28 +01:00
Robert Clausecker
7a605ba8f7 lib/libc/amd64/string/strcat.S: enable use of SIMD
strcat has a bespoke scalar assembly implementation we
inherited from NetBSD.  While it performs well, it is
better to call into our SIMD implementations if any SIMD
features are available at all.  So do that and implement
strcat() by calling into strlen() and strcpy() if these
are available.

Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Reviison: https://reviews.freebsd.org/D42600

(cherry picked from commit aff9143a242c0012b0195b3666e03fa3b7cd33e8)
2024-01-24 20:39:28 +01:00
Robert Clausecker
76f9afcdcf lib/libc/amd64/string: implement strncpy() by calling stpncpy()
Sponsored by:	The FreeBSD Foundation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42519

(cherry picked from commit e19d46c808267f53455e96a28ff7654211523d2c)
2024-01-24 20:39:27 +01:00