Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
0a57592
runtime: gate loader paths for PartitionAlloc + MPK tagging
oinoom Oct 10, 2025
88b9b9a
loader: add telemetry for libdl wrappers and consolidate docs
oinoom Oct 13, 2025
844f6b7
runtime: auto-retag system DSOs to loader compartment
oinoom Oct 13, 2025
6fd2060
runtime: drop loader gate before user constructors
oinoom Oct 13, 2025
9c73b03
runtime: preserve errno for loader mmap failures
oinoom Oct 13, 2025
e77f964
runtime: gate loader mmap wrappers on x86_64
oinoom Oct 14, 2025
24ccf1b
runtime: move loader telemetry increments out of gate
oinoom Oct 14, 2025
67d4699
tests: add mmap wrapper regression test for file-backed mappings
oinoom Oct 14, 2025
986aaf4
runtime: respect registered compartments in loader retag
oinoom Oct 15, 2025
080e604
cleanup
oinoom Oct 17, 2025
d015166
improvements
oinoom Oct 20, 2025
403b060
runtime: add bootstrap loader shim and PKRU interceptors
oinoom Oct 20, 2025
a6bb332
loader: remove pkru cache scaffolding
oinoom Oct 22, 2025
964702d
refactor: eliminate mmap/mmap64 wrapper duplication
oinoom Oct 22, 2025
9a4ab8e
refactor: make PKRU gates unconditional for loader compartmentalization
oinoom Oct 22, 2025
87c8af4
runtime: harden loader PKRU gating
oinoom Oct 22, 2025
0f2d09a
cleanup
oinoom Oct 24, 2025
387cc85
docs + cleanup
oinoom Oct 27, 2025
a221426
docs + cleanup
oinoom Oct 27, 2025
67bc378
docs + cleanup
oinoom Oct 27, 2025
fa0114f
docs + cleanup
oinoom Oct 27, 2025
fbc8334
docs + cleanup
oinoom Oct 27, 2025
9f657ff
runtime/tools: share libc compartment id
oinoom Oct 27, 2025
90d9c86
runtime: remove ia2_callgate_exit declaration (assembly-only)
oinoom Oct 27, 2025
a6c030c
runtime: inline ia2_callgate_{enter,exit} into __wrap___cxa_finalize
oinoom Oct 27, 2025
b5c4f27
runtime: remove unnecessary alignment directive from asm block
oinoom Oct 27, 2025
16d43db
runtime: use IA2_STR macro from ia2_internal.h instead of redefining
oinoom Oct 27, 2025
a01dd83
runtime: consolidate exit_callgates_x86_64.c into exit_callgates.c
oinoom Oct 27, 2025
b21b8fd
docs + cleanup
oinoom Oct 27, 2025
e9d74ca
simplify IA2_EXIT_PKRU
oinoom Oct 27, 2025
3c33c6e
runtime: fix exit() wrapper PKRU to allow ld.so access
oinoom Oct 28, 2025
2cae9fe
tests: add exit callgate verification tests
oinoom Oct 28, 2025
306c1fd
feature flag
oinoom Oct 31, 2025
72a91b6
fix configuration
oinoom Nov 5, 2025
e743f01
Merge branch 'fix.so' into fix.loader.dynamic
oinoom Nov 5, 2025
6e692d1
fix macro usage
oinoom Nov 6, 2025
b7105fa
remove script
oinoom Nov 10, 2025
0b40e86
Merge branch 'fix.so' into fix.loader.dynamic
oinoom Nov 18, 2025
69efd21
commit missing header
oinoom Nov 18, 2025
c3f60ea
partition-alloc: guard telemetry when disabled
oinoom Nov 18, 2025
b38e374
runtime: expose pkru helpers always
oinoom Nov 18, 2025
143ecd3
runtime: gate loader shims on libc flag
oinoom Nov 18, 2025
efb1a35
runtime: add loader gate stub
oinoom Nov 18, 2025
6ff3d81
partition-alloc: drop loader counter dependency
oinoom Nov 18, 2025
c9002d9
test script
oinoom Nov 19, 2025
03d2ddc
Merge pull request #642 from immunant/fix.so
oinoom Dec 3, 2025
4c85415
Merge branch 'main' into fix.loader.dynamic
oinoom Dec 3, 2025
d238b4e
runtime: restore loader gate sources and wrap flags
oinoom Dec 3, 2025
e3f8712
runtime: gate loader wrappers behind libc flag
oinoom Dec 3, 2025
38a06d3
cmake: disable libc compartment flag on aarch64
oinoom Dec 3, 2025
569327b
aarch64: hard-disable libc compartment runtime paths
oinoom Dec 3, 2025
c1633fe
cmake: force IA2_LIBC_COMPARTMENT=OFF in aarch64 toolchain
oinoom Dec 3, 2025
a83004e
cmake: block libc compartment flag for all aarch64 targets
oinoom Dec 3, 2025
8658d52
libia2: only build loader wrappers when libc compartment is on
oinoom Dec 3, 2025
192cca9
runtime: stub loader gate on aarch64
oinoom Dec 3, 2025
97ef42c
runtime: guard pkru debug log on arm
oinoom Dec 3, 2025
63718c1
runtime: keep pkru gates disabled on arm and export stub counters
oinoom Dec 3, 2025
bd70c01
ci: add libc compartment coverage row
oinoom Dec 4, 2025
124360a
ci: label pkru matrix rows with libc-on/off
oinoom Dec 4, 2025
5ec0dbe
ci: document matrix job label with libc flag
oinoom Dec 4, 2025
c56a27b
tests: temporarily drop mbstowcs libc case from libc-check
oinoom Dec 4, 2025
a53c2c7
ci: run libc job via dl_debug runner and prune target list
oinoom Dec 4, 2025
7ed1bd7
tests: align libc compartment ctests
oinoom Dec 4, 2025
a608b22
tests: drop bootstrap shim ctest entry
oinoom Dec 4, 2025
8995231
tests: include exit_callgate_standalone in libc compartment suite
oinoom Dec 4, 2025
4b64cb1
ci: filter libc compartment tests via ctest label
oinoom Dec 4, 2025
c665a56
tests: disable aarch64 pthread_join flake in terminating_threads
oinoom Dec 4, 2025
082070b
ci/tests: update libc compartment comments
oinoom Dec 4, 2025
4e5cf9c
ci: clarify pkru matrix job label
oinoom Dec 4, 2025
7521754
ci: simplify pkru job name comment
oinoom Dec 4, 2025
4ea96b4
tests: add libc-only mode for libc compartment suites
oinoom Dec 5, 2025
e0e2c6f
tests: make libc compartment builds libc-only
oinoom Dec 5, 2025
c400734
Merge pull request #648 from immunant/feat.test.libc
oinoom Dec 5, 2025
bac4f31
Merge branch 'main' into fix.loader.dynamic
oinoom Dec 5, 2025
edf0d28
add new tests to ci
oinoom Dec 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ on:

