| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Implement bsearch_s() as per §K.3.6.3.2 in C23, first specified
in C11. It behaves identically to bsearch(), except the callback
is called with a third argument, context, which is passed through
from the caller, and it also performs runtime constraint checking
on its arguments.
- Document bsearch_b(), bsearch_s(), and add history section
- Add rudimentary unit tests for bsearch(), bsearch_b(), and bsearch_s()
Reviewed by: dteske, fuz
Approved by: dteske (mentor), fuz (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D58876
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The UEXTERROR(3) macro is a partial analog to EXTERROR(9) that sets
the current user exterror state and errno. The main difference is
that it returns no value and sets errno directly since that's the
typical pattern in libraries.
While here move the storage and constructor for single-threaded
program's uexterr to its own file.
Reviewed by: kib
Effort: CHERI upstreaming
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D58059
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
To avoid any sort of POLA violation, this commit restores old
guards and defines the C23 feature test macros in addition to
them. This is to close off whole class of possible breakage,
rather than patching it case by case.
Reported by: dim
Reviewed by: dim, dteske, fuz
Approved by: dim, dteske (mentor), fuz (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D58911
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add fts_openat() as a new entry point for fts(3).
When dirfd is AT_FDCWD the behaviour is identical to fts_open().
Passing a pre-opened directory fd allows fts traversal inside
Capsicum capability mode where path-based operations are not
permitted.
Capability mode users should use fts_parent->fts_dirfd + fts_name with
openat(2) to access files.
Reviewed by: asomers
Relnotes: yes
Sponsored by: Google LLC (GSoC 2026)
Pull Request: https://github.com/freebsd/freebsd-src/pull/2273
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a C23 stdckdint.h header for userspace, which provides checked
addition, subtraction and multiplication. We lack similar helpers in
the kernel, where they are regularly needed.
Let's just adopt the C23 macros. For bonus points, I added a wrapper to
ensure that ignored an return value is raised as an error by the
compiler.
Reviewed by: kib, emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D58773
|
| |
|
|
|
|
|
|
|
|
| |
Define the __STDC_VERSION_STDIO_H__ feature test macro now that
the header fully conforms to C23.
Reviewed by: fuz
Approved by: fuz (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D58842
|
| |
|
|
|
|
|
| |
Reviewed by: fuz
Approved by: fuz (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D58842
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Several standard library functions are specified to return an unqualified
pointer while accepting a pointer to a potentially const-qualified object.
N3020 addresses this behaviour, discarding qualifiers due to incompatible
pointer types, by introducing qualifier-preserving macros for the affected
set of standard library functions.
Add `__qualsel()` helper to `<sys/cdefs.h>`, implemented using the generic
selection, and define qualifier-preserving macros for that set of functions
in `<string.h>`, `<wchar.h>`, and `<stdlib.h>`.
Macros are gated on `_STDC_VERSION__ >= 202311L && !__cplusplus`, therefore
there is no behavioural change for earlier C modes or C++ translation units.
The kernel is likewise unaffected, as it does not include userland headers.
As function-like macros, they are transparent except at a call site where
the address-of operator is applied, the macro is suppressed via `#undef`,
or the identifier appears in parenthesised form; all of which cause the
underlying function designator to be used instead.
Reviewed by: fuz
Approved by: fuz (mentor)
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/2288
|
| |
|
|
|
|
|
|
|
|
|
| |
Add BOOL_MAX and BITINT_MAXWIDTH macros for C23 compliance, and
define the __STDC_VERSION_LIMITS_H__ feature test macro now that
the header fully conforms to C23.
Reviewed by: fuz
Approved by: fuz (mentor)
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/2352
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously fts_build() called _dup(_dirfd(dirp)) for every child
entry, holding N simultaneous fds for a directory with N children.
Redefine fts_dirfd: instead of a fd for the entry's parent
directory, it is now a fd for the entry itself, set only for
directory entries. One dup per directory in fts_build() instead
of one per child. Close fts_dirfd during the directory post-order
visit, before advancing to its sibling.
To access a file using fd-relative operations, callers should use
openat(ent->fts_parent->fts_dirfd, ent->fts_name, ...) instead of
openat(ent->fts_dirfd, ent->fts_name, ...). The fd is valid until the
directory's post-order visit (FTS_DP).
Reported by: Mark Johnston <markj@FreeBSD.org>
Fixes: 4bd01d6ae016 (fts: refactor to use fd-relative operations)
Sponsored by: Google LLC (GSoC 2026)
Reviewed by: asomers
Pull Request: https://github.com/freebsd/freebsd-src/pull/2360
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace all _open() calls with _openat() in __fts_open(), fts_read(),
and fts_children(). Replace statfs() with _fstatfs().
Add fts_dirfd to struct _ftsent, set to the file descriptor of the
parent directory. Callers can use openat(ent->fts_dirfd, ent->fts_name,
...) to access files safely without relying on fts_accpath, which
enables programs in capability mode to open the files described by
_ftsent.
This is a preparatory change for fts_openat() which will allow callers
to provide a pre-opened directory fd, enabling fts(3) traversal inside
Capsicum capability mode.
Mirror all fts_open() changes to fts_open_b().
As a result of expanding _ftsend, publish new ELF symbol versions for
fts_openat and related functions.
Sponsored by: Google LLC (GSoC 2026)
Reviewed by: asomers
Pull Request: https://github.com/freebsd/freebsd-src/pull/2303
|
| |
|
|
|
|
|
|
|
|
|
|
| |
strfromd(), strfromf(), and strfroml() are implemented directly
in terms of gdtoa. If a non-conforming format string is passed,
the string "EDOOFUS" is returned and errno set to EDOOFUS as an
extension.
Reviewed by: fuz
MFC after: 1 month
Pull-Request: https://github.com/freebsd/freebsd-src/pull/2301
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Nexus-attached driver that discovers and parses coreboot's LBIO tables
from physical memory. Exposes firmware metadata (version, build info,
mainboard, serial config, TSC frequency, CBMEM entries) via sysctl
hw.coreboot.*, the firmware console ring buffer via /dev/coreboot_console,
and structured CBMEM entry access via /dev/cbmem ioctl interface.
Tested on:
- Qotom Q535G6 (Kabylake)
- Intel NUC D54250WYK (Haswell)
- Intel NUC D33217GKE (Ivy Bridge)
- Dell 3100 2-in-1 (Gabbiter)
- Dell 3100 (Fleex)
- Lenovo IdeaPad 320s
- Lenovo ThinkPad T480
- HP Chromebook 11 G4
- HP Chromebook 11 G5
- HP Chromebook 11 G6 EE
- HP Chromebook 14 G4
- HP Chromebook 14 G5
- HP Chromebook x360 11 G1 EE
- HP Chromebook x360 11 G2 EE
- HP Chromebook x360 14 G1
- Acer C720
- Acer Chromebook 11
- Lenovo N22
Reviewed by: ngie, kib, adrian
Differential Revision: https://reviews.freebsd.org/D55649
|
| |
|
|
|
|
|
| |
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D58463
|
| |
|
|
|
| |
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D57927
|
| |
|
|
| |
This reverts commit 95978326cb326c69592c75323914bdc52ada0346.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit e03ed9daeb49fffa1d16b8d00240c65e92650d01.
The change to the size of struct FTSENT is breaking backwards
compatibility for some binaries. Jitendra is working on a new version
that will move the new field into a private struct.
Reported by: bdrewery
Fixes: e03ed9daeb4 ("fts: refactor to use fd-relative operations")
Sponsored by: ConnectWise
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace all _open() calls with _openat() in __fts_open(), fts_read(),
and fts_children().
Add fts_dirfd to FTSENT. Callers can use
openat(ent->fts_dirfd, ent->fts_name, ...) to access files
safely without relying on fts_accpath, which enables:
1. Capsicum capability mode where path-based operations fail
2. Security-sensitive programs that avoid TOCTOU races
Replace statfs(ent->fts_path) with _fstatfs(ent->fts_dirfd) in
fts_ufslinks() when fts_dirfd is valid, falling back to statfs() for
root-level entries where fts_dirfd is -1
This is a preparatory change for fts_openat() which will allow
callers to provide a pre-opened directory fd, enabling fts(3)
traversal inside Capsicum capability mode.
Sponsored by: Google LLC (GSoC 2026)
Reviewed by: asomers, jillest
MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/2278
|
| |
|
|
|
|
|
|
| |
While here, drop duplicate include.
MFC after: 1 week
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D57733
|
| |
|
|
|
|
|
|
|
|
| |
C23 deprecates <stdalign.h> and specifies that the header shall
provide no content (§7.15.1).
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Pull Request: https://github.com/freebsd/freebsd-src/pull/2223
MFC after: 1 month
Reviewed by: imp, fuz
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Replace the `(bool(*)(bool))` probe in `__assert_sanitize()` with an unevaluated
conditional expression, so types with `explicit operator bool()` that require a
contextually converted constant expression of type `bool` are handled correctly.
Ergo, arity check is now performed separately via `__assert_sanitize_arity()`, a
unary template whose parameter pack must bind to exactly on argument after
`__VA_ARGS__` is substituted into the call.
Also align NDEBUG with C23 requirements.
Reported by: dim, aokblast
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: aokblast, fuz
MFC after: 1 week
Fixes: 867b51452ea78ece0b312a387e63fdbc2a11056a
Pull Request: https://github.com/freebsd/freebsd-src/pull/2265
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add C23 sized deallocation entry points as thin wrappers around free(3).
Implementations may ignore size and alignment hints, so behaviour stays
correct for existing allocations without validating caller metadata yet.
When jemalloc is updated to 5.3.1, rewire these to je_free_sized() and
je_free_aligned_sized() so deallocation can use the allocator's sized
deallocation (free_sized for fast paths and free_aligned_sized for
correct aligned hints.)
Please note this change satisfies the standard interface only. Both
functions should be delegated to jemalloc after the upgrade so callers
get the intended allocator behaviour; until then, hints are unused and
neither sized nor aligned-sized deallocation optimizations apply.
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: fuz
Pull Request: https://github.com/freebsd/freebsd-src/pull/2201
MFC after: 1 month
|
| |
|
|
|
|
| |
This broke cross-building on Linux and macOS.
This reverts commit 823d00b2d447247f1c5860e3bbc61f6fd19a70e5.
|
| |
|
|
|
|
|
| |
MFC after: 1 week
Inspired by: NetBSD
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D57252
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
style(9) still allows TAB after #define but this is a historical
artifact and by far the minority of uses cases. Going forward, we would
like to promote the use of a single space, as it allows alignment to
survive line prefixing (such as in diffs).
style(9) also has prescribed a single space between '#else' or '#endif'
and a comment recalling the guard since 2002.
So, commit 157c184689ea ("assert.h: Remove leading tabs for whitespace
consistency") was good, and in line with rules about whitespace changes
(since the file was heavily modified by surrounding commits).
This commit is thus basically a revert of 439710cf003b ("assert.h:
Revert "Remove leading tabs for whitespace consistency"), which extended
replacing spaces with TABs in the code introduced in the meantime (after
commit 157c184689ea).
Reviewed by: fuz, imp
Fixes: 439710cf003b ("assert.h: Revert "Remove leading tabs for whitespace consistency")
MAC after: 3 days
Differential Revision: https://reviews.freebsd.org/D57391
|
| |
|
|
|
|
|
|
|
|
|
| |
This reverts commit 157c184689ea3d7b8b6bd89aff849e94f004aa0e.
As per style(9), a tab goes after #define. This should not have been
removed.
Reported by: kib
Fixes: 157c184689ea3d7b8b6bd89aff849e94f004aa0e.
Pull Request: https://github.com/freebsd/freebsd-src/pull/2203
|
| |
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D57038
|
| |
|
|
|
|
|
| |
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: fuz
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/2203
|
| |
|
|
|
|
|
| |
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: fuz
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/2203
|
| |
|
|
|
|
|
| |
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: fuz
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/2203
|
| |
|
|
|
|
|
| |
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: fuz
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/2203
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`yp_prot.h` has carried a SunRPC-era typedef of `bool` guarded by
`BOOL_DEFINED`, but the header itself does not use it. The YP/RPC
interfaces use `bool_t` for protocol booleans.
Defining `bool` in a public header collides with modern C headers
that provide `bool` as a macro or keyword, such as `<stdbool.h>`
and C23-aware assert handling. Drop the compatibility typedef and
leave `bool` definition to the consumer's language mode.
Signed-off-by: Faraz Vahedi <kfv@kfv.io>
Reviewed by: fuz
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/2203
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previous script called acpiconf(8) (or apm(8) if ACPI wasn't supported,
although this was anyway redundant because APMIO just uses ACPI now).
Since a new generic power management interface was introduced, this isn't
sufficient, as this would only work for ACPI systems and for ACPI S3 suspend
(so no way to select suspend-to-idle). Rewrite in C to take advantage of the
new power interface.
We may want to add a switch to manually override the kern.power.suspend sysctl,
which is otherwise what the power device uses to decide which suspend type to
switch to (suspend-to-idle or firmware suspend), but this will require us to
amend the power interface.
Reviewed by: olce, imp, mhorne, ziaee
Tested by: mhorne
Approved by: olce, imp, mhorne, ziaee
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D56918
|
| |
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D56365
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Sorry for the mess.
Revert "sys/vnode.h: remove stale comment"
This reverts commit f193f5a749b696e6c05fa2c47c24522b1624b1a7.
Revert "vfs: convert VFS_OPs from macros to static inlines"
This reverts commit 48bf024f2ef5afeba3500bd92a04283370479edf.
Revert "vnode: add VIRF_KNOTE flag"
This reverts commit 7fe74a02764e5899b10cdc45ab34182b961d5d19.
Revert "vfs: convert vfs_op_thread_* macros to static inlines"
This reverts commit a61a696e78a967b149a6e39b1f98ada26217a6bb.
Revert "struct vnode: assign v_rl.resv1 as v_vrflag"
This reverts commit d990e8f0e9478194569ba28c366b0c0c0f414e7b.
Revert "sys/rangelock.h: explicitly enumerate padding at the end of the structure"
This reverts commit a770638ecf16515d8922111c3fdd417aba6c045e.
Revert "bufspace_wait(): only try to help bufdaemon if there is a chance to help"
This reverts commit 067cfac2e7bd9dc857fb6cc504c01b0249bcd1b7.
Revert "Add O_SYMLINK emulation"
This reverts commit f9458655e78f6532e962a13d28d6a6086b4156de.
Revert "libc: add freadlink(3)"
This reverts commit ae6a13deb8e33a52188643e09171207e1d7171e8.
Revert "Add O_SYMLINK emulation"
This reverts commit 2213820b6f4cd22bbfdc0f45741c3e7d17ae82c0.
|
| |
|
|
|
|
| |
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D56365
|
| |
|
|
|
|
|
|
|
|
|
| |
The getgroups test is a NetBSD tests, so just apply our larger hammer
and disable the feature entirely. The audit test can take a more
surgical approach and use __ssp_real() appropriately, since it's a local
one.
PR: 294881
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D56735
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Annex K specifies an interface for handling constraint violations from
gets_s, but we previously broke this for some classes of get_s misuse.
Provide a more nuanced version that tries to dodge errors that would
trigger a constraint handler while still providing value. Notably, we
don't want to trigger a failure unless the passed-in length reasonably
fits within an RSIZE_MAX, because gets_s will immediately call larger
lengths bogus and fail.
PR: 294881
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D56734
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These are required by ISO/IEC 9899:2024 § 7.18.1 ¶ 1 but were forgotten
in my initial work.
The current approach leaks intptr_t, uintptr_t, intmax_t, and uintmax_t
through <sys/_stdint.h>. This could be avoided using a more complicated
approach if desired.
PR: 294131
Fixes: 6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64
Reported by: Collin Funk <collin.funk1@gmail.com>
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56515
|
| |
|
|
|
|
|
| |
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D56362
|
| |
|
|
|
|
|
|
|
| |
Drop the _np suffix.
Reviewed by: dim
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D56222
|
| |
|
|
|
|
|
|
| |
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55539
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Move to sys/_offsetof.h and use __builtin_offsetof() instead of
__offsetof to avoid reintroducing sys/cdefs.h polution in stddef.h.
This has the side effect of allowing sys/stddef.h to be included after
stddef.h which can happen in compatability headers.
Effort: CHERI upstreaming
Sponsored by: DARPA, AFRL
Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D55307
|
| |
|
|
|
|
|
|
|
|
|
| |
I'd missed that stddef.h is standalone and isn't a copy of sys/stddef.h
in my initial merge.
Effort: CHERI upstreaming
Reviewed by: kib
Sponsored by: Innovate UK
Fixes: dca634d1544b ("new type: ptraddr_t")
Differential Revision: https://reviews.freebsd.org/D55305
|
| |
|
|
|
|
|
|
|
|
|
| |
Include sys/types.h by exterr.h, since size_t is used.
Drop include of sys/exterr_cat.h, it is useless for the only prototype
provided.
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55337
|
| |
|
|
|
|
|
|
|
|
|
|
| |
It takes exactly three arguments of known type.
Tweak the types of various resultproc_t functions to match the type (mostly
added const to struct pointers) allowing us to drop casts.
Effort: CHERI upstreaming
Reviewed by: vangyzen, glebius
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D54941
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The `eachresult` argument is documented to take a function pointer of
type:
bool_t (*)(caddr_t, struct sockaddr_in *)
It was declared to take a resultproc_t which has historically been
declared to be:
bool_t (*resultproc_t)(caddr_t, ...);
This overlapped well enough for currently supported ABIs where variadic
arguments are passed in registers, but this declaration is misaligned
with the documentation (resultproc_t takes three arguments) and will be
fixed in a followup commit.
Fix the type to be non-variadic, matching callbacks, and define a
convenience type of as most callbacks take something other than a char *
as their first argument and need to be cast.
Effort: CHERI upstreaming
Reviewed by: ngie, glebius, jhb
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D54940
|
| |
|
|
|
|
|
| |
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54879
|
| |
|
|
|
|
|
|
|
|
| |
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
|