#
79dea0c8 |
| 02-Jul-2025 |
Mark Johnston <markj@FreeBSD.org> |
linker: Fix the ifunc symbol value calculation for ET_REL files
Reported by: cy Fixes: aefae931820f ("linker: Improve handling of ifuncs when fetching symbol metadata")
|
#
aefae931 |
| 02-Jul-2025 |
Mark Johnston <markj@FreeBSD.org> |
linker: Improve handling of ifuncs when fetching symbol metadata
When looking up symbol values, we map ifunc symbols to the value returned by the resolver. However, the returned symbol size is stil
linker: Improve handling of ifuncs when fetching symbol metadata
When looking up symbol values, we map ifunc symbols to the value returned by the resolver. However, the returned symbol size is still that of the resolver. Be consistent and provide the size of the implementation symbol as well.
This fixes an inconsistency in dtrace's FBT provider, which enumerates all function symbols and disassembles their values, using the symbol size as the bound for the disassembly loop. In particular, for ifuncs, we were not creating return probes.
Reviewed by: kib MFC after: 2 weeks Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D50683
show more ...
|
Revision tags: release/14.3.0, release/13.4.0-p5, release/13.5.0-p1, release/14.2.0-p3, release/13.5.0, release/14.2.0-p2, release/14.1.0-p8, release/13.4.0-p4, release/14.1.0-p7, release/14.2.0-p1, release/13.4.0-p3, release/14.2.0, release/13.4.0 |
|
#
4d213c59 |
| 24-Aug-2024 |
Ahmad Khalifa <ahmadkhalifa570@gmail.com> |
sys: use globals for the ELF kernel and module type strings
Initialize the globals with macros so we can use the same values in the loader.
Also remove unnecessary "elfN module" checks.
Reviewed b
sys: use globals for the ELF kernel and module type strings
Initialize the globals with macros so we can use the same values in the loader.
Also remove unnecessary "elfN module" checks.
Reviewed by: imp, kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1394
show more ...
|
Revision tags: release/14.1.0 |
|
#
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 ...
|
#
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 |
|
#
eccde5f4 |
| 21-Feb-2024 |
Warner Losh <imp@FreeBSD.org> |
sys/kern: Remove a few sys/cdefs.h around some elf things
These sys/cdefs.h are no longer needed. Remove them in advance of other work in this area.
Sponsored by: Netflix
|
Revision tags: release/14.0.0 |
|
#
cf7974fd |
| 21-Sep-2023 |
Zhenlei Huang <zlei@FreeBSD.org> |
sysctl: Update 'master' copy of vnet SYSCTLs on kernel environment variables change
Complete phase three of 3da1cf1e88f8.
With commit 110113bc086f, vnet sysctl variables can be loader tunable but t
sysctl: Update 'master' copy of vnet SYSCTLs on kernel environment variables change
Complete phase three of 3da1cf1e88f8.
With commit 110113bc086f, vnet sysctl variables can be loader tunable but the feature is limited. When the kernel modules have been initialized, any changes (e.g. via kenv) to kernel environment variable will not affect subsequently created VNETs.
This change relexes the limitation by listening on kernel environment variable's set / unset events, and then update the 'master' copy of vnet SYSCTL or restore it to its initial value.
With this change, TUNABLE_XXX_FETCH can be greately eliminated for vnet loader tunables.
Reviewed by: glebius Fixes: 110113bc086f sysctl(9): Enable vnet sysctl variables to be loader tunable MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D41825
show more ...
|
#
205821a7 |
| 09-Sep-2023 |
Zhenlei Huang <zlei@FreeBSD.org> |
kernel linker: Eliminate unneeded vnet propagation
The module preload happens before vnet0 creation, at this moment the vnet list is empty thus invoking vnet_data_copy() during preload is a noop.
W
kernel linker: Eliminate unneeded vnet propagation
The module preload happens before vnet0 creation, at this moment the vnet list is empty thus invoking vnet_data_copy() during preload is a noop.
With recent change 110113bc086f, for dynamic module load, aka via kldload, linker will do vnet propagation right after registering sysctls which happens after module load, then previous propagation (during module load) is redundant.
No functional change intended.
MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D39852
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/
|
#
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/13.2.0, release/12.4.0, release/13.1.0 |
|
#
bb92cd7b |
| 24-Mar-2022 |
Mateusz Guzik <mjg@FreeBSD.org> |
vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd)
|
Revision tags: release/12.3.0 |
|
#
ecd8245e |
| 07-Nov-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Kernel linkers: add emergency sysctl to restore old behavior
allowing linking to static symbols from other files. Default the new settings to true, delaying the change of the kernel linker behavior
Kernel linkers: add emergency sysctl to restore old behavior
allowing linking to static symbols from other files. Default the new settings to true, delaying the change of the kernel linker behavior for other day.
Suggested by: emaste PR: 207898 Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32878
show more ...
|
#
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 ...
|
#
c37c6f99 |
| 08-Dec-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Style
Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32878
|
#
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.
|
#
b11e6fd7 |
| 25-Nov-2021 |
Mark Johnston <markj@FreeBSD.org> |
link_elf_obj: Process global ifunc relocs after other global relocs
This is needed to ensure that resolvers that reference global symbols return correct results.
Reviewed by: kib MFC after: 1 week
link_elf_obj: Process global ifunc relocs after other global relocs
This is needed to ensure that resolvers that reference global symbols return correct results.
Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33120
show more ...
|
#
a7e4eb14 |
| 07-Nov-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Kernel linkers: some style
Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D32878
|
#
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 ...
|
Revision tags: release/13.0.0 |
|
#
4aa157dd |
| 16-Mar-2021 |
Mark Johnston <markjdb@gmail.com> |
link_elf_obj: Add a case missing from 5e6989ba4f26
Fixes: 5e6989ba4f26 MFC after: 3 days Sponsored by: The FreeBSD Foundation
|
#
5e6989ba |
| 04-Mar-2021 |
Mark Johnston <markj@FreeBSD.org> |
link_elf_obj: Handle init_array sections in KLDs
Reuse existing handling for .ctors, print a warning if multiple constructor sections are present. Destructors are not handled as of yet.
This is r
link_elf_obj: Handle init_array sections in KLDs
Reuse existing handling for .ctors, print a warning if multiple constructor sections are present. Destructors are not handled as of yet.
This is required for KASAN.
Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29049
show more ...
|
#
0659df6f |
| 12-Jan-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
vm_map_protect: allow to set prot and max_prot in one go.
This prevents a situation where other thread modifies map entries permissions between setting max_prot, then relocking, then setting prot, c
vm_map_protect: allow to set prot and max_prot in one go.
This prevents a situation where other thread modifies map entries permissions between setting max_prot, then relocking, then setting prot, confusing the operation outcome. E.g. you can get an error that is not possible if operation is performed atomic.
Also enable setting rwx for max_prot even if map does not allow to set effective rwx protection.
Reviewed by: brooks, markj (previous version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28117
show more ...
|
Revision tags: release/12.2.0 |
|
#
d80126a6 |
| 19-Oct-2020 |
Mark Johnston <markj@FreeBSD.org> |
link_elf_obj: Colour VM objects
This will cause the VM to back sufficiently large .text sections, such as those in zfs.ko or amdgpu.ko on amd64, with superpage mappings when possible.
Reviewed by:
link_elf_obj: Colour VM objects
This will cause the VM to back sufficiently large .text sections, such as those in zfs.ko or amdgpu.ko on amd64, with superpage mappings when possible.
Reviewed by: alc, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26802
show more ...
|
#
44c705cf |
| 08-Oct-2020 |
Mitchell Horne <mhorne@FreeBSD.org> |
Handle kmod local relocation failures gracefully
It is possible for elf_reloc_local() to fail in the unlikely case of an unsupported relocation type. If this occurs, do not continue to process the f
Handle kmod local relocation failures gracefully
It is possible for elf_reloc_local() to fail in the unlikely case of an unsupported relocation type. If this occurs, do not continue to process the file.
Reviewed by: kib, markj (earlier version) MFC after: 1 week Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D26701
show more ...
|
#
fbf2a778 |
| 09-Sep-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Convert allocations of the phys pager to vm_pager_allocate().
Future changes would require additional initialization of OBJT_PHYS objects, and vm_object_allocate() is not suitable for it.
Reviewed
Convert allocations of the phys pager to vm_pager_allocate().
Future changes would require additional initialization of OBJT_PHYS objects, and vm_object_allocate() is not suitable for it.
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24652
show more ...
|