-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
internal/poll: invalid uintptr conversion in call to windows.SetFileInformationByHandle
#58933
Comments
Found new dashboard test flakes for:
2023-03-07 22:05 windows-amd64-race go@99914db5 os.TestChmod (log)
|
The parameter is incorrect.
on Windows
(CC @golang/windows) |
I just looked at the go/src/internal/poll/fd_windows.go Lines 1027 to 1030 in 618fb4a
Our code appears to set We should extend Alex. |
Change https://go.dev/cl/490855 mentions this issue: |
Agree. If we rely on an undocumented behavior then we should at least test our assumptions. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Just saw one of these on a
|
Oh, yeah, here's a bug, at least: The third argument violates the That can cause the buffer to be garbage-collected and reused while the call is in progress, leading to arbitrary corruption of its contents. |
The parameter is incorrect.
on Windowswindows.SetFileInformationByHandle
Change https://go.dev/cl/549256 mentions this issue: |
…ndle Also fix its call site in internal/poll to pass the length of the actual buffer instead of an unrelated variable, and update the definition of FILE_BASIC_INFO to match the documented field types and add padding that is empirically needed on the 386 architecture. Passing a pointer to a Go-allocated buffer as type uintptr violates the unsafe.Pointer conversion rules, which allow such a conversion only in the call expression itself for a call to syscall.Syscall or equivalent. That can allow the buffer to be corrupted arbitrarily if the Go runtime happens to garbage-collect it while the call to SetFileInformationByHandle is in progress. The Microsoft documentation for SetFileInformationByHandle specifies its third argument type as LPVOID, which corresponds to Go's unsafe.Pointer, not uintptr. Fixes golang#58933 (maybe). Change-Id: If577b57adea9922f5fcca55e46030c703d8f035c Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/549256 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Quim Muntal <[email protected]> Reviewed-by: Alex Brainman <[email protected]>
@gopherbot, please backport to Go 1.21. This was a use-after-free bug and could cause arbitrary heap corruption in programs that call |
Backport issue(s) opened: #65882 (for 1.21). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/566155 mentions this issue: |
…f SetFileInformationByHandle Also fix its call site in internal/poll to pass the length of the actual buffer instead of an unrelated variable, and update the definition of FILE_BASIC_INFO to match the documented field types and add padding that is empirically needed on the 386 architecture. Passing a pointer to a Go-allocated buffer as type uintptr violates the unsafe.Pointer conversion rules, which allow such a conversion only in the call expression itself for a call to syscall.Syscall or equivalent. That can allow the buffer to be corrupted arbitrarily if the Go runtime happens to garbage-collect it while the call to SetFileInformationByHandle is in progress. The Microsoft documentation for SetFileInformationByHandle specifies its third argument type as LPVOID, which corresponds to Go's unsafe.Pointer, not uintptr. Fixes #65882. Updates #58933. Change-Id: If577b57adea9922f5fcca55e46030c703d8f035c Cq-Include-Trybots: luci.golang.try:go1.21-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/549256 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Quim Muntal <[email protected]> Reviewed-by: Alex Brainman <[email protected]> (cherry picked from commit a709724) Reviewed-on: https://go-review.googlesource.com/c/go/+/566155 Reviewed-by: Bryan Mills <[email protected]>
Issue created automatically to collect these failures.
Example (log):
— watchflakes
The text was updated successfully, but these errors were encountered: