mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
runc rc95 contains a fix for CVE-2021-30465. runc rc94 provides fixes and improvements. One notable change is cgroup manager's Set now accept Resources rather than Cgroup (see https://github.com/opencontainers/runc/pull/2906). Modify the code accordingly. Also update runc dependencies (as hinted by hack/lint-depdendencies.sh): github.com/cilium/ebpf v0.5.0 github.com/containerd/console v1.0.2 github.com/coreos/go-systemd/v22 v22.3.1 github.com/godbus/dbus/v5 v5.0.4 github.com/moby/sys/mountinfo v0.4.1 golang.org/x/sys v0.0.0-20210426230700-d19ff857e887 github.com/google/go-cmp v0.5.4 github.com/kr/pretty v0.2.1 github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
45 lines
1021 B
Go
45 lines
1021 B
Go
package internal
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/cilium/ebpf/internal/unix"
|
|
)
|
|
|
|
func Pin(currentPath, newPath string, fd *FD) error {
|
|
if newPath == "" {
|
|
return errors.New("given pinning path cannot be empty")
|
|
}
|
|
if currentPath == newPath {
|
|
return nil
|
|
}
|
|
if currentPath == "" {
|
|
return BPFObjPin(newPath, fd)
|
|
}
|
|
var err error
|
|
// Renameat2 is used instead of os.Rename to disallow the new path replacing
|
|
// an existing path.
|
|
if err = unix.Renameat2(unix.AT_FDCWD, currentPath, unix.AT_FDCWD, newPath, unix.RENAME_NOREPLACE); err == nil {
|
|
// Object is now moved to the new pinning path.
|
|
return nil
|
|
}
|
|
if !os.IsNotExist(err) {
|
|
return fmt.Errorf("unable to move pinned object to new path %v: %w", newPath, err)
|
|
}
|
|
// Internal state not in sync with the file system so let's fix it.
|
|
return BPFObjPin(newPath, fd)
|
|
}
|
|
|
|
func Unpin(pinnedPath string) error {
|
|
if pinnedPath == "" {
|
|
return nil
|
|
}
|
|
err := os.Remove(pinnedPath)
|
|
if err == nil || os.IsNotExist(err) {
|
|
return nil
|
|
}
|
|
return err
|
|
}
|