Skip to content

Commit

Permalink
checkpoint: resolve symlink for external bind mount(fix ci broken)
Browse files Browse the repository at this point in the history
runc resolves symlink before doing bind mount. So
we should save original path while formatting CriuReq for
dump and restore.

"checkpoint: resolve symlink for external bind mount" is merged as
da22625(PR 2902) previously. And reverted
in commit 70fdc05(PR 3043) duo to behavior changes
caused by commit 0ca91f4(Fixes: CVE-2021-30465)

Signed-off-by: Liu Hua <[email protected]>
  • Loading branch information
Liu Hua committed Jul 21, 2021
1 parent 6e210a1 commit dde9bbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,9 @@ const descriptorsFilename = "descriptors.json"

func (c *linuxContainer) addCriuDumpMount(req *criurpc.CriuReq, m *configs.Mount) {
mountDest := strings.TrimPrefix(m.Destination, c.config.Rootfs)
if dest, err := securejoin.SecureJoin(c.config.Rootfs, mountDest); err == nil {
mountDest = dest[len(c.config.Rootfs):]
}
extMnt := &criurpc.ExtMountMap{
Key: proto.String(mountDest),
Val: proto.String(mountDest),
Expand Down Expand Up @@ -1134,6 +1137,9 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error {

func (c *linuxContainer) addCriuRestoreMount(req *criurpc.CriuReq, m *configs.Mount) {
mountDest := strings.TrimPrefix(m.Destination, c.config.Rootfs)
if dest, err := securejoin.SecureJoin(c.config.Rootfs, mountDest); err == nil {
mountDest = dest[len(c.config.Rootfs):]
}
extMnt := &criurpc.ExtMountMap{
Key: proto.String(mountDest),
Val: proto.String(m.Source),
Expand Down
13 changes: 12 additions & 1 deletion tests/integration/checkpoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@ function simple_cr() {
done
}

@test "checkpoint and restore " {
@test "checkpoint and restore" {
simple_cr
}

@test "checkpoint and restore (bind mount, destination is symlink)" {
mkdir -p rootfs/real/conf
ln -s /real/conf rootfs/conf
update_config ' .mounts += [{
source: ".",
destination: "/conf",
options: ["bind"]
}]'
simple_cr
}

Expand Down

0 comments on commit dde9bbf

Please sign in to comment.