Skip to content
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
10 changes: 6 additions & 4 deletions libcontainer/console_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ func checkPtmxHandle(ptmx *os.File) error {
if stat.Ino != PTMX_INO {
return fmt.Errorf("ptmx handle has wrong inode number: %v", stat.Ino)
}
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || stat.Rdev != unix.Mkdev(PTMX_MAJOR, PTMX_MINOR) {
rdev := uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on MIPS.
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || rdev != unix.Mkdev(PTMX_MAJOR, PTMX_MINOR) {
return fmt.Errorf("ptmx handle is not a real char ptmx device: ftype %#x %d:%d",
stat.Mode&unix.S_IFMT, unix.Major(stat.Rdev), unix.Minor(stat.Rdev))
stat.Mode&unix.S_IFMT, unix.Major(rdev), unix.Minor(rdev))
}
return nil
})
Expand Down Expand Up @@ -79,9 +80,10 @@ func getPtyPeer(pty console.Console, unsafePeerPath string, flags int) (*os.File
if statfs.Type != unix.DEVPTS_SUPER_MAGIC {
return fmt.Errorf("pty peer handle is not on a real devpts mount: super magic is %#x", statfs.Type)
}
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || stat.Rdev != wantPeerDev {
rdev := uint64(stat.Rdev) //nolint:unconvert // Rdev is uint32 on MIPS.
if stat.Mode&unix.S_IFMT != unix.S_IFCHR || rdev != wantPeerDev {
return fmt.Errorf("pty peer handle is not the real char device for pty %d: ftype %#x %d:%d",
peerNum, stat.Mode&unix.S_IFMT, unix.Major(stat.Rdev), unix.Minor(stat.Rdev))
peerNum, stat.Mode&unix.S_IFMT, unix.Major(rdev), unix.Minor(rdev))
}
return nil
}); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions libcontainer/rootfs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1047,10 +1047,10 @@ func mknodDevice(destDir *os.File, destName string, node *devices.Device) error
node.Type, node.Path,
stat.Mode&unix.S_IFMT, fileMode&unix.S_IFMT)
}
if stat.Rdev != dev {
if rdev := uint64(stat.Rdev); rdev != dev { //nolint:unconvert // Rdev is uint32 on MIPS.
return fmt.Errorf("new %c device inode %s has incorrect major:minor: %d:%d doesn't match expected %d:%d",
node.Type, node.Path,
unix.Major(stat.Rdev), unix.Minor(stat.Rdev),
unix.Major(rdev), unix.Minor(rdev),
unix.Major(dev), unix.Minor(dev))
}
return nil
Expand Down Expand Up @@ -1321,7 +1321,8 @@ func remountReadonly(m *configs.Mount) error {
}

func isDevNull(st *unix.Stat_t) bool {
return st.Mode&unix.S_IFMT == unix.S_IFCHR && st.Rdev == unix.Mkdev(1, 3)
//nolint:unconvert // Rdev is uint32 on MIPS.
return st.Mode&unix.S_IFMT == unix.S_IFCHR && uint64(st.Rdev) == unix.Mkdev(1, 3)
}

func verifyDevNull(f *os.File) error {
Expand Down