Skip to content

libcontainer: rename dmz -> exeseal #4643

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions contrib/cmd/memfd-bind/memfd-bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"strings"
"time"

"github.com/opencontainers/runc/libcontainer/dmz"
"github.com/opencontainers/runc/libcontainer/exeseal"

"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand Down Expand Up @@ -101,7 +101,7 @@ func cleanup(path string) error {
return nil
}

// memfdClone is a memfd-only implementation of dmz.CloneBinary.
// memfdClone is a memfd-only implementation of exeseal.CloneBinary.
func memfdClone(path string) (*os.File, error) {
binFile, err := os.Open(path)
if err != nil {
Expand All @@ -113,7 +113,7 @@ func memfdClone(path string) (*os.File, error) {
return nil, fmt.Errorf("checking %s size: %w", path, err)
}
size := stat.Size()
memfd, sealFn, err := dmz.Memfd("/proc/self/exe")
memfd, sealFn, err := exeseal.Memfd("/proc/self/exe")
if err != nil {
return nil, fmt.Errorf("creating memfd failed: %w", err)
}
Expand All @@ -126,7 +126,7 @@ func memfdClone(path string) (*os.File, error) {
if err := sealFn(&memfd); err != nil {
return nil, fmt.Errorf("could not seal fd: %w", err)
}
if !dmz.IsCloned(memfd) {
if !exeseal.IsCloned(memfd) {
return nil, fmt.Errorf("cloned memfd is not properly sealed")
}
return memfd, nil
Expand Down
8 changes: 4 additions & 4 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/dmz"
"github.com/opencontainers/runc/libcontainer/exeseal"
"github.com/opencontainers/runc/libcontainer/intelrdt"
"github.com/opencontainers/runc/libcontainer/system"
"github.com/opencontainers/runc/libcontainer/utils"
Expand Down Expand Up @@ -496,7 +496,7 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
exePath string
safeExe *os.File
)
if dmz.IsSelfExeCloned() {
if exeseal.IsSelfExeCloned() {
// /proc/self/exe is already a cloned binary -- no need to do anything
logrus.Debug("skipping binary cloning -- /proc/self/exe is already cloned!")
// We don't need to use /proc/thread-self here because the exe mm of a
Expand All @@ -505,13 +505,13 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
exePath = "/proc/self/exe"
} else {
var err error
safeExe, err = dmz.CloneSelfExe(c.stateDir)
safeExe, err = exeseal.CloneSelfExe(c.stateDir)
if err != nil {
return nil, fmt.Errorf("unable to create safe /proc/self/exe clone for runc init: %w", err)
}
exePath = "/proc/self/fd/" + strconv.Itoa(int(safeExe.Fd()))
p.clonedExes = append(p.clonedExes, safeExe)
logrus.Debug("runc-dmz: using /proc/self/exe clone") // used for tests
logrus.Debug("runc exeseal: using /proc/self/exe clone") // used for tests
}

cmd := exec.Command(exePath, "init")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dmz
package exeseal

import (
"errors"
Expand Down Expand Up @@ -224,7 +224,7 @@ func CloneSelfExe(tmpDir string) (*os.File, error) {
// around ~60% overhead during container startup.
overlayFile, err := sealedOverlayfs("/proc/self/exe", tmpDir)
if err == nil {
logrus.Debug("runc-dmz: using overlayfs for sealed /proc/self/exe") // used for tests
logrus.Debug("runc exeseal: using overlayfs for sealed /proc/self/exe") // used for tests
return overlayFile, nil
}
logrus.WithError(err).Debugf("could not use overlayfs for /proc/self/exe sealing -- falling back to making a temporary copy")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dmz
package exeseal

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion libcontainer/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type Process struct {
// ExtraFiles specifies additional open files to be inherited by the process.
ExtraFiles []*os.File

// Open handles to cloned binaries -- see dmz.CloneSelfExe for more details.
// Open handles to cloned binaries -- see exeseal.CloneSelfExe for more details.
clonedExes []*os.File

// Initial size for the console.
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ function teardown() {
runc --debug run test_hello
[ "$status" -eq 0 ]
[[ "$output" = *"Hello World"* ]]
[[ "$output" = *"runc-dmz: using /proc/self/exe clone"* ]]
[[ "$output" = *"runc exeseal: using /proc/self/exe clone"* ]]
# runc will use fsopen("overlay") if it can.
if can_fsopen overlay; then
[[ "$output" = *"runc-dmz: using overlayfs for sealed /proc/self/exe"* ]]
[[ "$output" = *"runc exeseal: using overlayfs for sealed /proc/self/exe"* ]]
fi
}

Expand Down