Fix ptsname() for big-endian architectures (again)#51
Merged
crosbymichael merged 2 commits intocontainerd:masterfrom Apr 8, 2021
Merged
Fix ptsname() for big-endian architectures (again)#51crosbymichael merged 2 commits intocontainerd:masterfrom
crosbymichael merged 2 commits intocontainerd:masterfrom
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 <peter.morjan@de.ibm.com> Cc: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Contributor
Author
Contributor
Author
|
It would be cool to have this tested on s390, alas with Travis gone I don't know how. |
tklauser
approved these changes
Apr 6, 2021
Contributor
tklauser
left a comment
There was a problem hiding this comment.
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: |
Member
|
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 <kolyshkin@gmail.com>
Contributor
Author
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 |
AkihiroSuda
approved these changes
Apr 8, 2021
Contributor
Author
|
Ideally we need an 1.0.2 release after merging this, as this bug is a regression in 1.0.1. |
crosbymichael
approved these changes
Apr 8, 2021
kolyshkin
added a commit
to kolyshkin/runc
that referenced
this pull request
Apr 8, 2021
This is to include containerd/console#51 Fixes: opencontainers#2896 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin
added a commit
to kolyshkin/runc
that referenced
this pull request
Apr 8, 2021
This is to include containerd/console#51 Fixes: opencontainers#2896 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin
added a commit
to kolyshkin/runc
that referenced
this pull request
Apr 12, 2021
This is to include containerd/console#51. Fixes: opencontainers#2896 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
kolyshkin
added a commit
to kolyshkin/runc-1
that referenced
this pull request
Apr 15, 2021
This is to include containerd/console#51. Fixes: opencontainers/runc#2896 Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This was referenced Apr 15, 2021
anthonyfok
added a commit
to anthonyfok/go-internal
that referenced
this pull request
Feb 16, 2024
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
mvdan
pushed a commit
to rogpeppe/go-internal
that referenced
this pull request
Feb 16, 2024
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.