Skip to content

fix(runregistry): keep runs whose pid we may not signal - #4982

Open
TDnorthgarden wants to merge 1 commit into
docker:mainfrom
TDnorthgarden:fix/runregistry-eperm-liveness
Open

TDnorthgarden wants to merge 1 commit into
docker:mainfrom
TDnorthgarden:fix/runregistry-eperm-liveness

Conversation

@TDnorthgarden

Copy link
Copy Markdown
Contributor

Problem

pidAlive treats a failed signal probe as proof the process is dead. On Unix, kill(pid, 0) returns EPERM when the process exists but belongs to another user (or root), so a live run was judged dead and Registry.List deleted its record (pkg/runregistry/registry.go:123-126) — making the run invisible to List/Find/Latest on multi-user hosts, shared data directories, and containers.

Windows has the same shape: OpenProcess returns ERROR_ACCESS_DENIED for protected processes (elevated or AV-guarded), which was also treated as dead.

Fix

  • Treat EPERM as alive on Unix: the probe proves the process exists, only inspection is refused. Same for ERROR_ACCESS_DENIED on Windows.
  • The kill(pid, 0) probe is now an injectable variable so the permission-denied branch can be exercised without a second user (TestPidAlivePermissionDenied); TestPidAliveRejectsNonPositive keeps the 0/negative guard.
  • The Windows path is otherwise unchanged; the repo's cross-compile CI verifies it.

Fixes #4981

@TDnorthgarden
TDnorthgarden requested a review from a team as a code owner November 20, 2026 11:25
@aheritier aheritier added area/registry OCI registry, agent sharing, push/pull kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Nov 20, 2026

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Unix fix addresses #4981: a real EPERM probe confirmed that the patched registry retains a record the base commit deleted. Please add a Windows regression test for the permission-denied behavior before merging.

return false
// ERROR_ACCESS_DENIED means the process exists but is protected
// (elevated or AV-guarded); it is alive.
return errors.Is(err, windows.ERROR_ACCESS_DENIED)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] Please add a Windows regression test that makes OpenProcess return ERROR_ACCESS_DENIED and asserts pidAlive still returns true. TestList_RealLiveness probes the current process and an exited child; neither exercises access denial. The Windows suite would still pass if this branch returned false and Registry.List resumed deleting records for protected live processes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Windows regression is added in f164b6c (force-pushed): openProcess is now a variable so TestPidAliveAccessDenied can make it return ERROR_ACCESS_DENIED and assert pidAlive returns true — pinning exactly the branch you flagged, while TestList_RealLiveness stays as-is.
The Windows test binary cross-compiles and vets clean for windows/amd64 locally; test-windows CI will execute it. Marking the PR ready for review.

@aheritier
aheritier marked this pull request as draft November 22, 2026 00:14
@aheritier

Copy link
Copy Markdown
Collaborator

👋 We’ve requested changes on this PR. Once you’ve addressed the feedback, please mark it ready for review.

pidAlive treated a failed signal probe as proof the process was dead.
On Unix, kill(pid, 0) returns EPERM when the process exists but belongs
to another user (or root), so a live run was judged dead and List
deleted its record — making it invisible to List/Find/Latest on
multi-user hosts, shared data dirs, and containers. Windows had the
same shape: OpenProcess returns ERROR_ACCESS_DENIED for protected
processes (elevated or AV-guarded), which was also treated as dead.

Treat EPERM (and ERROR_ACCESS_DENIED on Windows) as alive: it proves
existence, only inspection is refused. The probes are variables
(signalProcess, openProcess) so each platform's permission-denied
branch is pinned by a regression test without needing a second user or
a protected process.

Fixes docker#4981

Signed-off-by: Aucoto Zhang <tdnorthgarden@gmail.com>
@TDnorthgarden
TDnorthgarden force-pushed the fix/runregistry-eperm-liveness branch from 13fc176 to f164b6c Compare November 22, 2026 03:20
@TDnorthgarden
TDnorthgarden marked this pull request as ready for review November 22, 2026 03:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/registry OCI registry, agent sharing, push/pull kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runregistry treats an unsignalable live process (EPERM) as dead and deletes its record

2 participants