| #
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
|
|
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 |
|
| #
f11c79fc |
| 17-Oct-2024 |
Warner Losh <imp@FreeBSD.org> |
Revert "modules: Add missing opt_*.h files for stand-alone compile"
This reverts commit 1a37caeb076b9d31e13c54691d7f1eeb589798bb.
I'd overlooked 06c07e1203324bfe8ab4526c82dbb750864272d5 when I upda
Revert "modules: Add missing opt_*.h files for stand-alone compile"
This reverts commit 1a37caeb076b9d31e13c54691d7f1eeb589798bb.
I'd overlooked 06c07e1203324bfe8ab4526c82dbb750864272d5 when I updated a branch I'd previously committed but not updated. My search for this in my tree before the commit was to a stale file...
Sponsored by: Netflix
show more ...
|
| #
1a37caeb |
| 12-Oct-2024 |
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
|
|
Revision tags: 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 |
|
| #
c5f906d3 |
| 12-May-2024 |
Warner Losh <imp@FreeBSD.org> |
linux: Make module standalone-buildable
Add opt_inet.h and opt_usb.h to make linux module buildable standalone.
Sponsored by: Netflix
|
|
Revision tags: release/13.3.0, release/14.0.0 |
|
| #
8e1a7e29 |
| 10-Oct-2023 |
Mark Johnston <markj@FreeBSD.org> |
sanitizers: Avoid building genassym.c and genoffset.c with sanitizers
Some, particularly KASAN, may insert redzones around global symbols, resulting in incorrect offset definitions because genassym.
sanitizers: Avoid building genassym.c and genoffset.c with sanitizers
Some, particularly KASAN, may insert redzones around global symbols, resulting in incorrect offset definitions because genassym.sh (ab)uses symbol sizes to assign semantic meaning.
(Ideally I would be able to define this pattern in one place, but I haven't found a way to define a GENSYM_CFLAGS that actually works for all of the consumers (kern.post.mk, kmod.mk, sys/conf/files*).)
MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc.
show more ...
|
| #
c6ae97c4 |
| 27-Dec-2023 |
Alex Xu (Hello71) <alex_y_xu@yahoo.ca> |
sys: ${CFLAGS:N-flto} -> ${CFLAGS:N-flto*}
For the same reason as the original https://reviews.freebsd.org/D9659: -flto=<N>, -flto=full, and -flto=thin also produce the GIMPLE/bitcode which is not s
sys: ${CFLAGS:N-flto} -> ${CFLAGS:N-flto*}
For the same reason as the original https://reviews.freebsd.org/D9659: -flto=<N>, -flto=full, and -flto=thin also produce the GIMPLE/bitcode which is not supported by genassym, so filter those out as well.
Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/898
show more ...
|
| #
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/
|
| #
22dca7ac |
| 22-Jul-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Implement xattr syscalls
Reviewed by: Differential revision: https://reviews.freebsd.org/D35544 MFC after: 1 month
|
| #
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 ...
|
| #
126df352 |
| 31-Mar-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Move inclusion of i386-specific files under common condition
|
| #
b8941935 |
| 27-Mar-2023 |
Alexander V. Chernikov <melifaro@FreeBSD.org> |
netlink: fix linux module build w/ netlink.
Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl> MFC after: 2 weeks
|
| #
825fbd08 |
| 14-Feb-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Trim unused opt_usb.h from modules Makefiles
MFC after: 2 weeks
|
| #
10d16789 |
| 12-Feb-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Get rid of the opt_compat.h include.
Since e013e369 COMPAT_LINUX, COMPAT_LINUX32 build options are removed, so include of opt_compat.h is no more needed.
MFC after: 2 weeks
|
| #
07db1f36 |
| 06-Feb-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Attach netlink on i386.
Discussed with: melifaro MFC after: 3 days
|
| #
cc1b0f7d |
| 02-Feb-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
linux(4): Add coredump support to i386.
MFC after: 1 week
|
|
Revision tags: release/12.4.0 |
|
| #
35548e48 |
| 19-Jul-2022 |
Ed Maste <emaste@FreeBSD.org> |
linux64: improve linux_support.s make rules
Previously we relied on the .s.o rule in share/mk/bsd.suffixes.mk to tell make that linux_support.o is built from linux_support.s, even though we do not u
linux64: improve linux_support.s make rules
Previously we relied on the .s.o rule in share/mk/bsd.suffixes.mk to tell make that linux_support.o is built from linux_support.s, even though we do not use the .s.o rule to assemble it.
Reviewed by: sjg MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35864
show more ...
|
| #
ccd9b49f |
| 25-Jul-2022 |
Elliott Mitchell <ehem+freebsd@m5p.com> |
sys: use .S for assembly language files that use the preprocessor
Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/609 Differential Revision: https://reviews.freebsd.org/D3
sys: use .S for assembly language files that use the preprocessor
Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/609 Differential Revision: https://reviews.freebsd.org/D35908
show more ...
|
| #
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
|
| #
f396f9b6 |
| 29-Oct-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
linux, linux64: fix module load
The previous commit added references to to the syscallnames arrays, but failed to add the relevant source files to the module build. Thus, the modules failed to load
linux, linux64: fix module load
The previous commit added references to to the syscallnames arrays, but failed to add the relevant source files to the module build. Thus, the modules failed to load due to missing symbols.
Reported by: cy Fixes: 1da65dcb1c57 ("linux: populate sv_syscallnames in each sysentvec") Sponsored by: The FreeBSD Foundation
show more ...
|
| #
33178488 |
| 29-Oct-2022 |
Mitchell Horne <mhorne@FreeBSD.org> |
linux, linux64: improve SRCS formatting
Sort the entries alphabetically, and list them with one entry per line. This makes the diffs much cleaner when adding or removing a new entry, as I will do in
linux, linux64: improve SRCS formatting
Sort the entries alphabetically, and list them with one entry per line. This makes the diffs much cleaner when adding or removing a new entry, as I will do in the next commit.
MFC after: 1 week Sponsored by: The FreeBSD Foundation
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
|