Skip to content

Comments

fix: add writable tmpfs for /host/dev/shm (POSIX semaphores)#972

Merged
Mossaka merged 1 commit intomainfrom
fix/writable-dev-shm
Feb 19, 2026
Merged

fix: add writable tmpfs for /host/dev/shm (POSIX semaphores)#972
Mossaka merged 1 commit intomainfrom
fix/writable-dev-shm

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Feb 19, 2026

Summary

  • /dev is bind-mounted read-only (/dev:/host/dev:ro), making /dev/shm read-only after chroot /host
  • This breaks POSIX semaphores — python/black's blackd server (and other tools) fail with OSError: [Errno 30] Read-only file system when creating semaphores
  • Adds a tmpfs overlay at /host/dev/shm to provide a writable, isolated in-memory filesystem after chroot

Security Assessment

Low risk. Adding a writable /host/dev/shm tmpfs is safe because:

  • Docker containers use their own IPC namespace by default (no --ipc=host), so shared memory is fully isolated from the host and other containers
  • The agent already has writable /tmp at both /tmp and /host/tmp/dev/shm provides similar attack surface
  • Size is capped at 64MB (size=65536k) matching Docker's default; noexec and nosuid flags restrict abuse
  • All capabilities (NET_ADMIN, SYS_CHROOT, SYS_ADMIN) are dropped before user code runs

Test plan

  • Unit tests pass (npm test — 794/794 tests pass)
  • Updated should include exactly 5 tmpfs mounts test to account for new /host/dev/shm entry
  • Updated should set secure tmpfs options test to allow size=65536k (not just size=1m)
  • Manual validation: run a Python workflow that uses black --check to verify blackd semaphore creation succeeds

🤖 Generated with Claude Code

/dev is bind-mounted read-only (/dev:/host/dev:ro), which makes /dev/shm
read-only after chroot /host. This breaks POSIX semaphores — python/black's
blackd server and other tools fail with EROFS when creating semaphores.

