Skip to content

runsc: Make identity user mapping work for filesystem #11875

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

terenceli
Copy link

Fix #9918.

Currently, the rootless mode(runsc is called by no-root user) is not working well with the filesystem if we uses a non-root user in runsc container. This is because the runsc is mapping the host non-root user to root-user in container.

In some cases we need to map the host non-root user to runsc container non-root user (with the same uid).

After this patch, the following filesystem operations works well.

test@test-virtual-machine:/test$ ./runsc -ignore-cgroups --network host run abc
id
uid=1000(test) gid=1000(test) groups=1000(test)
touch /tmp/runsctest
echo aaa > /tmp/runsctest
ls -lh /tmp/runsctest
-rw-r--r-- 1 test test 4 Jun 29 18:46 /tmp/runsctest
exit
test@test-virtual-machine:
/test$ ls -lh /tmp/runsctest
-rw-r--r-- 1 test test 4 6月 29 18:46 /tmp/runsctest
test@test-virtual-machine:~/test$ cat /tmp/runsctest

Fix google#9918.

Currently, the rootless mode(runsc is called by no-root user)
is not working well with the filesystem if we uses a non-root user
in runsc container. This is because the runsc is mapping the
host non-root user to root-user in container.

In some cases we need to map the host non-root user to runsc
container non-root user (with the same uid).

After this patch, the following filesystem operations works well.

test@test-virtual-machine:~/test$ ./runsc   -ignore-cgroups --network host run abc
id
uid=1000(test) gid=1000(test) groups=1000(test)
touch /tmp/runsctest
echo aaa > /tmp/runsctest
ls -lh /tmp/runsctest
-rw-r--r-- 1 test test 4 Jun 29 18:46 /tmp/runsctest
exit
test@test-virtual-machine:~/test$ ls -lh /tmp/runsctest
-rw-r--r-- 1 test test 4  6月 29 18:46 /tmp/runsctest
test@test-virtual-machine:~/test$ cat /tmp/runsctest
@avagin
Copy link
Collaborator

avagin commented Jul 1, 2025

How does https://github.com/opencontainers/runc handle this case?

@terenceli
Copy link
Author

How does https://github.com/opencontainers/runc handle this case?

@avagin After I test, the runc is still not support this, but crun support this.

The discuess:
runc: opencontainers/runc#1800
crun: containers/crun#1082

I will make a more deep analysis in how runc and crun handle this case.

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.

gVisor unprivileged user can't access file in rootless mode
2 participants