-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ptsname() for big-endian architectures (again) #51
Conversation
This reverts commit f1b333f (Use Ioctl{SetPointerInt,GetInt} from golang.org/x/sys/unix on linux), changing the code to what it was after commit dbd69c5. This fixes a blocker bug on s390. The original description from commit dbd69c5 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 <[email protected]> Cc: Tobias Klauser <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
It would be cool to have this tested on s390, alas with Travis gone I don't know how. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for messing this up and thanks for the fix.
was able to test this patch with the unit tests on an s390x system and it works. Issue before testing with this patch:
After applying patch:
|
Could you add comment lines in the source to explain the original issue, LGTM then |
... with a pointer to a detailed explanation. Signed-off-by: Kir Kolyshkin <[email protected]>
Added a second commit. The full explanation is long, so I just warn and refer to an earlier commit which explains it. PTAL @AkihiroSuda @estesp @dmcgowan |
Ideally we need an 1.0.2 release after merging this, as this bug is a regression in 1.0.1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is to include containerd/console#51 Fixes: opencontainers#2896 Signed-off-by: Kir Kolyshkin <[email protected]>
This is to include containerd/console#51 Fixes: opencontainers#2896 Signed-off-by: Kir Kolyshkin <[email protected]>
This is to include containerd/console#51. Fixes: opencontainers#2896 Signed-off-by: Kir Kolyshkin <[email protected]>
This is to include containerd/console#51. Fixes: opencontainers/runc#2896 Signed-off-by: Kir Kolyshkin <[email protected]>
Use uint32 instead of uint (64-bit in Go on s390x) to store the return value of the TIOCGPTN syscall. This is to avoid the 32-bit value from being stored into a 64-bit buffer and get left-shifted by 32 when dereferencing, turning what should be /dev/pts/1 to /dev/pts/4294967296 on big-endian architectures such as s390x. Special thanks to the explanation and a similar bug fix provided at containerd/console#51
Use uint32 instead of uint (64-bit in Go on s390x) to store the return value of the TIOCGPTN syscall. This is to avoid the 32-bit value from being stored into a 64-bit buffer and get left-shifted by 32 when dereferencing, turning what should be /dev/pts/1 to /dev/pts/4294967296 on big-endian architectures such as s390x. Special thanks to the explanation and a similar bug fix provided at containerd/console#51
This reverts commit f1b333f (Use Ioctl{SetPointerInt,GetInt} from
golang.org/x/sys/unix on linux), changing the code to what it was after
commit dbd69c5. This fixes a blocker bug on s390 [1].
The original description from commit dbd69c5 follows:
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1941815
This is a regression in v1.0.1, so ideally we need a new 1.0.2 release after merging this.