Adding a tmpfs overlay at /host/dev/shm provides a writable, isolated
in-memory filesystem. Security: Docker containers have their own IPC namespace
(no --ipc=host), so shared memory is fully isolated from the host and other
containers. Size is capped at 64MB with noexec and nosuid flags.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 19, 2026 21:18
@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 82.30% 82.45% 📈 +0.15%
Statements 82.23% 82.37% 📈 +0.14%
Functions 82.74% 82.74% ➡️ +0.00%
Branches 74.46% 74.55% 📈 +0.09%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 83.2% → 83.8% (+0.55%) 82.5% → 83.0% (+0.54%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions
Copy link
Contributor

Node.js Build Test Results

Project Install Tests Status
clsx PASS PASS
execa PASS PASS
p-limit PASS PASS

Overall: PASS

All projects installed successfully and all tests passed.

AI generated by Build Test Node.js

@github-actions
Copy link
Contributor

Deno Build Test Results

Project Tests Status
oak 1/1 ✅ PASS
std 1/1 ✅ PASS

Overall: ✅ PASS

All Deno tests completed successfully.

AI generated by Build Test Deno

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes POSIX semaphore failures in the chrooted agent container by adding a writable tmpfs overlay for /host/dev/shm. The issue occurs because /dev is bind-mounted read-only (/dev:/host/dev:ro), which makes /dev/shm read-only after chroot /host, breaking tools like Python's black that require writable shared memory for semaphores.

Changes:

  • Added a 64MB tmpfs mount at /host/dev/shm with security flags (noexec, nosuid, nodev)
  • Updated tests to account for 5 tmpfs mounts (previously 4) and allow variable size limits
  • Added comprehensive documentation explaining the security implications and isolation guarantees

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/docker-manager.ts Added /host/dev/shm tmpfs mount with 64MB size limit and security flags; included detailed comment about IPC isolation and security implications
src/docker-manager.test.ts Updated test count from 4 to 5 tmpfs mounts; changed size validation from exact size=1m to regex pattern allowing both 1m and 65536k

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// A tmpfs overlay at /host/dev/shm provides a writable, isolated in-memory filesystem.
// Security: Docker containers use their own IPC namespace (no --ipc=host), so shared
// memory is fully isolated from the host and other containers. Size is capped at 64MB
// (Docker's default). noexec and nosuid flags restrict abuse vectors.
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions "noexec and nosuid flags restrict abuse vectors" but doesn't mention the nodev flag that's also applied in line 849. Consider updating the comment to include nodev for completeness: "noexec, nosuid, and nodev flags restrict abuse vectors."

Suggested change
// (Docker's default). noexec and nosuid flags restrict abuse vectors.
// (Docker's default). noexec, nosuid, and nodev flags restrict abuse vectors.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ build tests completed successfully.

AI generated by Build Test C++

@github-actions
Copy link
Contributor

Go Build Test Results ✅

All Go projects tested successfully!

Project Download Tests Status
color 1/1 PASS
env 1/1 PASS
uuid 1/1 PASS

Overall: PASS

AI generated by Build Test Go

@github-actions
Copy link
Contributor

Smoke Test Results

Last 2 Merged PRs:

✅ GitHub MCP
✅ Playwright
✅ File Write
✅ Bash Tool

Status: PASS

cc @Mossaka

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Bun Build Test Results

Project Install Tests Status
elysia 1/1 PASS
hono 1/1 PASS

Overall: PASS

All Bun projects built and tested successfully.

AI generated by Build Test Bun

@github-actions
Copy link
Contributor

.NET Build Test Results ✅

All .NET projects tested successfully!

Project Restore Build Run Status
hello-world PASS
json-parse PASS

Overall: PASS

Test Details

hello-world:

  • Restore: ✅ Completed in 79ms
  • Build: ✅ 0 errors, 0 warnings
  • Run: ✅ Output: "Hello, World!"

json-parse:

  • Restore: ✅ Completed in 703ms (with NuGet packages)
  • Build: ✅ 0 errors, 0 warnings
  • Run: ✅ Successfully parsed JSON and printed formatted output

AI generated by Build Test .NET

@github-actions
Copy link
Contributor

Build Test Results: Java ✅

Project Compile Tests Status
gson 1/1 PASS
caffeine 1/1 PASS

Overall: PASS

All Java projects compiled and tested successfully using Maven with proxy configuration.

AI generated by Build Test Java

@github-actions
Copy link
Contributor

feat: simplify release to workflow_dispatch only
feat: add ARM64 binary support for awf CLI
GitHub MCP (last 2 merged PRs): ✅
safeinputs-gh pr list: ✅
Playwright title: ✅
Tavily search: ❌ (tool unavailable)
File write + cat: ✅
Discussion query + comment: ✅
Build (npm ci && npm run build): ✅
Overall: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

Rust Build Test Results ✅

Project Build Tests Status
fd 1/1 PASS
zoxide 1/1 PASS

Overall: PASS

All Rust projects built successfully and passed their tests.

AI generated by Build Test Rust

@github-actions
Copy link
Contributor

Chroot Version Comparison Test Results

The chroot mode test compared runtime versions between the host system and the chroot environment:

Runtime Host Version Chroot Version Match?
Python Python 3.12.12 Python 3.12.3 ❌ NO
Node.js v24.13.0 v20.20.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall Result: ❌ Tests FAILED (1 of 3 passed)

The chroot environment successfully accessed and executed host binaries, but version mismatches were detected for Python and Node.js. This is expected if the host system has been updated after the chroot environment was created, or if the chroot is using system-installed versions while the host uses newer versions from package managers like nvm or pyenv.

AI generated by Smoke Chroot

@github-actions
Copy link
Contributor

Smoke Test Results

Last 2 merged PRs:

  • feat: simplify release to workflow_dispatch only
  • feat: add ARM64 binary support for awf CLI

✅ GitHub MCP (list PRs)
✅ Playwright (github.com navigation, title verified)
✅ File creation (/tmp/gh-aw/agent/smoke-test-claude-22200520155.txt)
✅ Bash commands (file read verification)

Status: PASS

AI generated by Smoke Claude

@Mossaka Mossaka merged commit 7916aa8 into main Feb 19, 2026
94 checks passed
@Mossaka Mossaka deleted the fix/writable-dev-shm branch February 19, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant