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

proc mounted with wrong permission #151

Open
ezrizhu opened this issue Mar 8, 2024 · 1 comment
Open

proc mounted with wrong permission #151

ezrizhu opened this issue Mar 8, 2024 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@ezrizhu
Copy link
Collaborator

ezrizhu commented Mar 8, 2024

dr-xr-xr-x 235 nobody root 0 Mar 16 01:50 proc
from #138

currently, we're using mount -t proc proc /proc

Attempted solution

unshare --mount --map-root-user --pid --fork /bin/bash
mkdir proc
mount -t proc -o uid=0,gid=0 none proc

but we get
mount: a: wrong fs type, bad option, bad superblock on none, missing codepage or helper program, or other error.

ezrizhu added a commit that referenced this issue Mar 8, 2024
In this commit, we are ensuring the dirs in the `/` root path of the temproot is as close as the 'real' one as possible. 

`$SANDBOX_DIR/temproot` is now being created with the same permission as the host, and every other directories on the top level are created with the same mode as the real one.
Symlinks are now also created in the unshare, and removed after unshare finishes. 
Tests are created to check the mode, ownership, and symlink of the files in the `/` directory. 

Known issues
In the test, we're ignoring files with the name swap.
And also /proc, our current `mount -t proc proc /proc` invocation are creating the /proc dir with nobody and nogroup ownership.  We're tracking this in #151
This PR currently assumes there are no regular files in the root dir besides the swap.img. We're tracking this in issue #150 

* feat: keep toplevel dir perms in temproot - fixes #80

* feat: recreate symlinks in temproot - fixes #139

* feat: set correct permission for root dir, and remove symlink after unshare

* feat: set temproot to be writible before removing symlinks

* test: add new test to verify consistency of root dir (see known issues)

* test(reuse_problematic_sandbox): set test to use a non-symblink dir

* test(toplevel-perms): ignore acl bit, user&group ownership
@ezrizhu
Copy link
Collaborator Author

ezrizhu commented Mar 18, 2024

attempted --mount-proc with unshare(1), also came back as owned by nobody and nogroup. unable to remount with gid,uid=0 aswell.

@ezrizhu ezrizhu added the help wanted Extra attention is needed label Mar 18, 2024
ezrizhu added a commit that referenced this issue Jun 12, 2024
In this commit, we are ensuring the dirs in the `/` root path of the temproot is as close as the 'real' one as possible. 

`$SANDBOX_DIR/temproot` is now being created with the same permission as the host, and every other directories on the top level are created with the same mode as the real one.
Symlinks are now also created in the unshare, and removed after unshare finishes. 
Tests are created to check the mode, ownership, and symlink of the files in the `/` directory. 

Known issues
In the test, we're ignoring files with the name swap.
And also /proc, our current `mount -t proc proc /proc` invocation are creating the /proc dir with nobody and nogroup ownership.  We're tracking this in #151
This PR currently assumes there are no regular files in the root dir besides the swap.img. We're tracking this in issue #150 

* feat: keep toplevel dir perms in temproot - fixes #80

* feat: recreate symlinks in temproot - fixes #139

* feat: set correct permission for root dir, and remove symlink after unshare

* feat: set temproot to be writible before removing symlinks

* test: add new test to verify consistency of root dir (see known issues)

* test(reuse_problematic_sandbox): set test to use a non-symblink dir

* test(toplevel-perms): ignore acl bit, user&group ownership
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant