| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The original scalar implementation of strrchr() had incorrect
logic that failed if the character searched for was the NUL
character. It was also possibly affected by the issue fixed
in 3d8ef251a for strchrnul().
Rewrite the function with logic that actually works. We defer
checking for the character until after we have checked for NUL.
When we encounter the final NUL byte, we mask out the characters
beyond the tail before checking for a match.
This bug only affects users running on amd64 with ARCHLEVEL=scalar
(cf. simd(7)). The default configuration is not affected.
The bug was unfortunately not caught by the unit test inherited
from NetBSD. An extended unit test catching the issue is proposed
in D56037.
PR: 293915
Reported by: safonov.paul@gmail.com
Tested by: safonov.paul@gmail.com
Fixes: 2ed514a220edbac6ca5ec9f40a3e0b3f2804796d
See also: https://reviews.freebsd.org/D56037
MFC after: 1 week
(cherry picked from commit 253f15c016ca699906f78b8e522a3f7ed675929b)
(cherry picked from commit 23d6516773916d8f324bea51867b0713c476f379)
|
| |
|
|
| |
(cherry picked from commit f7b368d25fadbfcba5072dfab3738082393fa189)
|
| |
|
|
| |
(cherry picked from commit 6cc99baea607255859ee958608e4db6e2ff24793)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Try to make the RETURN VALUES section flow better.
* Add basename(3), dirname(3), free(3) to the SEE ALSO section.
* Drop the CAVEATS section, which was obsolete the moment realpath(3)
was added to the Single Unix Specification in 1994.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55928
(cherry picked from commit 1aecb32021ce46d812db36b9037cdc6f423575f9)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Save prev_len after having checked for and appended a trailing slash,
not before. This requires us to back up if we end up returning a
partial result, but previously we would sometimes return a partial
result with a trailing slash and sometimes without.
* Replace strlcat() with a faster strlcpy() since we know exactly how
far into the buffer we are.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55914
(cherry picked from commit 99d295e471bc362a7927047c89472e1ee2d0da6b)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
developed
strnlen() doesn't seem to cope well with a length argument such that
string pointer plus length overflows past the end of the address space.
Reviewed by: fuz
MFC after: 1 week
PR: 293353, 293296
Differential Revision: https://reviews.freebsd.org/D55714
(cherry picked from commit 2a4e3112c811b9892e14e15cfd23538e7e47329c)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Don't assume that SIGINT and SIGQUIT are set to SIG_DFL at the start
of the test. Instead, retrieve their current dispositions and verify
that they are restored at the end of the test.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55709
(cherry picked from commit 48368f702423742b2a7dff7ad3191625e8bf26f0)
system(3): Fix brain glitch in previous commit
We were saving SIGINT twice instead of SIGINT and SIGQUIT.
Also restore original order of operations (SIGINT then SIGQUIT), which
matches the order in which they're discussed in the POSIX description
of system(3).
MFC after: 1 week
Sponsored by: Klara, Inc.
Fixes: 48368f702423 ("system(3): Address test robustness issue")
(cherry picked from commit 863b5c137a98d29dc6964cba0e0c4fe2a8bebab8)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
There is no need to call execl(), which will allocate an array and copy
our arguments into it, when we can use a static array and call execve()
directly.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55648
(cherry picked from commit 40e52e0edd038460a2a2aca017b3ac5a513fe37b)
|
| |
|
|
|
|
|
|
| |
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D55494
Sponsored-by: Netflix
(cherry picked from commit 6fd98877de633f5ec6f028e78d5a2d94527d63d0)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Our manual page states that if given a null pointer, system() returns
non-zero if the shell is available and zero if it is not. This is
consistent with the C standard's description of system(), but it is not
what we actually do. What we actually do is always return non-zero, as
required by POSIX.
As the POSIX rationale explains, implementing the logic required by the
C standard does not violate POSIX, since a conforming system always has
a shell, therefore the logic will always return non-zero.
Since our libc is commonly used in non-conforming situations such as
chroots or thin jails, we should implement the full logic required by
the C standard.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: obiwac, bnovkov, kevans
Differential Revision: https://reviews.freebsd.org/D55484
(cherry picked from commit 8ae3f44991948cc97b09adc248a9a46db71bf9e0)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Our manual page currently states that system() will return 127 if it
fails to execute the shell. The actual return value is, to quote POSIX,
“as if the command language interpreter had terminated using exit(127)
or _exit(127)”.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, kevans
Differential Revision: https://reviews.freebsd.org/D55483
(cherry picked from commit 7305604b29d3db29c9bb5de6e7a25829fb541d1e)
|
| |
|
|
|
|
|
|
|
|
|
| |
Replace the somewhat perfunctory NetBSD tests with our own.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, kevans
Differential Revision: https://reviews.freebsd.org/D55482
(cherry picked from commit 7a1ade5109ac57d1f59eaa75b5d0f13fabecf6ba)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Ignore SIGINT and SIGQUIT and block SIGCHLD, as POSIX requires.
To deal with the concurrency problem described in POSIX, we keep track
of the count of concurrent invocations. We ignore and block signals
only when the counter was zero before we incremented it, and restore
them only when the counter reaches zero after we decrement it.
Note that this does not address the issue of thread cancellation.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, sef, kevans
Differential Revision: https://reviews.freebsd.org/D55471
(cherry picked from commit 6e589e6e8e64793adb437c561ec084dbb6ad1ced)
|
| |
|
|
| |
(cherry picked from commit a03f285afafae243396c9bc7892cbe717a3ac37d)
|
| |
|
|
| |
(cherry picked from commit 1443a455a96e587a7b49608def79495e9d74513f)
|
| |
|
|
| |
(cherry picked from commit ffbf95907039821b69dfe1607d1695b46af82e35)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This avoids a dependency on the abort symbol in libsys.
PR: 292539
Reviewed by: mmel
Approved by: markj (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D55255
(cherry picked from commit 1782bc9a0a8da2d6aca31b7790981e1980c9e4b9)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Mainly rename numerator parameter of div(3) and ldiv(3) from num to
numer, and explicitly specify what "numer", "denom", and "rem" mean in
the manpages.
MFC after: 3 days
Obtained from: https://github.com/apple-oss-distributions/libc (partially)
Sponsored by: Klara, Inc.
(cherry picked from commit 0bba277f2223a31e4453ade39be110b1b3aeb1dd)
|
| |
|
|
|
|
| |
PR: 293072
(cherry picked from commit 10fde719587c22085c95759a242e9c51d249d024)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On arm64 we can use the "dc zva" instruction to zero memory. The CPU
tells software if the instruction is implemented, and if so the size
and alignment it will use.
When the size is 64-bytes the Arm Optimized Routines implementation of
memset can use dc zva to zero memory, and has a build flag to skip
checking.
Use this flag to build a version of memset that will be used when this
assumption is true.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D54776
(cherry picked from commit 32d1f18865abe94d351a6f178a93b7195595ec69)
|
| |
|
|
|
|
|
|
|
|
|
| |
This allows static binaries to only include the functions they
reference.
Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D54775
(cherry picked from commit f0516ed4652cfb7435f8c5a16b46dc067779a1a8)
|
| |
|
|
|
|
|
|
|
|
|
| |
If we update Makefile.inc it may be to change the contents of these
files.
Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D54774
(cherry picked from commit 00f68392130cf597c7c76669c63dab26b31630c1)
|
| |
|
|
|
|
|
|
|
| |
Reviewed by: andrew
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D54560
(cherry picked from commit 41ccf82b29f3b16fcd1ccb4987569c851222ef8d)
(cherry picked from commit fb96702a034c663adb4a1b44299af01fa71e29fd)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Function arguments are based on Section 9.4.1 "GNU C Library IFUNC interface"
from "System V ABI for the Arm 64-bit Architecture (AArch64)", 2025Q1.
(https://github.com/ARM-software/abi-aa/releases/download/2025Q1/sysvabi64.pdf)
Reviewed by: andrew
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D54599
(cherry picked from commit 5eec3531204bd93426642a9c45b0c292a01447e4)
|
| |
|
|
|
|
|
|
|
|
|
| |
Mainly, avoid reusing the name of one of the functions we should be
testing (but aren't) for local variables.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55054
(cherry picked from commit d70b9eb74fc4aa430bd2ff4bca37e6a9b6c8004f)
|
| |
|
|
|
|
|
|
| |
Although not needed on FreeBSD due to namespace pollution, we should
technically #include <stddef.h> to secure a definition of NULL.
Fixes: 5074d5c9845e ("libc: Improve POSIX conformance of dirfd()")
(cherry picked from commit 1c00d5a3b234ef937d848956027e9de5ea8010f9)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
POSIX states that dirfd() should set errno to EINVAL and return -1 if
dirp does not refer to a valid directory stream. Our interpretation is
that this applies if dirp is null or the file descriptor associated
with it is negative.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55025
(cherry picked from commit 5074d5c9845e142883cdbb9ad212be66e57615d0)
|
| |
|
|
|
|
|
|
|
|
|
| |
Fix style nits (mostly whitespace issues) and clean up the manual page.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55024
(cherry picked from commit 387ae6390534b6e9b48931840e7bc76eeb0b258d)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If no resolver configuration was found, we would fall back to INADDR_ANY
and IN6ADDR_ANY. This made sense when it was first written thirty or
forty years ago but not today, especially since connecting to INADDR_ANY
or IN6ADDR_ANY is no longer supported. Switch to the loopback address
and simplify the code.
Note that (as the pre-existing comment in the code states) running
without a resolver configuration is not really supported. Still, if
we're going to have a hardcoded fallback, it might as well work.
PR: 291790
MFC after: 1 week
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55011
(cherry picked from commit 1538284a5fddfce546db678cb873b7edc6adb9ed)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
To facilitate comparison with mtree -C generated output, keep the
keywords ordered.
No functional change intended.
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54872
(cherry picked from commit fe962e33d86f888b496b17251c8bedebf92be8ee)
|
| |
|
|
| |
(cherry picked from commit 4daf2d3e7db53a113108f9a02ceaf5051d416184)
|
| |
|
|
| |
(cherry picked from commit 77c5f29453ed3dbb4ba1a372329ab32ec27c998d)
|
| |
|
|
| |
(cherry picked from commit 2a5b083c1f7e0a4518bd944241af1d1102997c4d)
|
| |
|
|
| |
(cherry picked from commit 080d8ed7dd29ba537ce4cca286ed3369aca61ef5)
|
| |
|
|
| |
(cherry picked from commit 58580dc0c694b107ba7ba1b14dc8ee8f306e53f6)
|
| |
|
|
| |
(cherry picked from commit 3f0aea09689f6c10740de78011469355208a19a5)
|
| | |
|
| |
|
|
| |
(cherry picked from commit 2d555ec85a716e016be587b2a1606ca69267f870)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
NO_FP_LIBC was added in 2004 to save space by disabling FP support in
*printf()/*scanf(). The size benefit is negligible on modern systems
and conflicts with assumptions made by current base utilities.
Remove the option and always build libc with floating-point support.
Reported by: Oskar Holmlund <eovholmlund at gmail com>
(cherry picked from commit 8e6843db9bc5af14b0ee631081ecaf1f02ce821a)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If net is all-zero, the loop to extract all leading non-zero octets will
iterate zero times and leave nn with the value 4, which the following
switch statement to initialise qbuf does not handle. As a result,
_dns_getnetbyaddr will look up the PTR record for this uninitialised
string, which will leak the pre-existing contents of that stack memory
to the DNS resolver and, if remote and not otherwise protected, network.
Note that _dns_getnetbyaddr is only used if nsswitch.conf is configured
to enable the "dns" source for the "networks" database, which is not the
default configuration in FreeBSD.
For glibc this same bug, in code also derived from BIND's, was issued
CVE-2026-0915. This commit adopts the same behaviour as glibc's fix,
which is to regard a net of 0 as being for 0.0.0.0. Apparently NetBSD
will return NS_UNAVAIL instead, which may or may not make more sense,
but in general glibc compatibility tends to cause less friction when
there's not a good reason to avoid it.
Reviewed by: markj (secteam)
Fixes: 1363f04ce1b8 ("get* rework and new bind code")
MFC after: 1 day
Security: Same bug as glibc's CVE-2026-0915
(cherry picked from commit 331316b073505e4794754af1cd0c5ccc578a2bde)
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We don't support CPU hotplug, but we do support cpuset(8) restrictions
on jails (including prison0, which uses cpuset 1). The process cannot
widen its cpuset beyond its root set, so it makes sense to instead
report the number of cpus enabled there rather than the total number
in the system.
This change is effectively a nop for the majority of systems and jails
in the wild, though it does reduce the performance of this query now
that we can't take advantage of AT_NCPUS being provided in the auxinfo.
The implementation here is notably different than Linux, which would not
take cgroups into account. They do, however, take CPU hotplug into
account, so the possibility for it to diverge from (and be lower than)
the # configured count to reflect what the process can actually be
scheduled on doesn't really diverge in semantics.
Reviewed by: kib
(cherry picked from commit d617806aac1469319970e3551656e9deabb98a35)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
mac_text(3) as-written would seem to indicate that a `mac_t` should be
freed with free(3), but this isn't the case. One can derive from
context from when the change was introduced and COMPATIBILITY that this
was intended to talk about *text in `mac_to_text`, so move the comment
there.
PR: 179832
Co-authored-by: Priit Järv <priit cc ttu ee>
(cherry picked from commit 081218b7a2006e5b6783e51f66fd751871ac1272)
|
| |
|
|
| |
(cherry picked from commit 3204c097fd08436805f059c0d7f676d29ee9bb62)
|
| |
|
|
| |
(cherry picked from commit b0d4b059cf8425cbe094f93362a61c56a26d45f3)
|
| |
|
|
| |
(cherry picked from commit b8c99e7d912f0dad84cec80f8c4331646b87a3ec)
|
| |
|
|
| |
(cherry picked from commit 04a664d87607d25d87baf56903090707cc91e2e0)
|
| |
|
|
| |
(cherry picked from commit 3088263177da2813dd09364171feadd0e31d1fc3)
|
| |
|
|
| |
(cherry picked from commit 874cdf6af695c42d561647f7165c99c2d3df0faa)
|
| |
|
|
| |
(cherry picked from commit 5685c07b5a8e4ccc19140eeaa5987a38dca7c668)
|