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

[Feature] overlayfs mounts #412

Closed
georgeto opened this issue Mar 20, 2021 · 5 comments
Closed

[Feature] overlayfs mounts #412

georgeto opened this issue Mar 20, 2021 · 5 comments

Comments

@georgeto
Copy link

There is already pull request #167 from four years ago that implements exactly this feature, but it was abandoned due to security concerns regarding overlayfs.
However, nowadays there is fuse-overlayfs, so i guess this blocker is history?

I rebased the abandoned pull request onto the current master branch, and was able to use the bubblewrap overlayfs feature as a non-root user with a non-setuid bubblewrap binary.
I searched for overlayfs in my installed packages, and what I found was fuse-overlayfs, which I guess explains why I can use this feature as a non-root user with a non-setuid bubblewrap binary.

Is there a chance to get the overlayfs feature merged, if I fix the open issues (e.g. handling realpath errors) and make a new pull request?

@georgeto georgeto changed the title [Feature] option --overlay and --ro-overlay [Feature] overlayfs mounts Mar 20, 2021
@Maryse47
Copy link

I searched for overlayfs in my installed packages, and what I found was fuse-overlayfs, which I guess explains why I can use this feature as a non-root user with a non-setuid bubblewrap binary.

Another possibility is you have Linux 5.11+ which enabled rootless overlayfs.

@georgeto
Copy link
Author

I searched for overlayfs in my installed packages, and what I found was fuse-overlayfs, which I guess explains why I can use this feature as a non-root user with a non-setuid bubblewrap binary.

Another possibility is you have Linux 5.11+ which enabled rootless overlayfs.

Indeed, I have Linux 5.11, so this could very well be.

@joanbm
Copy link

joanbm commented Apr 1, 2021

While this is not integrated, this is a workaround for rootless overlayfs mounts on Linux >=5.11.

  1. Use bwrap to run a wrapper script bwrap_overlayfs_wrapper. Give it extra capabilities CAP_DAC_OVERRIDE and CAP_SYS_ADMIN (in order to do the overlay) and CAP_SETPCAP (to drop the extra capabilities):
bwrap --dev-bind / / --cap-add CAP_SETPCAP --cap-add CAP_DAC_OVERRIDE --cap-add CAP_SYS_ADMIN -- ./bwrap_overlayfs_wrapper ls
  1. Now in this wrapper script bwrap_overlayfs_wrapper you do the overlay you want (here I'm doing an overlayfs for $HOME) and then use capsh to drop the extra capabilities:
#!/usr/bin/env bash
set -euo pipefail

# Create a throwaway overlayfs
TEMPDIR="$(mktemp -d)"
trap 'rm -rf "$TEMPDIR"' EXIT

mkdir -p "$TEMPDIR"/{upper,work}
mount -t overlay -o lowerdir="$HOME",upperdir="$TEMPDIR"/upper,workdir="$TEMPDIR"/work none "$HOME"
trap 'umount "$HOME" && rm -rf "$TEMPDIR"' EXIT

touch "$HOME/this_is_an_overlay"

# Drop capabilities that should have been given to the wrapper then execute the original program
(cd "$(pwd)" && capsh --drop=CAP_SYS_ADMIN --drop=CAP_SETPCAP --drop=CAP_DAC_OVERRIDE --caps="" --shell=/usr/bin/env -- -- "$@")

Example:

[user@machine ~]$ ls
bwrap_overlayfs_wrapper  some_document
[user@machine ~]$ bwrap --dev-bind / / --cap-add CAP_SETPCAP --cap-add CAP_DAC_OVERRIDE --cap-add CAP_SYS_ADMIN -- ./bwrap_overlayfs_wrapper ls
bwrap_overlayfs_wrapper  some_document	this_is_an_overlay
[user@machine ~]$ ls
bwrap_overlayfs_wrapper  some_document
[user@machine ~]$ 

This is rootless and as far as I can tell by checking /proc/self/status, no extra capabilities remain.

@smcv
Copy link
Collaborator

smcv commented Jan 5, 2023

Is there a chance to get the overlayfs feature merged, if I fix the open issues (e.g. #167 (comment)) and make a new pull request?

I'd consider a PR that enabled this on kernels where overlayfs is allowed for non-root users, and only when bubblewrap is not setuid (same restriction as --size, --userns-fd, --cap-add).

On kernels where overlayfs is not allowed for non-root users, bubblewrap should not allow it either.

Similarly, when bubblewrap is setuid root, we should not allow this: with a setuid bubblewrap (as used on Debian <= 10, etc.), there's too high a risk of bubblewrap allowing something that the kernel considers unsafe.

@smcv
Copy link
Collaborator

smcv commented Jan 6, 2023

I'd consider a PR that enabled this on kernels where overlayfs is allowed for non-root users, and only when bubblewrap is not setuid (same restriction as --size, --userns-fd, --cap-add)

... for example #547.

rhendric added a commit to rhendric/bubblewrap that referenced this issue Jan 6, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Jan 6, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Jan 31, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Mar 5, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Mar 5, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue May 14, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
swick pushed a commit to swick/bubblewrap that referenced this issue Sep 28, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Oct 5, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Nov 18, 2023
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Apr 22, 2024
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Sep 16, 2024
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Sep 24, 2024
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Oct 3, 2024
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
smcv pushed a commit to rhendric/bubblewrap that referenced this issue Oct 15, 2024
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
[smcv: Fix merge conflicts with containers#660]
Signed-off-by: Simon McVittie <[email protected]>
rhendric added a commit to rhendric/bubblewrap that referenced this issue Oct 15, 2024
This commit adds --overlay, --tmp-overlay, --ro-overlay, and
--overlay-src options to enable bubblewrap to create overlay mounts.
These options are only permitted when bubblewrap is not installed
setuid.

Resolves: containers#412
Co-authored-by: William Manley <[email protected]>
Signed-off-by: Ryan Hendrickson <[email protected]>
[smcv: Fix merge conflicts with containers#660]
Signed-off-by: Simon McVittie <[email protected]>
@smcv smcv closed this as completed in f371022 Oct 16, 2024
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

No branches or pull requests

4 participants