Skip to content

Commit

Permalink
proc: do not export internal PROC_ constants
Browse files Browse the repository at this point in the history
Fixes: 54905ce ("initial safe MkdirAll and MkdirAllHandle implementations")
Signed-off-by: Aleksa Sarai <[email protected]>
  • Loading branch information
cyphar committed Jul 10, 2024
1 parent ce95b91 commit fbc8097
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions procfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ func fstatfs(f *os.File) (unix.Statfs_t, error) {
// The kernel guarantees that the root inode of a procfs mount has an
// f_type of PROC_SUPER_MAGIC and st_ino of PROC_ROOT_INO.
const (
PROC_SUPER_MAGIC = 0x9fa0
PROC_ROOT_INO = 1
procSuperMagic = 0x9fa0 // PROC_SUPER_MAGIC
procRootIno = 1 // PROC_ROOT_INO
)

func verifyProcRoot(procRoot *os.File) error {
if statfs, err := fstatfs(procRoot); err != nil {
return err
} else if statfs.Type != PROC_SUPER_MAGIC {
} else if statfs.Type != procSuperMagic {
return fmt.Errorf("%w: incorrect procfs root filesystem type 0x%x", errUnsafeProcfs, statfs.Type)
}
if stat, err := fstat(procRoot); err != nil {
return err
} else if stat.Ino != PROC_ROOT_INO {
} else if stat.Ino != procRootIno {
return fmt.Errorf("%w: incorrect procfs root inode number %d", errUnsafeProcfs, stat.Ino)
}
return nil
Expand Down Expand Up @@ -306,7 +306,7 @@ func procThreadSelf(procRoot *os.File, subpath string) (_ *os.File, _ procThread
// aren't on the wrong filesystem here.
if statfs, err := fstatfs(handle); err != nil {
return nil, nil, err
} else if statfs.Type != PROC_SUPER_MAGIC {
} else if statfs.Type != procSuperMagic {
return nil, nil, fmt.Errorf("%w: incorrect /proc/self/fd filesystem type 0x%x", errUnsafeProcfs, statfs.Type)
}
}
Expand Down

0 comments on commit fbc8097

Please sign in to comment.