| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This change fixes two NULL pointer dereferences caused by the
__bt_first function.
The first was caused by returning 0 (i.e., RET_SUCCESS) when a key
was not found, causing the caller to dereference an uninitalized
or NULL pointer. The second one was caused by an if statment clobbering
a local variable with a function call result that might be NULL.
Reported by: clang-tidy
Sponsored by: Klara, Inc.
Reviewed by: markj
Obtained from: https://github.com/apple-oss-distributions/libc (partially)
Differential Revision: https://reviews.freebsd.org/D54905
|
| |
|
|
| |
Sponsored by: Klara, Inc.
|
| |
|
|
|
|
|
| |
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54899
|
| |
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
| |
Fixes: 9bf69c37f43e96292e97e41bf942d7aca4101362
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
|
| |
|
|
|
|
|
| |
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54879
|
| |
|
|
|
|
|
| |
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54862
|
| |
|
|
|
|
|
|
|
|
| |
If execfd is set, the fexecve(2) is used by posix_spawn() instead of the
provided path.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54862
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
Make pdwait(2) cancellable, same as all other wait*(2) syscalls wrappers.
Reviewed by: asomers, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54592
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Historically (and in a small amount of older software such as OpenAFS),
developers would attempt to free XDR strings with
xdr_free((xdrproc_t)xdr_string, &string)
This resulted in xdr_free calling xdr_string with only two intentional
arguments and whatever was left in the third argument register. If the
register held a sufficently small number, xdr_string would return FALSE
and not free the string (no one checks the return values).
Software should instead free strings with:
xdr_free((xdrproc_t)xdr_wrapstring, &string)
Because buggy software exists in the wild, act as though xdr_wrapstring
was used in the XDR_FREE case and plug these leaks.
Reviewed by: kib
MFC after: 3 days
Effort: CHERI upstreaming
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D54825
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The type of xdrproc_t is clearly defined in the comments as a function
with two arguments, an XDR * and a void * (sometimes spelled caddr_t).
It was initialy defined as:
typedef bool_t (*xdrproc_t)();
At some point people started giving it a non-empty argument list.
Unfortunatly, there has been widespread disagreement about how arguments
are passed. There seems to have been a widespread view that it should
be allowed to pass three argument function pointer to xdrproc_t. Most
notable is xdr_string which takes a maximum length parameter. This lead
to all sorts of prototypes (all of which have been present in the
FreeBSD source tree):
FreeBSD userspace (nominally from tirpc, but seemingly local):
typedef bool_t (*xdrproc_t)(XDR *, ...);
FreeBSD kernel, glibc:
typedef bool_t (*xdrproc_t)(XDR *, void *, ...);
rcp/xdr.h with _KERNEL defined (not used?):
typedef bool_t (*xdrproc_t)(XDR *, void *, u_int);
gssrpc (in krb5) and Linux kernel:
typedef bool_t (*xdrproc_t)(XDR *, void *);
For two argument functions on current ABIs, these all equivalent as
these arguments are passed in registers regardless of decleration and
definition, but we end up with two problems:
- xdr_free((xdrproc_t)xdr_string, ...) calls xdr_string with no third
argument and (at least on FreeBSD) may fail to free memory if the
string is shorter than the value lying around in the third argument
register. There are no instance of this in tree, but I found some
with Debian code search, in particular in OpenAFS.
- Under CheriABI, variadic arguments are passed in a separate,
bounded array so theses prototypes aren't equilvalent to the
non-variadic calling convention of the functions.
The reality is that that xdr_string should not be cast to xdrproc_t and
xdr_wrapstring should be used instead so we do not need to support this
case. Instances of the former behavior are now extremely rare.
With this change we bring FreeBSD in line with gssrpc and the Linux
Kernel. Warnings about casts should now be correct and should be fixed.
Bump __FreeBSD_version as some software required adaptation if it is
declaring functions to cast to xdrproc_t. Update OpenZFS's workaround
of this historic mess accordingly.
Effort: CHERI upstreaming
Sponsored by: Innovate UK
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54824
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Nobody else's mac.conf(5) has any entries for jails, so they get a
trivial ENOENT and we fail before we can fetch any jail parameters.
Most notably, this breaks `jls -s` / `jls -n` if you do not have any
loaded policy that applies jail labels.
Add an entry that works for everyone, and hardcode that as an ENOENT
fallback in libjail to provide a smoother transition. This is probably
not harmful to leave in long-term, since mac.conf(5) will override it.
This unearthed one additional issue, in that mac_get_prison() in the
MAC framework handled the no-label-policies bit wrong. We don't want
to break jail utilities enumerating jail parameters automatically, so
we must ingest the label in all cases -- we can still use it as a small
optimization to avoid trying to copy out any label. We will break
things if a non-optional element is specified in the copied in label,
but that's expected.
The APIs dedicated to jaildescs remain unphased, since they won't be
used in the same way.
Fixes: db3b39f063d9f05 ("libjail: extend struct handlers [...]")
Fixes: bd55cbb50c58876 ("kern: add a mac.label jail parameter")
Reported by: jlduran (on behalf of Jenkins)
Reviewed by: jlduran
Differential Revision: https://reviews.freebsd.org/D54786
|
| |
|
|
|
|
|
|
|
|
|
| |
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>
MFC after: 2 weeks
|
| |
|
|
|
|
|
|
|
| |
Change tdestroy() to immediately free a node with no right child as
soon as it is encountered. Currently, such nodes are visited twice
before deletion.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54699
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
Add strtonumx(), a companion to strtonum(3) that preserves its safety
and error-reporting semantics while allowing the caller to specify a
conversion base, similar to the strtol(3) family of functions.
Reviewed by: emaste, kib, ziaee
Obtained from: https://www.illumos.org/issues/15365
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54270
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The __aligned attribute in the previous version applied to the location
of the pointers, not the data the pointers pointed to. While this
could be fixed by applying the attribute to a local typedef of uint16_t,
just using memcpy() for the unaligned access is simpler and ISO C.
This fixes the build on CHERI architectures which do not support
misaligned pointers and were thus failing with:
lib/libc/string/swab.c:12:18: error: alignment (1) of 'const uint16_t *' (aka 'const unsigned short *') is less than the required capability alignment (16) [-Werror,-Wcheri-capability-misuse]
12 | const uint16_t *f __aligned(1) = from;
|
Co-authored by: Jessica Clarke <jrtc27@FreeBSD.org>
Fixes: 02ebbc781f08 ("swab: Fix implementation to support overlapping copies")
Sponsored by: AFRL, DARPA
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D54399
|
| |
|
|
|
|
| |
Reviewed by: andrew
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D54560
|
| |
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Make it possible to search for literal two colons (::) and actually
find something. Make the "x"/"x:"/"x::" examples more explicit and
more visibile.
Signed-off-by: Simon Wollwage <rootnode+freebsd@wollwage.com>
Obtained from: NetBSD, nbuwe <uwe@stderr.spb.ru>, 856d5b6
PR: 291374
Reviewed by: imp, jlduran
Pull Request: https://github.com/freebsd/freebsd-src/pull/1923
|
| |
|
|
|
|
|
| |
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by: emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1914
(cherry picked from commit 907cf3e4378f9d114af41d05a59ef4a075d3efb0)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous fix introduced a regression on machines without the BMI1
instruction set extension. The TZCNT instruction used in this function
behaves different on old machines when the source operand is zero, but
the code was originally designed to never trigger this case. The bug
fix caused this case to be possible, leading to a regression on
sufficiently old hardware.
Fix the code by messing with things such that the source operand is
never zero.
PR: 291720
Fixes: 66eb78377bf109af1d9e25626bf254b4369436ec
Tested by: cy
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D54303
|
| |
|
|
|
|
|
| |
Reviewed by: alc, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54365
|
| |
|
|
|
|
|
| |
Reviewed by: alc, emaste, ziaee
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54365
|
| |
|
|
|
|
|
|
|
|
|
| |
The function clears the whole tree.
Relnotes: yes
Reviewed by: alc, emaste
Discussed with: dougm
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54365
|
| |
|
|
|
|
|
| |
Reviewed by: alc, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54365
|
| |
|
|
|
|
|
|
|
| |
, related functions, and the EXTERROR_VERBOSE environment variable.
Reviewed by: emaste, mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54380
|
| |
|
|
|
|
|
| |
Reviewed by: emaste, mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54380
|
| |
|
|
| |
MFC after: 1 week
|
| |
|
|
|
|
|
|
|
|
|
|
| |
If the variable is set and the process is not suid, __uexterr_format(),
used by err(3), prints errno/category/source line/pX always, not only
when there is no kernel message provided.
Requested by: mckusick
Reviewed by: emaste, mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54380
|
| |
|
|
|
|
|
|
|
|
| |
Note that we trust kernel code to only request the printout of integer
types, and use the 'j' modifier always.
Reviewed by: emaste, mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54380
|
| |
|
|
|
|
|
| |
Reviewed by: emaste, mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54380
|
| |
|
|
|
|
|
|
|
| |
This implementation appears to be broken on some CPUs. Disable it
until the issue can be investigated and fixed.
PR: 291720
Fixes: 66eb78377bf1 ("libc/amd64: fix overread conditions in stpncpy()")
Fixes: 90253d49db09 ("lib/libc/amd64/string: add stpncpy scalar, baseline implementation")
|
| |
|
|
|
|
|
| |
I misapplied ngie's recommended correction.
Fixes: 123c086200491819595abc271d360e605288fd18
Differential Revision: https://reviews.freebsd.org/D54169
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to incorrect unit test design, two overread conditions went
undetected in the amd64 baseline stpncpy() implementation.
For buffers of 1--16 and 32 bytes that do not contain nul bytes
and end exactly at a page boundary, the code would incorrectly
read 16 bytes from the next page, possibly crossing into an
unmapped page and crashing the program. If the next page was
mapped, the code would then proceed with the expected behaviour
of the stpncpy() function.
Three changes were made to fix the bug:
- an off-by-one error is fixed in the code deciding whether to
enter the runt case or not, entering it for 0<n<=32 bytes
instead of 0<n<32 bytes as it was before.
- in the runt case, the logic to skip reading a second 16-byte
chunk if the buffer ends in the first chunk was fixed to
account for buffers that end at a 16-byte boundary but do not
hold a nul byte.
- in the runt case, the logic to transform the location of the
end of the input buffer into a bit mask was fixed to allow
the case of n==32, which was previously impossible due to the
incorrect logic for entering said case.
The performance impact should be minimal.
PR: 291359
See also: D54169
Reported by: Collin Funk <collin.funk1@gmail.com>
Reviewed by: getz
Approved by: markj (mentor)
MFC after: 1 week
Fixes: 90253d49db09a9b1490c448d05314f3e4bbfa468 (D42519)
Differential Revision: https://reviews.freebsd.org/D54170
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The test is extended the same way I previously extended the memccpy()
test to fix what is probably the same kind of bug.
PR: 291359
Reported by: Collin Funk <collin.funk1@gmail.com>
Reviewed by: ngie
Approved by: markj (mentor)
Fixes: 6fa9e7d8737548ef93c573387ce62402c368d486 (D42519)
See also: 61ed5748e4e9c7397fcb2638b442f46ac5c9e7c5 (D46051)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54169
lib/libc/tests/string/stpncpy_test.c: apply ngie's fixes
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Add an nscache specific inline function to calculate the misalignment
rather than adding and subtracting _ALIGN(p) and p which can take the
buffer far out of bound (undefined behavior in C and unsupported on
CHERI).
Reviewed by: kib
Effort: CHERI upstreaming
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D53945
|
| |
|
|
|
|
|
| |
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54066
|
| |
|
|
|
|
|
| |
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54066
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This test suite is purely tested with compile-time assertions, so
it needs a dummy runtime test to ensure that kyua reports the
file as passing.
Pull Request: https://github.com/freebsd/freebsd-src/pull/1915
Sponsored by: The FreeBSD Foundation
Reviewed by: fuz
Approved by: markj (mentor)
MFC after: 1 month
Signed-off-by: Siva Mahadevan <me@svmhdvn.name>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
gcc14 is concerned that the operator precedence between - and & might
be confusing. Throw in some redundant parentheses to make it shut up.
The LLVM build was fine before this change.
Reported by: Martin Filla <freebsd@sysctl.cz>
Approved by: markj (mentor)
MFC after: 1 month
Fixes: 6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64
Differential Revision: https://reviews.freebsd.org/D54057
|
| |
|
|
|
|
|
|
|
|
| |
Otherwise the directory created by etc/mtree/BSD.tests.dist, which is
where these belong, and referred to by the generated Kyuafile for
/usr/tests/lib/libc (via stdbit's existence in TESTS_SUBDIRS), ends up
empty with no Kyuafile, which is an error for kyua.
Reported by: kp
Fixes: 2fb8cbc6ef1b ("libc/tests: add stdbit test framework and unit tests")
|
| |
|
|
|
|
|
|
| |
Add cross references to relevant stdbit man pages
Approved by: markj (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D53661
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This adds unit tests for all 70 functions in <stdbit.h>.
I'm sorry for the test framework, but it makes it so I don't
have to write 70 unit tests by hand.
Reviewed by: adrian, des
Approved by: markj (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D53660
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This adds man pages for each group of functions in <stdbit.h>.
The man pages have cross references to one-another.
Cross references from external man pages to these will be added
in a later commit.
Reviewed by: pauamma@gundo.com, kib
Approved by: markj (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D53659
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This new header complies with ISO/IEC 9899:2024 (C23).
Contrary to glibc, we do not provide inline definitions in
<stdbit.h> as we expect our system compiler to soon recognise
these as builtins anyway.
Relnotes: yes
MFC after: 1 month
Reviewed by: adrian
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D53657
|
| |
|
|
|
|
|
|
|
|
| |
This file checks the correctness of the various _MAX, _MIN, and
_WIDTH macros defined for the libc types. It assumes that none
of the types have padding bits.
Approved by: markj (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D53831
|
| |
|
|
|
|
| |
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1903
|