Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runsc: When mounting a new procfs fails, fall back to recursive bind-mount. #11097

Merged
merged 1 commit into from
Nov 1, 2024

Conversation

copybara-service[bot]
Copy link

runsc: When mounting a new procfs fails, fall back to recursive bind-mount.

As part of sandbox startup, runsc needs to set up a chroot environment
with a minimal working procfs filesystem mounted within. However, doing
so from within a container (as applications like Dangerzone do) may fail,
because in the container runtime's default configuration, some paths of the
procfs filesystem visible from within the container may be obstructed. This
prevents mounting new unobstructed instances of procfs.

This change detects this case and falls back to the previous behavior of
using a recursive bind-mount of /proc in such a case. The obstructed
subdirectories of procfs are preserved in this case, which is fine because
we only need a very minimal subset of procfs to actually work.

Additionally, runsc actually only needs a few kernel parameter files
and /proc/self in order to work. So this change sets up a tmpfs mount
that contains just those files, with the kernel parameter files being
plainly copied and /proc/self being a symlink to the one present in the
mounted view of procfs (regardless of which mounting method was used).

The runtime_in_docker test will continuously verify that this fallback
mechanism works to avoid similar breakage in the future.

Credits to @avagin for figuring out this solution.

Fixes #10944.

@copybara-service copybara-service bot added the exported Issue was exported automatically label Oct 31, 2024
@copybara-service copybara-service bot force-pushed the test/cl691672104 branch 7 times, most recently from 16ddc95 to 315c869 Compare November 1, 2024 21:39
…mount.

As part of sandbox startup, `runsc` needs to set up a chroot environment
with a minimal working `procfs` filesystem mounted within. However, doing
so from within a container (as applications like Dangerzone do) may fail,
because in the container runtime's default configuration, some paths of the
procfs filesystem visible from within the container may be obstructed. This
prevents mounting new unobstructed instances of `procfs`.

This change detects this case and falls back to the previous behavior of
using a recursive bind-mount of `/proc` in such a case. The obstructed
subdirectories of procfs are preserved in this case, which is fine because
we only need a very minimal subset of `procfs` to actually work.

Additionally, `runsc` actually only needs a few kernel parameter files
and `/proc/self` in order to work. So this change sets up a `tmpfs` mount
that contains just those files, with the kernel parameter files being
plainly copied and `/proc/self` being a symlink to the one present in the
mounted view of `procfs` (regardless of which mounting method was used).

The `runtime_in_docker` test will continuously verify that this fallback
mechanism works to avoid similar breakage in the future.

Credits to @avagin for figuring out this solution.

Fixes #10944.

PiperOrigin-RevId: 692310347
@copybara-service copybara-service bot merged commit 6adc072 into master Nov 1, 2024
0 of 2 checks passed
@copybara-service copybara-service bot deleted the test/cl691672104 branch November 1, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exported Issue was exported automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Operation not permitted when mounting /proc to /tmp/proc
1 participant