| #
bdb56184 |
| 16-Aug-2026 |
Devin Teske <dteske@FreeBSD.org> |
linux: implement pkey_alloc, pkey_free and pkey_mprotect
Bridge the Linux memory protection key syscalls to FreeBSD's native MPK support instead of returning ENOSYS. Modern Linux software probes the
linux: implement pkey_alloc, pkey_free and pkey_mprotect
Bridge the Linux memory protection key syscalls to FreeBSD's native MPK support instead of returning ENOSYS. Modern Linux software probes these at startup: Chromium-based browsers (found via www/linux-brave) use protection keys for V8's heap and JIT sandboxing, and glibc >= 2.27 exposes the full API.
pkey_alloc() allocates from a per-process bitmap kept in the process emuldata (key 0 implicitly allocated, matching Linux's mm_pkey_allocation_map; ENOSPC once keys 1..15 are exhausted or when PKU is absent, as Linux returns on such hardware) and applies the requested initial access rights to the calling thread's PKRU, located in the XSAVE area via xsave_area_offset(). pkey_free() is bookkeeping only: as on Linux, freeing neither untags pages nor updates PKRU. pkey_mprotect() performs the protection change and tags the range through amd64_pkru_update(), factored out of sysarch(2)'s AMD64_SET_PKRU/AMD64_CLEAR_PKRU implementation so that both share the same argument checking and map read lock synchronization with a parallel pmap_vmspace_copy() on fork; tags die with the mapping, matching Linux VMA semantics. A pkey of -1 degrades to plain mprotect.
The allocation map is inherited on fork and reset on exec. At exec the Linux sysvecs initialize PKRU to 0x55555554, Linux's init_pkru default (access disabled for keys 1..15), so memory tagged with a not yet allocated key is inaccessible to threads that were never granted rights -- the property V8's thread isolation relies on. Setting PKRU at exec initializes the user FPU state slightly earlier than the lazy first-use path; the state would be initialized moments later in rtld/libc startup regardless. Protection key faults already deliver SEGV_PKUERR through the existing siginfo translation.
The common code carries no architecture ifdefs. Machine-dependent state lives in struct linux_pemuldata_md, embedded in the process emuldata in the manner of struct mdthread, and common code calls per-arch lifecycle hooks (linux_pemuldata_init_md/_exec_md) and pkey back ends after performing the parameter validation Linux applies regardless of hardware support. On amd64 the implementation lives in sys/amd64/linux/linux_pkru.c, compiled into linux_common and serving both the 64-bit and 32-bit Linux ABIs. Elsewhere (arm64, i386) linux_emul_md.c provides stubs returning what Linux returns on hardware without protection keys (ENOSPC from pkey_alloc; pkey_mprotect with a pkey of -1 acts as plain mprotect), so applications take their normal no-PKU fallback instead of the ENOSYS path.
PR: 297427 MFC after: 1 month Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D58782
show more ...
|
|
Revision tags: release/15.1.0-p2, release/15.0.0-p12, release/14.4.0-p8, release/15.0.0-p11, release/14.3.0-p16, release/14.4.0-p7, release/15.1.0-p1, release/15.1.0, release/15.0.0-p10, release/14.4.0-p6, release/14.3.0-p15, release/14.4.0-p5, release/14.3.0-p14, release/15.0.0-p9, release/14.4.0-p4, release/14.3.0-p13, release/13.5.0-p14, release/15.0.0-p8, release/14.4.0-p3, release/14.3.0-p12, release/13.5.0-p13, release/15.0.0-p7, release/13.5.0-p12, release/14.3.0-p11, release/14.4.0-p2, release/15.0.0-p6, release/13.5.0-p11, release/14.3.0-p10, release/14.4.0-p1, release/15.0.0-p5, release/14.4.0, release/13.5.0-p10, release/14.3.0-p9, release/15.0.0-p4, release/15.0.0-p3, release/13.5.0-p9, release/15.0.0-p2, release/14.3.0-p8, release/15.0.0-p1, release/13.5.0-p8, release/14.3.0-p7 |
|
| #
3e2093de |
| 28-Nov-2025 |
Ed Maste <emaste@FreeBSD.org> |
linux: Add required symbol to EXPORT_SYMS list
PR: 291270
|
| #
fbf05d21 |
| 08-Dec-2025 |
Gleb Smirnoff <glebius@FreeBSD.org> |
linux: separate all ifnet(9) related code into linux_ifnet.c
Remove linux_use_real_ifname(). It is no longer used outside of the file since 3ab3c9c29cf0. There is no functional change.
Reviewed b
linux: separate all ifnet(9) related code into linux_ifnet.c
Remove linux_use_real_ifname(). It is no longer used outside of the file since 3ab3c9c29cf0. There is no functional change.
Reviewed by: melifaro, dchagin Differential Revision: https://reviews.freebsd.org/D54076
show more ...
|
|
Revision tags: release/15.0.0, release/14.3.0-p6, release/13.5.0-p7, release/13.5.0-p6, release/14.3.0-p5, release/13.5.0-p5, release/14.2.0-p7, release/14.3.0-p4, release/14.3.0-p3, release/14.2.0-p6, release/13.5.0-p4, release/13.5.0-p3, release/14.2.0-p5, release/14.3.0-p2, release/14.3.0-p1, release/14.2.0-p4, release/13.5.0-p2, 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 |
|
| #
e9ac4169 |
| 15-Jul-2024 |
Warner Losh <imp@FreeBSD.org> |
Remove residual blank line at start of Makefile
This is a residual of the $FreeBSD$ removal.
MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
|
|
Revision tags: release/14.1.0, release/13.3.0, release/14.0.0 |
|
| #
ab393e95 |
| 12-Oct-2023 |
Kristof Provost <kp@FreeBSD.org> |
netlink: move NETLINK define to opt_global.h
Move the NETLINK define into opt_global.h so we can rely on it being set correctly, without having to remember to include opt_netlink.h. This ensures tha
netlink: move NETLINK define to opt_global.h
Move the NETLINK define into opt_global.h so we can rely on it being set correctly, without having to remember to include opt_netlink.h. This ensures that the NETLINK define is correctly set. If not we may end up with unloadable modules, due to missing symbols (such as nlmsg_get_group_writer).
PR: 274306 Reviewed by: imp, markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D42179
show more ...
|
| #
031beb4e |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
|
| #
c4299cec |
| 29-May-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Make linux_emul_path private
There is no need to refer to linux_emul_path from outside anymore.
MFC after: 2 month
|
|
Revision tags: release/13.2.0 |
|
| #
96056265 |
| 31-Mar-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Fix opt_netlink.h inclusion
Add opt_netlink.h to the linux_common module, on i386, where we don't uses linux_common module, move opt_netlink.h inclusion under i386 condition.
MFC after:
linux(4): Fix opt_netlink.h inclusion
Add opt_netlink.h to the linux_common module, on i386, where we don't uses linux_common module, move opt_netlink.h inclusion under i386 condition.
MFC after: 2 weeks
show more ...
|
| #
c19fc5cd |
| 28-Jan-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux_common: Fixup .PATH.
Since we have arm64, and awaiting ppc64 Linuxulator, do not include x86 specific path to the module build for non x86 architectures.
MFC after: 1 week
|
|
Revision tags: release/12.4.0 |
|
| #
010175a7 |
| 29-Oct-2022 |
Warner Losh <imp@FreeBSD.org> |
modules: Add missing opt_*.h files for stand-alone compile
Standalone compile that we at least create these opt_*.h files.
Sponsored by: Netflix
|
| #
7c40e2d5 |
| 26-Aug-2022 |
Alexander V. Chernikov <melifaro@FreeBSD.org> |
linuxolator: add netlink support
Add the glue code to support netlink in Linuxolator. linux_common(4) now depends on netlink(4).
All netlink protocol constants are consistent with the Linux version
linuxolator: add netlink support
Add the glue code to support netlink in Linuxolator. linux_common(4) now depends on netlink(4).
All netlink protocol constants are consistent with the Linux version. However, certain OS-specific constants such as AF_INET6, interface flags or default routing table id, are different between FreeBSD and Linux. Thus, it may be needed to rewrite some message parts or even rewrite the whole message, adding or removing some TLVs. The core netlink implementation code provides efficient rewriting callbacks which Linuxolator now uses.
Reviewed by: dchagin Differential Revision: https://reviews.freebsd.org/D36361 MFC after: 2 months
show more ...
|
| #
2b378d59 |
| 23-May-2022 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4); Move vdso_selector_x86.c to the linux_common module
MFC after: 2 weeks
|
| #
2434137f |
| 23-May-2022 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Deduplicate translate_traps()
As translate_traps() is common for x86 Linuxulators, move it under x86/linux.
MFC after: 2 weeks
|
|
Revision tags: release/13.1.0 |
|
| #
1f70a85b |
| 08-Jan-2022 |
Alexander V. Chernikov <melifaro@FreeBSD.org> |
linux: add sysctl to pass untranslated interface names
Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33792
|
|
Revision tags: release/12.3.0 |
|
| #
5bb3134a |
| 07-Nov-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Fix some modules to export more used symbols
and remove non-present symbols that are now reported by kmod_syms.awk.
Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differ
Fix some modules to export more used symbols
and remove non-present symbols that are now reported by kmod_syms.awk.
Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32878
show more ...
|
|
Revision tags: release/13.0.0 |
|
| #
e9b13c66 |
| 05-Nov-2020 |
Conrad Meyer <cem@FreeBSD.org> |
linux(4): Deduplicate unimpl/dummy syscall handlers
No functional change.
Reviewed by: emaste, trasz Differential Revision: https://reviews.freebsd.org/D27099
|
| #
7abf30d3 |
| 03-Nov-2020 |
Edward Tomasz Napierala <trasz@FreeBSD.org> |
Make linux_errtbl[] static.
MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27004
|
|
Revision tags: release/12.2.0, release/11.4.0, release/12.1.0, release/11.3.0 |
|
| #
0269ae4c |
| 06-Jun-2019 |
Alan Somers <asomers@FreeBSD.org> |
MFHead @348740
Sponsored by: The FreeBSD Foundation
|
| #
6e4cf32e |
| 13-May-2019 |
Dmitry Chagin <dchagin@FreeBSD.org> |
Add warning to the Linuxulator makefiles that building it outside of a kernel does not make sence.
PR: 222861 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20179
|
| #
c5156c77 |
| 13-May-2019 |
Dmitry Chagin <dchagin@FreeBSD.org> |
Linuxulator depends on a fundamental kernel settings such as SMP. Many of them listed in opt_global.h which is not generated while building modules outside of a kernel and such modules never match re
Linuxulator depends on a fundamental kernel settings such as SMP. Many of them listed in opt_global.h which is not generated while building modules outside of a kernel and such modules never match real cofigured kernel.
So, we should prevent our users from building obviously defective modules.
Therefore, remove the root cause of the building of modules outside of a kernel - the possibility of building modules with DEBUG or KTR flags. And remove all of DEBUG printfs as it is incomplete and in threaded programms not informative, also a half of system call does not have DEBUG printf. For debuging Linux programms we have dtrace, ktr and ktrace ability.
PR: 222861 Reviewed by: trasz MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20178
show more ...
|
| #
d5368bf3 |
| 13-May-2019 |
Dmitry Chagin <dchagin@FreeBSD.org> |
Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions alter the userspace sockaddr to convert the format between linux and BSD versions. That's the minimum 3 of copyin/copyout operations
Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions alter the userspace sockaddr to convert the format between linux and BSD versions. That's the minimum 3 of copyin/copyout operations for one syscall.
Also some syscall uses linux_sa_put() and linux_getsockaddr() when load sockaddr to userspace or from userspace accordingly.
To avoid this chaos, especially converting sockaddr in the userspace, rewrite these 4 functions to convert sockaddr only in kernel and leave only 2 of this functions.
Also in order to reduce duplication between MD parts of the Linuxulator put struct sockaddr conversion functions that are MI out into linux_common module.
PR: 232920 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20157
show more ...
|
|
Revision tags: release/12.0.0, release/11.2.0 |
|
| #
6469bdcd |
| 06-Apr-2018 |
Brooks Davis <brooks@FreeBSD.org> |
Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is close
Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options.
Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures.
Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files.
Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941
show more ...
|
| #
1ac2776b |
| 22-Mar-2018 |
Ed Maste <emaste@FreeBSD.org> |
Share Linux errno table with libsysdecode
Requested by: jhb Reviewed by: jhb Sponsored by: Turing Robotic Industries Inc.
|
| #
6e481f83 |
| 16-Mar-2018 |
Ed Maste <emaste@FreeBSD.org> |
Share a single bsd-linux errno table across MD consumers
Three copies of the linuxulator linux_sysvec.c contained identical BSD to Linux errno translation tables, and future work to support other ar
Share a single bsd-linux errno table across MD consumers
Three copies of the linuxulator linux_sysvec.c contained identical BSD to Linux errno translation tables, and future work to support other architectures will also use the same table. Move the table to a common file to be used by all. Make it 'const int' to place it in .rodata.
(Some existing Linux architectures use MD errno values, but x86 and Arm share the generic set.)
This change should introduce no functional change; a followup will add missing errno values.
MFC after: 3 weeks Sponsored by: Turing Robotic Industries Inc. Differential Revision: https://reviews.freebsd.org/D14665
show more ...
|
|
Revision tags: release/10.4.0, release/11.1.0 |
|
| #
193d9e76 |
| 04-Mar-2017 |
Enji Cooper <ngie@FreeBSD.org> |
sys/modules: normalize .CURDIR-relative paths to SRCTOP
This simplifies make output/logic
Tested with: `cd sys/modules; make ALL_MODULES=` on amd64 MFC after: 1 month Sponsored by: Dell EMC Isilon
|