Skip to content

capability: fall back to prctl when procfs is absent - #266

Closed
sairex53 wants to merge 1 commit into
moby:mainfrom
sairex53:codex/capability-lastcap-proc-fallback
Closed

sairex53 wants to merge 1 commit into
moby:mainfrom
sairex53:codex/capability-lastcap-proc-fallback

Conversation

@sairex53

Copy link
Copy Markdown

LastCap reads /proc/sys/kernel/cap_last_cap and returns an error if the file is absent. This makes capability operations fail in root filesystems without a proc mount.

When the procfs file is missing, probe PR_CAPBSET_READ until the kernel reports an unsupported capability. Keep the procfs path when it is available, and add a regression test for the fallback.

Tested on Fedora 44 ARM64:

  • cd capability && go test ./...

Fixes #265.

LastCap fails in root filesystems without /proc/sys/kernel/cap_last_cap. Probe PR_CAPBSET_READ on the running kernel when the procfs file is missing, and stop at the first unsupported capability.

Add a regression test that compares this fallback with the procfs result.

Fixes: moby#265
Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
@kolyshkin

Copy link
Copy Markdown
Collaborator

I am going to solve this differently.

@kolyshkin kolyshkin closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

capability.LastCap fails when /proc/sys/kernel/cap_last_cap is unavailable

2 participants