mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
utils: remove unneeded EnsureProcHandle
All of the callers of EnsureProcHandle now use filepath-securejoin's ProcThreadSelf to get a file handle, which has much stricter verification to avoid procfs attacks than EnsureProcHandle's very simplistic filesystem type check. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -19,18 +19,6 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// EnsureProcHandle returns whether or not the given file handle is on procfs.
|
||||
func EnsureProcHandle(fh *os.File) error {
|
||||
var buf unix.Statfs_t
|
||||
if err := unix.Fstatfs(int(fh.Fd()), &buf); err != nil {
|
||||
return fmt.Errorf("ensure %s is on procfs: %w", fh.Name(), err)
|
||||
}
|
||||
if buf.Type != unix.PROC_SUPER_MAGIC {
|
||||
return fmt.Errorf("%s is not on procfs", fh.Name())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
haveCloseRangeCloexecBool bool
|
||||
haveCloseRangeCloexecOnce sync.Once
|
||||
@@ -67,12 +55,6 @@ func fdRangeFrom(minFd int, fn fdFunc) error {
|
||||
defer closer()
|
||||
defer fdDir.Close()
|
||||
|
||||
// NOTE: This is not really necessary since securejoin.ProcThreadSelf
|
||||
// verifies this in a far stricter sense than EnsureProcHandle.
|
||||
if err := EnsureProcHandle(fdDir); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fdList, err := fdDir.Readdirnames(-1)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user