Rootless containers having access to device files even without --device-cgroup-rule #16855
Replies: 2 comments 4 replies
-
Rootless users are not allowed to create devices or to modify the protections on the devices. When you run a container with a volume from the host system, then it is bind mounted into the container. In rootful mode, the device is created inside of the container so permissions and other fields can be changed. Note for rootless users, you might need to do |
Beta Was this translation helpful? Give feedback.
-
I guess i still did not get it, when you say device is created inside rootful container and not bind mounted. But when I am running rootful container i am bind mounting /dev with flag -v. Is there some exception for /dev directory, that even when we do bind mount in a rootful container using -v /dev:/dev then the rootful container does not bind mounts instead it re create the device node which are present on host system. Is this specifically for /dev directory. And by creating device you mean creating using mknode, if that is so then I have not given permission to use mknode if you see the way i am executing the container in rootful mode: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Team,
Below is my environment information:
[satx@sat ~]$ uname -a
Linux sat.com 5.15.0-4.70.5.2.el9uek.x86_64 #2 SMP Wed Nov 16 05:19:51 PST 2022 x86_64 x86_64 x86_64 GNU/Linux
[satx@sat ~]$ podman --version
podman version 4.2.0
Default ownership of any video file in my system looks as below:
Inside my containers I wanted to access video device files and wanted to run the container rootless as well. In order to achieve the same I set the policy for SELinux as below:
setsebool -P container_use_devices=true
And post that when I run my rootless container as below I am able to access all the device files:
My Concern is that if I run the same container using same way as root user then the container is not able to access the device files as can be seen below:
It looks like for rooted containers there are 2 lines of defense in order to access the device files, one we need to set the SELinux Policy as mentioned above secondly we need to use the --device-cgroup-rule flag when running the container and then only rooted container is able to access the device files as can be seen below:
My assumption was that the rootless container should also require the --device-cgroup-rule in order to access video devices. Rootless container should also have same amount of restrictions.
Why more restrictions for root user and less restrictions for rootless user. Is this some kind of security issue or I missed to understand something.
Beta Was this translation helpful? Give feedback.
All reactions