Restriction of filesystem mounting
Hello,
I've come across the need to restrict ability of mounting filesystems inside container and probably forbid remounting of already mounted filesystems in container namespace (mounted by lxc-start for example). It semms that the obvious solution is to drop capability from bounding set of processes inside container. Unfortunately there is no separate capability for mount/umount and dropping of CAP_SYS_ADMIN is unacceptable in my case.
I don't see a way to solve this problem without modifying kernel code, though I don't know how exactly to modify it. My first thought was to create new separate capability CAP_SYS_MOUNT, although it may break existing applications which presume CAP_SYS_ADMIN would be enough to do mount/umount. Another option to solve this problem would be to create cgroup controller with list of permitted filesystem types similar to existing controller for devices (CGROUP_DEVICE).
Any suggestions will be helpful.
With best reagrds,
Sergey Kononenko.
Quoted 7 lines · Sergey Kononenko
I've come across the need to restrict ability of mounting filesystems inside container and probably forbid remounting of already mounted filesystems in container namespace (mounted by lxc-start for example). It semms that the obvious solution is to drop capability from bounding set of processes inside container. Unfortunately there is no separate capability for mount/umount and dropping of
CAP_SYS_ADMINis unacceptable in my case.
Could you explain a little more why you have this requirement? Anybody in their own filesystem namespace can do no harm to users in other namespaces. What's the worry?
-- Dave
Quoted 3 lines
Could you explain a little more why you have this requirement? Anybody in their own filesystem namespace can do no harm to users in other namespaces. What's the worry?
I don't want to expose information about hardware configuration to processes inside container which now can be easily accessed by mounting sysfs. Also through sysfs direct access to hardware is possible and that definitely can do harm to other containers and whole system. For example removing hard drives by
echo 1 > /sys/bus/scsi/drivers/sd/<SCSI-ID>/delete
So I definitely want to forbid mounting of sysfs inside container. And probably there are some other "dangerous" filesystems.
Also in the future I plan to make mount option for proc filesystem which hide kernel low level or hardware information (/proc/bus, /proc/interrupts, etc.) And I want to mount proc with such option inside container once, without possibility of remounting without option and getting unrestricted view of proc.
With best regards,
Sergey Kononenko.