diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-02-02 10:03:13 +0100 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2022-02-03 14:50:04 -0500 |
commit | 06821627fb6fde0e55d70263469394a0a5299899 (patch) | |
tree | 27967924ec8f499bbeaf51542b0ac0ea2a4861c1 /libpod | |
parent | 44cd232befd81b7efff0b2c1256fbf8d2490649d (diff) | |
download | podman-06821627fb6fde0e55d70263469394a0a5299899.tar.gz podman-06821627fb6fde0e55d70263469394a0a5299899.tar.bz2 podman-06821627fb6fde0e55d70263469394a0a5299899.zip |
libpod: enforce noexec,nosuid,nodev for /dev/shm
these mount flags are already used for the /dev/shm mount on the host,
but they are not set for the bind mount itself.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_internal_linux.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 5cc2a78fc..86d8586d0 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -510,6 +510,9 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) { if c.IsReadOnly() && dstPath != "/dev/shm" { newMount.Options = append(newMount.Options, "ro", "nosuid", "noexec", "nodev") } + if dstPath == "/dev/shm" && c.state.BindMounts["/dev/shm"] == c.config.ShmDir { + newMount.Options = append(newMount.Options, "nosuid", "noexec", "nodev") + } if !MountExists(g.Mounts(), dstPath) { g.AddMount(newMount) } else { @@ -1570,6 +1573,9 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti if c.IsReadOnly() && dstPath != "/dev/shm" { newMount.Options = append(newMount.Options, "ro", "nosuid", "noexec", "nodev") } + if dstPath == "/dev/shm" && c.state.BindMounts["/dev/shm"] == c.config.ShmDir { + newMount.Options = append(newMount.Options, "nosuid", "noexec", "nodev") + } if !MountExists(g.Mounts(), dstPath) { g.AddMount(newMount) } |