mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
libpod: mount safely subpaths
add a function to securely mount a subpath inside a volume. We cannot trust that the subpath is safe since it is beneath a volume that could be controlled by a separate container. To avoid TOCTOU races between when we check the subpath and when the OCI runtime mounts it, we open the subpath, validate it, bind mount to a temporary directory and use it instead of the original path. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -1035,10 +1035,11 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
|
||||
}
|
||||
|
||||
// Generate the OCI newSpec
|
||||
newSpec, err := c.generateSpec(ctx)
|
||||
newSpec, cleanupFunc, err := c.generateSpec(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer cleanupFunc()
|
||||
|
||||
// Make sure the workdir exists while initializing container
|
||||
if err := c.resolveWorkDir(); err != nil {
|
||||
|
Reference in New Issue
Block a user