jobs:
test-on-pkru-enabled-host:
# Preserve the stable job key for downstream users, but surface matrix
# details (including libc-compartment on/off) in the Actions UI.
name: >-
tests (pkru) [${{ matrix.build-type }}, ${{ matrix.c_compiler }},
${{ matrix.linker }},
${{ matrix.ia2-libc == 'IA2_LIBC_COMPARTMENT=ON' && 'libc-on' || 'libc-off' }},
${{ matrix.ia2-tracer }}, ${{ matrix.ia2-debug }}]
runs-on: self-hosted
timeout-minutes: 5
continue-on-error: ${{ matrix.ia2-tracer == 'ON' }}
Expand All @@ -22,6 +29,16 @@ jobs:
ia2-tracer: [IA2_TRACER=ON, IA2_TRACER=OFF]
ia2-verbose: [IA2_VERBOSE=ON]
ia2-debug-memory: [IA2_DEBUG_MEMORY=ON]
ia2-libc: [IA2_LIBC_COMPARTMENT=OFF]
include:
- build-type: Release
c_compiler: clang
linker: lld
ia2-debug: IA2_DEBUG=ON
ia2-tracer: IA2_TRACER=OFF
ia2-verbose: IA2_VERBOSE=ON
ia2-debug-memory: IA2_DEBUG_MEMORY=ON
ia2-libc: IA2_LIBC_COMPARTMENT=ON
steps:
- name: Setup Rust
# We don't use actions-rust-lang/setup-rust-toolchain because it's slower
Expand Down Expand Up @@ -50,6 +67,7 @@ jobs:
-D${{ matrix.ia2-tracer }} \
-D${{ matrix.ia2-verbose }} \
-D${{ matrix.ia2-debug-memory }} \
-D${{ matrix.ia2-libc }} \
-G Ninja
ninja
popd
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ project(IA2Phase2)
option(IA2_DEBUG "Enable debug telemetry and runtime checks" OFF)
option(IA2_LIBC_COMPARTMENT "Enable libc/ld.so compartmentalization and exit callgate support" OFF)

