Skip to content

Commit 559bd4e

Browse files
committed
libcontainer: rename dmz -> exeseal
The "dmz" name was originally used because the libcontainer/dmz package housed the runc-dmz binary, but since we removed it in commit 871057d ("drop runc-dmz solution according to overlay solution") the name is an anachronism and we should just give it a more self-explanatory name. So, call it libcontainer/exeseal because the purpose of the package is to provide tools to seal /proc/self/exe against attackers. Signed-off-by: Aleksa Sarai <[email protected]>
1 parent ef9830a commit 559bd4e

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

contrib/cmd/memfd-bind/memfd-bind.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"strings"
2828
"time"
2929

30-
"github.com/opencontainers/runc/libcontainer/dmz"
30+
"github.com/opencontainers/runc/libcontainer/exeseal"
3131

3232
"github.com/sirupsen/logrus"
3333
"github.com/urfave/cli"
@@ -101,7 +101,7 @@ func cleanup(path string) error {
101101
return nil
102102
}
103103

104-
// memfdClone is a memfd-only implementation of dmz.CloneBinary.
104+
// memfdClone is a memfd-only implementation of exeseal.CloneBinary.
105105
func memfdClone(path string) (*os.File, error) {
106106
binFile, err := os.Open(path)
107107
if err != nil {
@@ -113,7 +113,7 @@ func memfdClone(path string) (*os.File, error) {
113113
return nil, fmt.Errorf("checking %s size: %w", path, err)
114114
}
115115
size := stat.Size()
116-
memfd, sealFn, err := dmz.Memfd("/proc/self/exe")
116+
memfd, sealFn, err := exeseal.Memfd("/proc/self/exe")
117117
if err != nil {
118118
return nil, fmt.Errorf("creating memfd failed: %w", err)
119119
}
@@ -126,7 +126,7 @@ func memfdClone(path string) (*os.File, error) {
126126
if err := sealFn(&memfd); err != nil {
127127
return nil, fmt.Errorf("could not seal fd: %w", err)
128128
}
129-
if !dmz.IsCloned(memfd) {
129+
if !exeseal.IsCloned(memfd) {
130130
return nil, fmt.Errorf("cloned memfd is not properly sealed")
131131
}
132132
return memfd, nil

libcontainer/container_linux.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
"github.com/opencontainers/runc/libcontainer/cgroups"
2424
"github.com/opencontainers/runc/libcontainer/configs"
25-
"github.com/opencontainers/runc/libcontainer/dmz"
25+
"github.com/opencontainers/runc/libcontainer/exeseal"
2626
"github.com/opencontainers/runc/libcontainer/intelrdt"
2727
"github.com/opencontainers/runc/libcontainer/system"
2828
"github.com/opencontainers/runc/libcontainer/utils"
@@ -496,7 +496,7 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
496496
exePath string
497497
safeExe *os.File
498498
)
499-
if dmz.IsSelfExeCloned() {
499+
if exeseal.IsSelfExeCloned() {
500500
// /proc/self/exe is already a cloned binary -- no need to do anything
501501
logrus.Debug("skipping binary cloning -- /proc/self/exe is already cloned!")
502502
// We don't need to use /proc/thread-self here because the exe mm of a
@@ -505,13 +505,13 @@ func (c *Container) newParentProcess(p *Process) (parentProcess, error) {
505505
exePath = "/proc/self/exe"
506506
} else {
507507
var err error
508-
safeExe, err = dmz.CloneSelfExe(c.stateDir)
508+
safeExe, err = exeseal.CloneSelfExe(c.stateDir)
509509
if err != nil {
510510
return nil, fmt.Errorf("unable to create safe /proc/self/exe clone for runc init: %w", err)
511511
}
512512
exePath = "/proc/self/fd/" + strconv.Itoa(int(safeExe.Fd()))
513513
p.clonedExes = append(p.clonedExes, safeExe)
514-
logrus.Debug("runc-dmz: using /proc/self/exe clone") // used for tests
514+
logrus.Debug("runc exeseal: using /proc/self/exe clone") // used for tests
515515
}
516516

517517
cmd := exec.Command(exePath, "init")

libcontainer/dmz/cloned_binary_linux.go renamed to libcontainer/exeseal/cloned_binary_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dmz
1+
package exeseal
22

33
import (
44
"errors"
@@ -224,7 +224,7 @@ func CloneSelfExe(tmpDir string) (*os.File, error) {
224224
// around ~60% overhead during container startup.
225225
overlayFile, err := sealedOverlayfs("/proc/self/exe", tmpDir)
226226
if err == nil {
227-
logrus.Debug("runc-dmz: using overlayfs for sealed /proc/self/exe") // used for tests
227+
logrus.Debug("runc exeseal: using overlayfs for sealed /proc/self/exe") // used for tests
228228
return overlayFile, nil
229229
}
230230
logrus.WithError(err).Debugf("could not use overlayfs for /proc/self/exe sealing -- falling back to making a temporary copy")

libcontainer/dmz/overlayfs_linux.go renamed to libcontainer/exeseal/overlayfs_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dmz
1+
package exeseal
22

33
import (
44
"fmt"

libcontainer/process.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type Process struct {
5252
// ExtraFiles specifies additional open files to be inherited by the process.
5353
ExtraFiles []*os.File
5454

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

5858
// Initial size for the console.

tests/integration/run.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ function teardown() {
131131
runc --debug run test_hello
132132
[ "$status" -eq 0 ]
133133
[[ "$output" = *"Hello World"* ]]
134-
[[ "$output" = *"runc-dmz: using /proc/self/exe clone"* ]]
134+
[[ "$output" = *"runc exeseal: using /proc/self/exe clone"* ]]
135135
# runc will use fsopen("overlay") if it can.
136136
if can_fsopen overlay; then
137-
[[ "$output" = *"runc-dmz: using overlayfs for sealed /proc/self/exe"* ]]
137+
[[ "$output" = *"runc exeseal: using overlayfs for sealed /proc/self/exe"* ]]
138138
fi
139139
}
140140

0 commit comments

Comments
 (0)