container: optionally isolate host abstract UNIX domain sockets via landlock #1

Open
ophestra wants to merge 1 commits from netadr-landlock-lsm into staging
Owner

This pull request is made on behalf of @netadr.

Hi,

Attached is a patch from the v0.1.1 tag that adds optional isolation of host abstract UNIX domain sockets from the container via the Landlock LSM's LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET. I had to use libpsx to invoke landlock_restrict_self atomically across all threads due to Go's unpredictable thread model and the fact that Landlock applies rulesets on a per-thread basis. The patch introduces a corresponding NixOS option and matching documentation in addition the core functionality. The only notable omission is automated testing through the sandbox test tool -- I wasn't sure how the maintainers would want that to be set up. I would love if this could be upstreamed; please let me know if I can do anything further to assist :)

netadr (Clayton)

This pull request is made on behalf of @netadr. Hi, Attached is a patch from the v0.1.1 tag that adds optional isolation of host abstract UNIX domain sockets from the container via the Landlock LSM's LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET. I had to use libpsx to invoke landlock_restrict_self atomically across all threads due to Go's unpredictable thread model and the fact that Landlock applies rulesets on a per-thread basis. The patch introduces a corresponding NixOS option and matching documentation in addition the core functionality. The only notable omission is automated testing through the sandbox test tool -- I wasn't sure how the maintainers would want that to be set up. I would love if this could be upstreamed; please let me know if I can do anything further to assist :) netadr (Clayton)
ophestra added 1 commit 2025-08-17 13:33:10 +09:00
container: optionally isolate host abstract UNIX domain sockets via landlock
Some checks failed
Test / Create distribution (push) Failing after 52s
Test / Sandbox (push) Successful in 2m22s
Test / Sandbox (race detector) (push) Successful in 4m4s
Test / Planterette (push) Successful in 4m3s
Test / Create distribution (pull_request) Failing after 29s
Test / Sandbox (pull_request) Successful in 40s
Test / Sandbox (race detector) (pull_request) Successful in 41s
Test / Planterette (pull_request) Successful in 41s
Test / Hakurei (push) Failing after 20m46s
Test / Hakurei (race detector) (push) Failing after 22m7s
Test / Flake checks (push) Has been skipped
Test / Hakurei (pull_request) Failing after 34m54s
Test / Hakurei (race detector) (pull_request) Failing after 36m37s
Test / Flake checks (pull_request) Has been skipped
7add29b79c
Author
Owner

For landlock_restrict_self we might not need libpsx, since we can call runtime.LockOSThread() in [Container.Start] somewhere before landlock_restrict_self is called. I have yet to verify this for landlock_restrict_self but it works for all other syscalls that works on the calling thread.

For landlock_restrict_self we might not need libpsx, since we can call runtime.LockOSThread() in [Container.Start] somewhere before landlock_restrict_self is called. I have yet to verify this for landlock_restrict_self but it works for all other syscalls that works on the calling thread.
cat force-pushed netadr-landlock-lsm from 7add29b79c to 2de7c2d07d 2025-08-17 16:06:10 +09:00 Compare
cat force-pushed netadr-landlock-lsm from 2de7c2d07d to c809e9bd7c 2025-08-17 16:16:57 +09:00 Compare
cat force-pushed netadr-landlock-lsm from c809e9bd7c to d0d6f192ad 2025-08-17 17:34:17 +09:00 Compare
cat force-pushed netadr-landlock-lsm from d0d6f192ad to 141bec290b 2025-08-17 17:36:57 +09:00 Compare
cat force-pushed netadr-landlock-lsm from 141bec290b to 9eb6bc71c4 2025-08-17 17:44:24 +09:00 Compare
cat referenced this issue from a commit 2025-08-18 02:27:57 +09:00
cat referenced this issue from a commit 2025-08-18 02:33:34 +09:00
cat force-pushed netadr-landlock-lsm from 9eb6bc71c4 to a5baad9e00 2025-08-18 02:36:50 +09:00 Compare
cat force-pushed netadr-landlock-lsm from a5baad9e00 to c1ff73b1b1 2025-08-18 02:50:21 +09:00 Compare
Some checks failed
Test / Create distribution (push) Successful in 36s
Test / Create distribution (pull_request) Successful in 31s
Test / Sandbox (pull_request) Successful in 2m13s
Test / Sandbox (push) Successful in 2m20s
Test / Hpkg (push) Successful in 4m6s
Test / Hpkg (pull_request) Successful in 3m59s
Test / Sandbox (race detector) (pull_request) Successful in 4m15s
Test / Sandbox (race detector) (push) Successful in 4m27s
Test / Hakurei (race detector) (push) Failing after 22m30s
Test / Flake checks (pull_request) Has been cancelled
Test / Hakurei (pull_request) Has been cancelled
Test / Hakurei (race detector) (pull_request) Has been cancelled
Test / Hakurei (push) Failing after 39m52s
Test / Flake checks (push) Has been skipped
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin netadr-landlock-lsm:netadr-landlock-lsm
git checkout netadr-landlock-lsm
Sign in to join this conversation.
No description provided.