# The libc compartment feature is currently x86_64-only. Force it off on
# AArch64 to avoid building incomplete loader-gate support and the resulting
# runtime crashes under QEMU.
if(DEFINED LIBIA2_AARCH64 AND LIBIA2_AARCH64 AND IA2_LIBC_COMPARTMENT)
message(WARNING "IA2_LIBC_COMPARTMENT is not supported on AArch64 yet; disabling for this build.")
set(IA2_LIBC_COMPARTMENT OFF CACHE BOOL "Enable libc/ld.so compartmentalization and exit callgate support" FORCE)
endif()
# Also guard based on the configured target processor in case the toolchain
# variable is missing. Any aarch64 target should disable the feature.
if(IA2_LIBC_COMPARTMENT AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
message(WARNING "IA2_LIBC_COMPARTMENT is not supported on AArch64 targets; forcing OFF.")
set(IA2_LIBC_COMPARTMENT OFF CACHE BOOL "Enable libc/ld.so compartmentalization and exit callgate support" FORCE)
endif()

if(IA2_DEBUG)
message(STATUS "IA2: debug mode enabled")
endif()
Expand Down Expand Up @@ -51,4 +65,5 @@ ExternalProject_Add(tools
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DClang_DIR=${Clang_DIR}
-DLLVM_DIR=${LLVM_DIR}
-DIA2_LIBC_COMPARTMENT=${IA2_LIBC_COMPARTMENT}
INSTALL_COMMAND "")
4 changes: 4 additions & 0 deletions cmake/aarch64-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set(LIBIA2_AARCH64 TRUE)

# The libc/loader compartment feature is x86_64-only. Force the option off
# for all AArch64 builds to avoid pulling in incomplete loader PKRU paths.
set(IA2_LIBC_COMPARTMENT OFF CACHE BOOL "Enable libc/ld.so compartmentalization and exit callgate support" FORCE)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

Expand Down
6 changes: 4 additions & 2 deletions cmake/ia2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ function(add_ia2_compartment NAME TYPE)
endif()

target_include_directories(${NAME} PRIVATE
${CMAKE_SOURCE_DIR}/misc/test_runner/include)
${CMAKE_SOURCE_DIR}/misc/test_runner/include
${CMAKE_SOURCE_DIR}/tests/common)
target_compile_definitions(${NAME} PRIVATE
IA2_ENABLE=1
PKEY=${ARG_PKEY}
Expand Down Expand Up @@ -154,7 +155,8 @@ function(create_compile_commands NAME TYPE)
# the libraries defined by tests and instead just add the include flags for its
# assertions
target_include_directories(${COMPILE_COMMAND_TARGET} PRIVATE
${CMAKE_SOURCE_DIR}/misc/test_runner/include)
${CMAKE_SOURCE_DIR}/misc/test_runner/include
${CMAKE_SOURCE_DIR}/tests/common)
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF)
endfunction()

Expand Down
43 changes: 43 additions & 0 deletions runtime/libia2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ if(IA2_LIBC_COMPARTMENT)
list(APPEND LIBIA2_SOURCES
exit_callgates.c
)
# Loader gate functionality uses x86-specific PKRU instructions
if(NOT LIBIA2_AARCH64)
list(APPEND LIBIA2_SOURCES
loader_gate.c
dlopen_wrapper.c
mmap_wrapper.c
)
else()
# AArch64 still needs the loader gate symbols even though PKRU gates are disabled
list(APPEND LIBIA2_SOURCES
loader_gate_stub.c
)
endif()
else()
# Stub provides symbols when libc compartmentalization is disabled
list(APPEND LIBIA2_SOURCES
loader_gate_stub.c
)
endif()

add_library(libia2 ${LIBIA2_SOURCES})
Expand Down Expand Up @@ -50,6 +68,31 @@ target_link_options(libia2
"-Wl,-z,relro"
)

# Loader gate wrap flags (x86-64 only, requires PKRU instructions)
if(IA2_LIBC_COMPARTMENT AND NOT LIBIA2_AARCH64)
target_link_options(libia2
INTERFACE
# Loader entry point wrappers: interpose every libdl entry
# so the loader gate runs and keeps allocations on pkey 1
# for the threat model.
"-Wl,--wrap=dlopen"
"-Wl,--wrap=dlmopen"
"-Wl,--wrap=dlsym"
"-Wl,--wrap=dlvsym"
"-Wl,--wrap=dlclose"
"-Wl,--wrap=dladdr"
"-Wl,--wrap=dladdr1"
"-Wl,--wrap=dlinfo"
"-Wl,--wrap=dlerror"
"-Wl,--wrap=dl_iterate_phdr"

# Memory mapping wrappers (tag loader mmaps with pkey 1)
"-Wl,--wrap=mmap"
"-Wl,--wrap=mmap64"
"-Wl,--wrap=mremap"
)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CARGO_PROFILE "dev")
set(CARGO_PROFILE_DIR "debug")
Expand Down
8 changes: 8 additions & 0 deletions runtime/libia2/bootstrap_shim.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
GLIBC_PRIVATE {
global:
__libc_dlopen_mode;
__libc_dlsym;
__libc_dlclose;
local:
*;
};
Loading
Loading