feat(sandbox): add-ons work in the sandbox on Linux and Windows, and every refusal says who asked #3093
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3093
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:feat/sandbox-addons"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add-ons now work in the sandbox on Linux and Windows. An add-on here is other people's code that runs inside the game's process: a Vulkan layer (MAKO's or lsfg-vk's frame generation, MangoHud, vkBasalt, OBS's capture), a library in
LD_PRELOAD(GameMode), or another program's DLL. Every gap still left now names itself in the log. With the sandbox on, MAKO's frame generation (the Decky plugin on Steam Decks, see #2910 and #1061) was refused its settings, its status, its model, its caches andLossless.dll, and nothing said so. The PR has four parts, the same on both systems:1. One table of add-ons (
build_core::addons::ADDONS). Each entry says:VK_IMPLICIT_LAYER_PATH, the XDG and/etcimplicit_layer.dfolders,VK_ADD_IMPLICIT_LAYER_PATH; Windows: the registry'sImplicitLayers, machine and user, andVK_ADD_IMPLICIT_LAYER_PATH), on only when itsenable_environmentholds and itsdisable_environmentisn't set; or a library inLD_PRELOAD;closed: a service it needs that the sandbox closes and can't open for it alone.Each sandbox checks places by its own rules, and logs refusals. On Windows, the plan limits how many add-on places it includes:
MangoHud's and vkBasalt's fixed rules move into the table and also get what they were missing: MangoHud's
output_folder, and vkBasalt's shader include and texture folders, effect files, data-folder config and log.2. Layers that are on can be granted access to load, known or not.
Plan::optional).3. Every refusal says who asked. Other libraries' file calls now reach the game's file layer on both systems:
open,fopen,opendir, … all 30 ofLINUX_FILE_WRAPS:hos_file_foreign,build-compile'slinux_file_exports). The executable comes first in every library's lookup, so Mesa's, the Vulkan loader's and a layer's calls arrive too. The executable's own copy reaches the C library throughdlsym(RTLD_NEXT)instead of--wrap's__real_, which would now be itself. The renderer's copy is unchanged.So the player's folders are served to those libraries as to the game. When both Landlock or the AppContainer and the builder refuse a path, it's logged once per path with the module that asked (on Windows, the first module past the C runtime's and Windows' own frames):
sandbox: refused opening <path> to <module>: a place the sandbox gives no one (an add-on's? ...). On Windows a DLL the container may not load is logged asrefused loading. The game's own modules (in the program's folder) are never logged. Each layer that is on but not in the table is logged too.4. Services the sandbox closes are the
closedfield. OBS's Linux capture uses an abstract socket that the Landlock scope closes; opening it would open every abstract socket. GameMode is in the table as needing nothing: the builder already registers the game with it.Also fixed:
tests/test_builder_files_wine.pydidn't link onmainsince #3086 (CoTaskMemAlloc: it now linksole32, as the game does).OBS on Windows isn't in the table. OBS supports capturing sandboxed (UWP) games, so whether it works confined needs checking; until then it's logged as an unknown layer. RTSS, ReShade and others: the same.
Read first:
addons.rs;addons()insandbox_linux.rsandgather.rs;hos_file_foreignandnote_foreigninhost/hos_file_linux.c;note_refusedandaskerinhost/hos_file_windows.c.Testing
Tested:
cargo test -p build-core: 215 passed.cargo test -p build-compile: passed.cargo clippy --all-targets -D warnings: clean forbuild-coreandbuild-compileon Linux, and forbuild-coreonx86_64-pc-windows-gnullvm.addons.rs: on/off as the loader decides it; MAKO on gets its places, off gets none; a layer's library as the loader finds it; an unknown layer logged and given nothing; settings-file values.sandbox_linux.rsan_add_on_on_is_given_its_own_places: a full start with MAKO's manifest, on and off, and a variable naming the home folder refused.plan.rs: an add-on's places served; a layer's DLL under ProgramData gets its own entry, never one under the game folder.tests/test_builder_files_linux.py(real Landlock and the builder's file service), plain and LTO: another library'sfopenof the game folder served; its refusal logged withlibaddon.soand the path, once per path; the program's own refusal not logged. All of its earlier checks still pass. The new checks fail onmain, which exports nothing.tests/test_sandbox_refusals_wine.py(new, Wine): another program's DLL refused, logged withaddon.dlland the path, once per path; the program's own refusal not logged. It fails onmain(nonote_refused).tests/test_builder_files_wine.py: 27 checks pass (it failed to link onmain).tests/test_sandbox_program_data_wine.py: passes.tests/test_doc_anchors.py: passes.host/hos_file_linux.c(both copies) andhost/hos_file_windows.c:-Wall -Wextra -Werrorclean.Not tested: nothing has run in the game, and no game build has linked the exported names. None of these add-ons has run confined. Opened without a game run (
--force) at the request of the person I work for.Still to test:
main, norefusedlines from Mesa or the loader in a normal session, the same fps (shared queue run on this PC; the file calls of every library now go through the layer first)mako-run, sandbox on: expectsandbox: add-on MAKO Renderer is onand generated frames (by hand, the reporters of #2910 and #1061)output_folder; vkBasalt with a ReShade effect (by hand)refusedline naming it (by hand or Test Farm)Measurements
Not measured. Every file open by another library now makes one more call (through a function pointer) and, only when refused, one request to the builder; the game's own opens are unchanged. The Linux run above checks the fps.
Risks
MANGOHUD=1,ENABLE_VKBASALT=1), for example through a manifest with noenable_environment, still gets it: a layer with noenable_environmentis on. A MangoHud run only throughLD_PRELOAD(OpenGL only) doesn't apply: the game is Vulkan.~/.cache/mako-render,~/.config/mako-render/runtime-state,~/.local/share/mako-render/captures), as well as individual pipeline cache files.Checklist
Ready for review
main; the title is a Conventional Commit.--forceon request; no add-on is installed here)mise run testpasses (any failure that also fails onmainis named). (cargo test -p build-coreand the docs check only)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
@review
Recommendation: Request changes. A symlink can turn an add-on grant into access to the whole home or game program, bypassing the sandbox's stated boundaries. Valid add-on configurations are also missed, and the claimed support has not yet been exercised in game.
The change discovers active add-ons and grants their files at startup, replacing unconditional MangoHud and vkBasalt settings grants. It could enable frame generation and add-on configuration under confinement, but currently weakens a sandbox boundary and misses some valid paths.
Blocking (2): must change before merging.
builder/crates/build-core/src/sandbox_linux.rs:993: The width and program checks compare unresolved path spellings, but Landlock opens the resulting path following symlinks. (more on the line) Do: Resolve and validate the actual target, including existing parent components for directories that must be created, against the real home, bases, game and program paths before granting it; reject unsafe or unresolved links.builder/crates/build-core/src/addons.rs:477: The settings parser treats a valid TOML inline comment as part of the value instead of parsing the quoted string. (more on the line) Do: Parse each supported configuration format according to its syntax, including quoted strings and inline comments, and test a real path with a trailing comment.Should fix (3): not blocking, but worth doing before merging.
builder/crates/build-core/src/addons.rs:286: The 64 KiB limit is applied after reading the entire manifest; settings files are read the same way. (more on the line) Do: Open regular files and read at most 64 KiB plus one byte before deciding whether to discard them; apply the same bound to settings files.builder/crates/build-core/src/addons.rs:129: The pipeline-cache grants cannot create a cache on a fresh installation. (more on the line) Do: Provide a narrowly scoped way to create the individual cache file before confinement, with suitable error handling, or explicitly choose and document the permanent cold-cache behavior.builder/crates/build-core/src/sandbox_linux.rs:2315: The new integration test still discovers manifests from the host's /etc directory. (more on the line) Do: Point VK_IMPLICIT_LAYER_PATH at the test's isolated manifest directory, or inject the complete search list into the test.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4 and L5.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: the PR reports game-free tests but no confined game run with MAKO, lsfg-vk, MangoHud, or vkBasalt. No startup timing or cache measurements are supplied.
Other systems: The Linux rules affect every module in the confined process, including the game and other injected layers. Windows adds layer discovery and logging but no file grants from the current table. The PR reports no game runs on Linux, Steam Deck, or Windows; CI was still running.
Switches: No switches added, changed, or removed. Existing add-on and Vulkan environment variables now influence discovery and grants; HOS_SANDBOX remains unchanged.
Reviewed:
0dd3f900eaagainst1c91b18f86: Read AGENTS.md, CONTRIBUTING.md, the PR template, the commit and diff, addons.rs, and relevant sandbox path and rule application code. Skimmed the larger existing sandbox files and standards; docs/review-checklist.md is absent. No translations, generated files, or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: No code, tests, or project scripts were run, as requested. The PR reports cargo test and clippy results; its game scenarios remain untested and CI is still running.
Overlaps and merge order: Unknown; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +126,4 @@write(At::In(Base::Data, "mako-render/captures")),read(At::Var("MAKO_FG_PACKAGE")),write(At::In(Base::Cache, "mako-render")),write_file(At::In(Base::Cache, "mako_pipeline_cache.bin")),L4 (should fix): The pipeline-cache grants cannot create a cache on a fresh installation.
When: If mako_pipeline_cache.bin or lsfg-vk_pipeline_cache.bin does not exist before launch, find() omits it and no parent directory grant permits its creation. Subsequent confined launches therefore remain unable to persist that cache.
Do: Provide a narrowly scoped way to create the individual cache file before confinement, with suitable error handling, or explicitly choose and document the permanent cold-cache behavior.
@ -0,0 +283,4 @@pub fn layers_on_in(manifests: &[PathBuf], env: &dyn Fn(&str) -> Option<OsString>) -> Vec<Layer> {let mut out: Vec<Layer> = Vec::new();for m in manifests.iter().take(256) {let Ok(text) = std::fs::read(m) else { continue };L3 (should fix): The 64 KiB limit is applied after reading the entire manifest; settings files are read the same way.
When: A large file named by a layer search path or an add-on configuration variable is allocated and read in full at every launch before it is discarded, potentially exhausting memory or delaying startup.
Do: Open regular files and read at most 64 KiB plus one byte before deciding whether to discard them; apply the same bound to settings files.
@ -0,0 +474,4 @@}let (k, v) = line.split_once('=')?;let v = v.trim();let v = v.strip_prefix('"').and_then(|v| v.strip_suffix('"')).unwrap_or(v);L2 (blocking): The settings parser treats a valid TOML inline comment as part of the value instead of parsing the quoted string.
When: A MAKO configuration containing
dll = "/opt/lossless/Lossless.dll" # scaling libraryproduces a value beginning with a quote, which plain() rejects. When that DLL is outside the fixed Steam locations, the layer cannot read it under the sandbox.Do: Parse each supported configuration format according to its syntax, including quoted strings and inline comments, and test a real path with a trailing comment.
@ -965,0 +990,4 @@for g in found.grants {let above_base = bases.all().iter().any(|b| b.starts_with(&g.path));let writes = g.want != crate::addons::Want::Read;if !narrow(&g.path, home.as_deref()) || above_base || (writes && writes_the_program(input, &g.path)) {L1 (blocking): The width and program checks compare unresolved path spellings, but Landlock opens the resulting path following symlinks.
When: With MangoHud enabled and output_folder pointing to a symlink under the home directory whose target is the home directory or the game directory, the spelling passes these checks. The rule is then applied to the target directory and gives the confined game write access there.
Do: Resolve and validate the actual target, including existing parent components for directories that must be created, against the real home, bases, game and program paths before granting it; reject unsafe or unresolved links.
@ -2243,0 +2312,4 @@std::fs::write(game.join("longshot-game-process"), "x").unwrap();let mut env = Env::new();env.insert("HOME".into(), home.clone().into());env.insert("XDG_DATA_DIRS".into(), root.join("none").into());L5 (should fix): The new integration test still discovers manifests from the host's /etc directory.
When: If an enabled known add-on is installed in /etc/vulkan/implicit_layer.d, linux_manifests() includes it despite the test's XDG overrides, so the assertion that the off case has no add-on grants can fail based on the machine running the test.
Do: Point VK_IMPLICIT_LAYER_PATH at the test's isolated manifest directory, or inject the complete search list into the test.
0dd3f900ea2ee719d8a7WIP: feat(sandbox): add-ons get the places of their own they need, on Linux and Windows (MAKO, lsfg-vk, MangoHud, vkBasalt)to WIP: feat(sandbox): add-ons work in the sandbox on Linux and Windows, and every refusal says who asked@review
Recommendation: Request changes. The add-on grants still follow symlinks past the intended sandbox boundaries, and valid settings can be misread. The new Windows layer-library grant also silently stops after eight entries.
The change discovers add-ons, grants their files and adds diagnostics for refused access. It could make sandboxed add-ons usable, but the safety checks and several edge cases remain incomplete.
Blocking (2): must change before merging.
builder/crates/build-core/src/sandbox_linux.rs:993: The width and program checks compare unresolved path spellings, but Landlock opens the resulting path following symlinks. When: With MangoHud enabled and output_folder pointing to a symlink under the home directory whose target is the home directory or the game directory, the spelling passes these checks. The rule is then applied to the target directory and gives the confined game write access there. Do: Resolve and validate the actual target, including existing parent components for directories that must be created, against the real home, bases, game and program paths before granting it; reject unsafe or unresolved links.builder/crates/build-core/src/addons.rs:477: The settings parser treats a valid TOML inline comment as part of the value instead of parsing the quoted string. When: A MAKO configuration containingdll = "/opt/lossless/Lossless.dll" # scaling libraryproduces a value beginning with a quote, which plain() rejects. When that DLL is outside the fixed Steam locations, the layer cannot read it under the sandbox. Do: Parse each supported configuration format according to its syntax, including quoted strings and inline comments, and test a real path with a trailing comment.Should fix (5): not blocking, but worth doing before merging.
builder/crates/build-core/src/addons.rs:286: The 64 KiB limit is applied after reading the entire manifest; settings files are read the same way. When: A large file named by a layer search path or an add-on configuration variable is allocated and read in full at every launch before it is discarded, potentially exhausting memory or delaying startup. Do: Open regular files and read at most 64 KiB plus one byte before deciding whether to discard them; apply the same bound to settings files.builder/crates/build-core/src/addons.rs:129: The pipeline-cache grants cannot create a cache on a fresh installation. When: If mako_pipeline_cache.bin or lsfg-vk_pipeline_cache.bin does not exist before launch, find() omits it and no parent directory grant permits its creation. Subsequent confined launches therefore remain unable to persist that cache. Do: Provide a narrowly scoped way to create the individual cache file before confinement, with suitable error handling, or explicitly choose and document the permanent cold-cache behavior.builder/crates/build-core/src/sandbox_linux.rs:2315: The new integration test still discovers manifests from the host's /etc directory. When: If an enabled known add-on is installed in /etc/vulkan/implicit_layer.d, linux_manifests() includes it despite the test's XDG overrides, so the assertion that the off case has no add-on grants can fail based on the machine running the test. Do: Point VK_IMPLICIT_LAYER_PATH at the test's isolated manifest directory, or inject the complete search list into the test.builder/crates/build-core/src/sandbox_windows/plan.rs:477: Layer library grants silently stop after eight libraries. (more on the line) Do: Plan grants for all discovered layer libraries, or explicitly report every library omitted by a safe limit.host/hos_file_windows.c:643: The new load-refusal diagnostic covers only the wide-character LoadLibrary hooks. (more on the line) Do: Add equivalent refusal logging to both ANSI hooks, converting their paths with the appropriate Windows code page.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4, L5, L8 and L9.Since the last review (on
0dd3f900ea)Still open: L1 (The width and program checks compare unresolved path spellings, but Landlock opens the res…); L2 (The settings parser treats a valid TOML inline comment as part of the value instead of par…); L3 (The 64 KiB limit is applied after reading the entire manifest; settings files are read the…); L4 (The pipeline-cache grants cannot create a cache on a fresh installation.); L5 (The new integration test still discovers manifests from the host's /etc directory.); L6 (The add-on support and changed Linux grants have not been exercised in a confined game.); L7 (Windows layer discovery and its diagnostic have not been exercised in a game launch.)
New: L8 (Layer library grants silently stop after eight libraries.); L9 (The new load-refusal diagnostic covers only the wide-character LoadLibrary hooks.)
Checks: Still running: 11 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven: the reported game-free tests pass, but no game build or confined add-on run has been reported, and no before-and-after performance numbers are available.
Other systems: Linux library interposition affects file calls from drivers, the Vulkan loader and add-ons; Windows changes affect layer loading and file-service diagnostics. Confined game runs on Linux, Steam Deck and Windows remain outstanding.
Switches: No switches added, changed or removed.
Reviewed:
2ee719d8a7against1c91b18f86: Read the repository rules and pull request template, the commit and diff, and the code relevant to the ledger and changed layer grants and diagnostics. The complete changed code files, generated files and recorded runs were not all read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The author reports game-free Linux and Wine tests; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -461,6 +474,9 @@ pub fn plan(input: &Input) -> (bool, Grants) {);}p.guard = [Some(g), i.program_dir.as_deref()].into_iter().flatten().filter_map(path_norm).collect();for f in i.layer_libraries.iter().take(8) {L8 (should fix): Layer library grants silently stop after eight libraries.
When: With nine enabled implicit layers whose DLLs need their own AppContainer grant, the ninth DLL is not granted and can fail to load.
Do: Plan grants for all discovered layer libraries, or explicitly report every library omitted by a safe limit.
@ -567,2 +640,4 @@}static HMODULE WINAPI my_LoadLibraryExW(LPCWSTR p, HANDLE f, DWORD fl) {HMODULE m = ORIG(LoadExWFn, F_LOADEXW)(p, f, fl);if (!m) note_load(p, __builtin_return_address(0));L9 (should fix): The new load-refusal diagnostic covers only the wide-character LoadLibrary hooks.
When: An add-on using LoadLibraryA or LoadLibraryExA to load a DLL that the container refuses receives no refused-loading diagnostic.
Do: Add equivalent refusal logging to both ANSI hooks, converting their paths with the appropriate Windows code page.
2ee719d8a7d81f498e67@fix
d81f498e67e2b4810df6Recommendation: Approve. The code is ready: only testing is left. The sandbox changes have game-free test results, but their intended add-on support and Windows layer discovery have not been demonstrated in a game launch. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
e2b4810df6. I rebased it ontomain(471aff1bf9). I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The change discovers add-ons, grants selected files and layer libraries access, and adds refusal diagnostics. The fix hardens path handling, bounds reads, creates missing pipeline caches and extends Windows diagnostics; real-world compatibility and runtime cost remain unverified.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Unproven: the description reports passing game-free tests but no confined game or real add-on runs. No performance measurements are reported.
Other systems: Linux file calls from shared libraries and Windows layer loading can affect drivers, overlays and other add-ons. The reported tests cover simulated libraries and Wine, but no game launch on either platform or Steam Deck.
Switches: No switches added, changed or removed by the fix.
Reviewed:
e2b4810df6against471aff1bf9: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the fix diff, and relevant portions of addons.rs, sandbox_linux.rs, sandbox_windows/gather.rs, sandbox_windows/plan.rs, hos_file_windows.c and build-compile/src/lib.rs. The repository has no docs/review-checklist.md. The full base diff and remaining changed files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The description reports passing game-free tests, but no game build or launch; CI has not run on this head.
Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
WIP: feat(sandbox): add-ons work in the sandbox on Linux and Windows, and every refusal says who askedto feat(sandbox): add-ons work in the sandbox on Linux and Windows, and every refusal says who askedllun referenced this pull request2026-12-03 20:16:18 +00:00