#
b5149b26 |
| 23-Oct-2024 |
Mark Johnston <markj@FreeBSD.org> |
linker: Handle a truncated hints file properly
If vattr.va_size is 0, we will end up accessing invalid memory. This is mostly harmless (because malloc(0) still allocates some memory), but it trigge
linker: Handle a truncated hints file properly
If vattr.va_size is 0, we will end up accessing invalid memory. This is mostly harmless (because malloc(0) still allocates some memory), but it triggers a KASAN report.
PR: 282268 Reviewed by: christos, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47240
show more ...
|
Revision tags: release/13.4.0, release/14.1.0 |
|
#
28a59100 |
| 06-Mar-2024 |
Austin Shafer <ashafer@badland.io> |
linuxkpi: Provide a non-NULL value for THIS_MODULE
THIS_MODULE is used to differentiate modules on Linux. We currently completely stub out any Linux struct module usage, but THIS_MODULE is still use
linuxkpi: Provide a non-NULL value for THIS_MODULE
THIS_MODULE is used to differentiate modules on Linux. We currently completely stub out any Linux struct module usage, but THIS_MODULE is still used to populate the "owner" fields of various drivers. Even though we don't actually dereference these "owner" fields they are still used by drivers to check if devices/dmabufs/etc come from different modules. For example, during DRM GEM import some drivers check if the dmabuf's owner matches the dev's owner. If they match because they are both NULL drivers may incorrectly think two resources come from the same module.
This adds a general purpose __this_linker_file which will point to the linker file of the module that uses it. We can then use that pointer to have a valid value for THIS_MODULE.
Reviewed by: bz, jhb Differential Revision: https://reviews.freebsd.org/D44306
show more ...
|
#
7ef5c19b |
| 31-Mar-2024 |
Mark Johnston <markj@FreeBSD.org> |
kern linker: Don't invoke dtors without having invoked ctors
I have a kernel module which fails to load because of an unrecognized relocation type. link_elf_load_file() fails before the module's ct
kern linker: Don't invoke dtors without having invoked ctors
I have a kernel module which fails to load because of an unrecognized relocation type. link_elf_load_file() fails before the module's ctors are invoked and it calls linker_file_unload(), which causes the module's dtors to be executed, resulting in a kernel panic.
Add a flag to the linker file to ensure that dtors are not invoked if unloading due to an error prior to ctors being invoked.
At the moment I only implemented this for link_elf_obj.c since link_elf.c doesn't invoke dtors, but I refactored link_elf.c to make them more similar.
Fixes: 9e575fadf491 ("link_elf_obj: Invoke fini callbacks") Reviewed by: zlei, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44559
show more ...
|
#
1c7307cf |
| 27-Mar-2024 |
Zhenlei Huang <zlei@FreeBSD.org> |
kern linker: Make linker_file_add_dependency() void
The only possible return value has been zero since cee9542d51f0.
No functional change intended.
Reviewed by: dfr MFC after: 1 week Differential
kern linker: Make linker_file_add_dependency() void
The only possible return value has been zero since cee9542d51f0.
No functional change intended.
Reviewed by: dfr MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D44507
show more ...
|
#
39450eba |
| 26-Mar-2024 |
Zhenlei Huang <zlei@FreeBSD.org> |
kern linker: Do not touch userrefs of the kernel file
A nonzero `userrefs` of a linker file indicates that the file, either loaded from kldload(2) or preloaded, can be unloaded via kldunload(2). As
kern linker: Do not touch userrefs of the kernel file
A nonzero `userrefs` of a linker file indicates that the file, either loaded from kldload(2) or preloaded, can be unloaded via kldunload(2). As for the kernel file, it can be unloaded by the loader but should not be after initialization.
This change fixes regression from d9ce8a41eac9 which incidentally increases `userrefs` of the kernel file.
Reviewed by: dfr, dab, jhb Fixes: d9ce8a41eac9 kern_linker: Handle module-loading failures in preloaded .ko files MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42530
show more ...
|
#
f43ff3e1 |
| 26-Mar-2024 |
Zhenlei Huang <zlei@FreeBSD.org> |
kern linker: Do not unload a module if it has dependants
Despite the name, linker_file_unload() will drop a reference and return success when the module file has dependants, i.e. it has more than on
kern linker: Do not unload a module if it has dependants
Despite the name, linker_file_unload() will drop a reference and return success when the module file has dependants, i.e. it has more than one reference. When user request to unload such modules then the kernel should reject unambiguously and immediately.
PR: 274986 Reviewed by: dfr, dab, jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42527
show more ...
|
#
c21bc6f3 |
| 22-Mar-2024 |
Bojan Novković <bnovkov@FreeBSD.org> |
ddb: Add CTF-based pretty printing
Add basic CTF support and a CTF-powered pretty-printer to ddb.
The db_ctf.* files expose a basic interface for fetching type data for ELF symbols, interacting wit
ddb: Add CTF-based pretty printing
Add basic CTF support and a CTF-powered pretty-printer to ddb.
The db_ctf.* files expose a basic interface for fetching type data for ELF symbols, interacting with the CTF string table, and translating type identifiers to type data.
The db_pprint.c file uses those interfaces to implement a pretty-printer for all kernel ELF symbols. The pretty-printer works with symbol names and arbitrary addresses: pprint struct thread 0xffffffff8194ad90
Pretty-printing currently only works after the root filesystem gets mounted because the CTF info is not available during early boot.
Differential Revision: https://reviews.freebsd.org/D37899 Approved by: markj (mentor)
show more ...
|
Revision tags: release/13.3.0, release/14.0.0 |
|
#
ecf710f0 |
| 07-Nov-2023 |
Zhenlei Huang <zlei@FreeBSD.org> |
kern linker: Do not retry loading modules on EEXIST
LINKER_LOAD_FILE() calls linker_load_dependencies() which will return EEXIST in case the module to be loaded has already been compiled into the ke
kern linker: Do not retry loading modules on EEXIST
LINKER_LOAD_FILE() calls linker_load_dependencies() which will return EEXIST in case the module to be loaded has already been compiled into the kernel. Since the format of the module is now recognized then there is no need to retry loading with a different linker, otherwise the userland will get misleading error number ENOEXEC.
PR: 274936 Reviewed by: dfr MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42474
show more ...
|
#
110113bc |
| 09-Sep-2023 |
Zhenlei Huang <zlei@FreeBSD.org> |
sysctl(9): Enable vnet sysctl variables to be loader tunable
Complete phase two of 3da1cf1e88f8.
In 3da1cf1e88f8, the meaning of the flag CTLFLAG_TUN is extended to automatically check if there is
sysctl(9): Enable vnet sysctl variables to be loader tunable
Complete phase two of 3da1cf1e88f8.
In 3da1cf1e88f8, the meaning of the flag CTLFLAG_TUN is extended to automatically check if there is a kernel environment variable which shall initialize the SYSCTL during early boot. It works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTLs which belong to VNETs.
This change extends the meaning further, to allow it also works for the SYSCTLs which belong to VNETs. A typical usage is ``` VNET_DEFINE_STATIC(int, foo) = 0; SYSCTL_INT(_net, OID_AUTO, foo, CTLFLAG_RWTUN | CTLFLAG_VNET, &VNET_NAME(foo), 0, "Description of the foo loader tunable"); ```
Note that the implementation has a limitation. It behaves the same way as that of non-vnet loader tunables. That is, after the kernel or modules being initialized, any changes (e.g. via kenv) to kernel environment variable will not affect the corresponding vnet variable of subsequently created VNETs. To overcome it, we can use TUNABLE_XXX_FETCH to fetch the kernel environment variable into those vnet variables during vnet constructing.
This change will fix the following SYSCTLs those belong to VNETs and have CTLFLAG_TUN flag: ``` net.add_addr_allfibs net.bpf.optimize_writers net.inet.tcp.fastopen.ccache_buckets net.link.bridge.inherit_mac net.link.bridge.ipfw_arp net.link.bridge.log_stp net.link.bridge.pfil_bridge net.link.bridge.pfil_local_phys net.link.bridge.pfil_member net.link.bridge.pfil_onlyip net.link.lagg.default_use_flowid net.link.lagg.default_use_numa net.link.lagg.default_flowid_shift net.link.lagg.lacp.debug net.link.lagg.lacp.default_strict_mode ```
Although the following vnet SYSCTLs have CTLFLAG_TUN flag, theirs values are re-fetched via TUNABLE_XXX_FETCH, thus are not affected by this change. ``` net.inet.ip.reass_hashsize net.inet.tcp.hostcache.cachelimit net.inet.tcp.hostcache.hashsize net.inet.tcp.hostcache.bucketlimit net.inet.tcp.syncache.bucketlimit net.inet.tcp.syncache.cachelimit net.inet.tcp.syncache.hashsize net.key.spdcache.maxentries net.key.spdcache.threshold ```
In memoriam: hselasky Discussed with: hselasky, glebius Fixes: 3da1cf1e88f8 Extend the meaning of the CTLFLAG_TUN flag ... MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D39638
show more ...
|
#
685dc743 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
Revision tags: release/13.2.0 |
|
#
ba8cc6d7 |
| 12-Mar-2023 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: use __enum_uint8 for vtype and vstate
This whacks hackery around only reading v_type once.
Bump __FreeBSD_version to 1400093
|
#
53d0b9e4 |
| 31-May-2023 |
Jessica Clarke <jrtc27@FreeBSD.org> |
pmc: Provide full path to modules from kernel linker
This unifies the user object and kernel module paths in libpmcstat, allows modules loaded from non-standard locations (e.g. from a user's home di
pmc: Provide full path to modules from kernel linker
This unifies the user object and kernel module paths in libpmcstat, allows modules loaded from non-standard locations (e.g. from a user's home directory when testing) to be found and, since buffer is what all the warnings here use (they were never updated when buffer_modules were added to pick based on where the file was found) has the side-effect of ensuring the messages are correct.
This includes obsoleting the now-superfluous -k option in pmcstat.
This change breaks the hwpmc ABI and will be followed by a bump to the pmc major version.
Reviewed by: jhb, jkoshy, mhorne Differential Revision: https://reviews.freebsd.org/D40048
show more ...
|
#
4d846d26 |
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
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
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
show more ...
|
Revision tags: release/12.4.0 |
|
#
c84c5e00 |
| 18-Jul-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
ddb: annotate some commands with DB_CMD_MEMSAFE
This is not completely exhaustive, but covers a large majority of commands in the tree.
Reviewed by: markj Sponsored by: Juniper Networks, Inc. Spons
ddb: annotate some commands with DB_CMD_MEMSAFE
This is not completely exhaustive, but covers a large majority of commands in the tree.
Reviewed by: markj Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35583
show more ...
|
#
31d1b816 |
| 28-May-2022 |
Dmitry Chagin <dchagin@FreeBSD.org> |
sysent: Get rid of bogus sys/sysent.h include.
Where appropriate hide sysent.h under proper condition.
MFC after: 2 weeks
|
Revision tags: release/13.1.0 |
|
#
bb92cd7b |
| 24-Mar-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd)
|
#
5a8fceb3 |
| 22-Feb-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
boottrace: trace annotations for startup and shutdown
Add trace events for execution of SYSINITs (both static and dynamically loaded), and to the various steps in the shutdown/panic/reboot paths.
S
boottrace: trace annotations for startup and shutdown
Add trace events for execution of SYSINITs (both static and dynamically loaded), and to the various steps in the shutdown/panic/reboot paths.
Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. X-NetApp-PR: #23 Differential Revision: https://reviews.freebsd.org/D30187
show more ...
|
#
877eea42 |
| 20-Feb-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
kern_linker.c: sort includes
This is preferred by style(9). Do this ahead of adding another include.
Reviewed by: imp, kevans MFC after: 3 days Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
kern_linker.c: sort includes
This is preferred by style(9). Do this ahead of adding another include.
Reviewed by: imp, kevans MFC after: 3 days Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D30185
show more ...
|
Revision tags: release/12.3.0 |
|
#
95c20faf |
| 07-Nov-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
kernel linker: do not read debug symbol tables for non-debug symbols
In particular, this prevents resolving locals from other files. To access debug symbol tables, add LINKER_LOOKUP_DEBUG_SYMBOL and
kernel linker: do not read debug symbol tables for non-debug symbols
In particular, this prevents resolving locals from other files. To access debug symbol tables, add LINKER_LOOKUP_DEBUG_SYMBOL and LINKER_DEBUG_SYMBOL_VALUES kobj methods, which are allowed to use any types of present symbols in all tables.
PR: 207898 Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32878
show more ...
|
#
72f66626 |
| 16-Nov-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
linker_debug_symbol_values(): use proper linker interface to get debug values
Reported by: markj Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revisi
linker_debug_symbol_values(): use proper linker interface to get debug values
Reported by: markj Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32878
show more ...
|
#
4f924a78 |
| 12-Nov-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
linker_kldload_busy(): allow recursion
Some drivers recursively loads modules by explicit calls to kldload during initialization, which might occur during kldload.
PR: 259748 Reported and tested by
linker_kldload_busy(): allow recursion
Some drivers recursively loads modules by explicit calls to kldload during initialization, which might occur during kldload.
PR: 259748 Reported and tested by: thj Reviewed by: markj Sponsored by: Nvidia networking MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32972
show more ...
|
#
7e1d3eef |
| 25-Nov-2021 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: remove the unused thread argument from NDINIT*
See b4a58fbf640409a1 ("vfs: remove cn_thread")
Bump __FreeBSD_version to 1400043.
|
#
9e575fad |
| 29-Jul-2021 |
Mark Johnston <markj@FreeBSD.org> |
link_elf_obj: Invoke fini callbacks
This is required for KASAN: when a module is unloaded, poisoned regions (e.g., pad areas between global variables) are left as such, so if they are reused as KLDs
link_elf_obj: Invoke fini callbacks
This is required for KASAN: when a module is unloaded, poisoned regions (e.g., pad areas between global variables) are left as such, so if they are reused as KLDs are loaded, false positives can arise.
Reported by: pho, Jenkins Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31339
show more ...
|
#
e266a0f7 |
| 20-May-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
kern linker: do not allow more than one kldload and kldunload syscalls simultaneously
kld_sx is dropped e.g. for executing sysinits, which allows user to initiate kldunload while module is not yet f
kern linker: do not allow more than one kldload and kldunload syscalls simultaneously
kld_sx is dropped e.g. for executing sysinits, which allows user to initiate kldunload while module is not yet fully initialized.
Reviewed by: markj Differential revision: https://reviews.freebsd.org/D30456 Sponsored by: The FreeBSD Foundation MFC after: 1 week
show more ...
|
#
f1f98706 |
| 18-Apr-2021 |
Warner Losh <imp@FreeBSD.org> |
Minor style cleanup
We prefer 'while (0)' to 'while(0)' according to grep and stlye(9)'s space after keyword rule. Remove a few stragglers of the latter. Many of these usages were inconsistent withi
Minor style cleanup
We prefer 'while (0)' to 'while(0)' according to grep and stlye(9)'s space after keyword rule. Remove a few stragglers of the latter. Many of these usages were inconsistent within the file.
MFC After: 3 days Sponsored by: Netflix
show more ...
|