Merge pull request #10205 from ashahab-altiscale/9875-non-privileged-proc-sys
use lxc.auto.mount to ensure proc and sys are readonly
This commit is contained in:
commit
cac17f990b
1 changed files with 12 additions and 9 deletions
|
@ -61,13 +61,24 @@ lxc.cgroup.devices.allow = {{$allowedDevice.GetCgroupAllowString}}
|
||||||
lxc.pivotdir = lxc_putold
|
lxc.pivotdir = lxc_putold
|
||||||
|
|
||||||
# NOTICE: These mounts must be applied within the namespace
|
# NOTICE: These mounts must be applied within the namespace
|
||||||
|
{{if .ProcessConfig.Privileged}}
|
||||||
# WARNING: mounting procfs and/or sysfs read-write is a known attack vector.
|
# WARNING: mounting procfs and/or sysfs read-write is a known attack vector.
|
||||||
# See e.g. http://blog.zx2c4.com/749 and http://bit.ly/T9CkqJ
|
# See e.g. http://blog.zx2c4.com/749 and http://bit.ly/T9CkqJ
|
||||||
# We mount them read-write here, but later, dockerinit will call the Restrict() function to remount them read-only.
|
# We mount them read-write here, but later, dockerinit will call the Restrict() function to remount them read-only.
|
||||||
# We cannot mount them directly read-only, because that would prevent loading AppArmor profiles.
|
# We cannot mount them directly read-only, because that would prevent loading AppArmor profiles.
|
||||||
lxc.mount.entry = proc {{escapeFstabSpaces $ROOTFS}}/proc proc nosuid,nodev,noexec 0 0
|
lxc.mount.entry = proc {{escapeFstabSpaces $ROOTFS}}/proc proc nosuid,nodev,noexec 0 0
|
||||||
lxc.mount.entry = sysfs {{escapeFstabSpaces $ROOTFS}}/sys sysfs nosuid,nodev,noexec 0 0
|
lxc.mount.entry = sysfs {{escapeFstabSpaces $ROOTFS}}/sys sysfs nosuid,nodev,noexec 0 0
|
||||||
|
{{if .AppArmor}}
|
||||||
|
lxc.aa_profile = unconfined
|
||||||
|
{{end}}
|
||||||
|
{{else}}
|
||||||
|
# In non-privileged mode, lxc will automatically mount /proc and /sys in readonly mode
|
||||||
|
# for security. See: http://man7.org/linux/man-pages/man5/lxc.container.conf.5.html
|
||||||
|
lxc.mount.auto = proc sys
|
||||||
|
{{if .AppArmor}}
|
||||||
|
lxc.aa_profile = .AppArmorProfile
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{if .ProcessConfig.Tty}}
|
{{if .ProcessConfig.Tty}}
|
||||||
lxc.mount.entry = {{.ProcessConfig.Console}} {{escapeFstabSpaces $ROOTFS}}/dev/console none bind,rw 0 0
|
lxc.mount.entry = {{.ProcessConfig.Console}} {{escapeFstabSpaces $ROOTFS}}/dev/console none bind,rw 0 0
|
||||||
|
@ -85,14 +96,6 @@ lxc.mount.entry = {{$value.Source}} {{escapeFstabSpaces $ROOTFS}}/{{escapeFstabS
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if .ProcessConfig.Privileged}}
|
|
||||||
{{if .AppArmor}}
|
|
||||||
lxc.aa_profile = unconfined
|
|
||||||
{{else}}
|
|
||||||
# Let AppArmor normal confinement take place (i.e., not unconfined)
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
# limits
|
# limits
|
||||||
{{if .Resources}}
|
{{if .Resources}}
|
||||||
{{if .Resources.Memory}}
|
{{if .Resources.Memory}}
|
||||||
|
|
Loading…
Reference in a new issue