Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15
runc.21021
Fix-ptsname-for-big-endian-architectures-again....
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File Fix-ptsname-for-big-endian-architectures-again.patch of Package runc.21021
From a2612510eb095c6db04e056a0fc6f892a35f518a Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin <kolyshkin@gmail.com> Date: Tue, 6 Apr 2021 10:45:51 -0700 Subject: [PATCH 1/2] Fix ptsname() for big-endian architectures (again) This reverts commit f1b333f2c5050f (Use Ioctl{SetPointerInt,GetInt} from golang.org/x/sys/unix on linux), changing the code to what it was after commit dbd69c59b81. This fixes a blocker bug on s390. The original description from commit dbd69c59b81 follows: On big-endian architectures unix.IoctlGetInt() leads to a wrong result because a 32 bit value is stored into a 64 bit buffer. When dereferencing the result is left shifted by 32. Without this patch ptsname() returns a wrong path from the second pty onwards. To protect syscalls against re-arranging by the GC the conversion from unsafe.Pointer to uintptr must occur in the Syscall expression itself. See the documentation of the unsafe package for details. Cc: Peter Morjan <peter.morjan@de.ibm.com> Cc: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> --- tc_linux.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tc_linux.go b/tc_linux.go index 75f8694..1bdd68e 100644 --- a/vendor/github.com/containerd/console/tc_linux.go +++ b/vendor/github.com/containerd/console/tc_linux.go @@ -19,6 +19,7 @@ package console import ( "fmt" "os" + "unsafe" "golang.org/x/sys/unix" ) @@ -31,13 +32,17 @@ const ( // unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. // unlockpt should be called before opening the slave side of a pty. func unlockpt(f *os.File) error { - return unix.IoctlSetPointerInt(int(f.Fd()), unix.TIOCSPTLCK, 0) + var u int32 + if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))); err != 0 { + return err + } + return nil } // ptsname retrieves the name of the first available pts for the given master. func ptsname(f *os.File) (string, error) { - u, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN) - if err != nil { + var u uint32 + if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&u))); err != 0 { return "", err } return fmt.Sprintf("/dev/pts/%d", u), nil From 073d1657b8570d499c8cb0a31742209ae93cf7f0 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin <kolyshkin@gmail.com> Date: Wed, 7 Apr 2021 11:38:55 -0700 Subject: [PATCH 2/2] tc_linux.go: add a warning to not change the code ... with a pointer to a detailed explanation. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> --- tc_linux.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tc_linux.go b/tc_linux.go index 1bdd68e..7d552ea 100644 --- a/vendor/github.com/containerd/console/tc_linux.go +++ b/vendor/github.com/containerd/console/tc_linux.go @@ -33,6 +33,7 @@ const ( // unlockpt should be called before opening the slave side of a pty. func unlockpt(f *os.File) error { var u int32 + // XXX do not use unix.IoctlSetPointerInt here, see commit dbd69c59b81. if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))); err != 0 { return err } @@ -42,6 +43,7 @@ func unlockpt(f *os.File) error { // ptsname retrieves the name of the first available pts for the given master. func ptsname(f *os.File) (string, error) { var u uint32 + // XXX do not use unix.IoctlGetInt here, see commit dbd69c59b81. if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&u))); err != 0 { return "", err }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor