-
Notifications
You must be signed in to change notification settings - Fork 18k
x/crypto/sha3: unsafe pointer conversion #37644
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
Comments
Possibly related to #35173 |
Maybe someone on the Go team could provide some more clarity:
|
This is definitely related to some of those issues, but I suspect it is its own thing.
The code guarantees that It may be worth adding the pattern above as a special case. (@mdempsky: did we not already do that?) |
The issue here is that it's creating an unaligned pointer: checkptr requires that It looks like that code is only used on x86 and ppc64le, so it's probably fine to annotate |
Indeed, you're right, it's alignment not length. |
@mdempsky, if pointers to unaligned data really are benign on x86 and ppc64le, then arguably A |
Not a dup but #19367 would make everyone's life much easier. |
@bcmills My rationale is that:
I'm open to being convinced otherwise though. @OneOfOne The issue here is alignment, not size, of the slice. unsafe.Slice wouldn't help with that. |
If unaligned pointers to integer types are not unambiguously allowed, then On the other hand, if unaligned pointers are safe on this architecture, they should not result in an error on this architecture. If we allow false-positives in race-mode checks, people will start ignoring (or annotating away) actual race-mode failures on the (mistaken) theory that they're false-positives. |
This is way out of my league, but just my two cents - some large modules like go-ethereum are affected by this, so their downstreams (like me) are unable to move to Go 1.14 if they want to keep using |
I think the immediate fix/workaround is to add We can continue discussing whether that's the most appropriate fix afterwards. |
See also #37298. |
Upstream issue: golang/go#37644
Change https://golang.org/cl/222855 mentions this issue: |
It is unclear whether unaligned reads should be allowed, or if they are even actually a good idea here. However, while we figure that out, we should un-break 'go test -race' for users of this package. Updates golang/go#37644 Updates golang/go#37298 Updates golang/go#37715 Updates golang/go#34972 Updates golang/go#35128 Change-Id: I088f5703023e4f05ee274a6753e925973f12ac1b Reviewed-on: https://go-review.googlesource.com/c/crypto/+/222855 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
The |
Thanks @bcmills . That sounds reasonable to me. |
Upstream issue: golang/go#37644
After add -race flag when test, got this error in old sha3 library: x/crypto: fatal error: checkptr: unsafe pointer conversion (golang/go#37644) Since they have already fixed the issue, it's better to switch to official crypto library.
After add -race flag when test, got this error in old sha3 library: x/crypto: fatal error: checkptr: unsafe pointer conversion (golang/go#37644) Since they have already fixed the issue, it's better to switch to official crypto library.
Add cfg.SaveToFile() Add ParseMediaType Update config server, todo: remove yaml config file Update config server Add go-playground/validator Remove diode_go_client/crypto/sha3 After add -race flag when test, got this error in old sha3 library: x/crypto: fatal error: checkptr: unsafe pointer conversion (golang/go#37644) Since they have already fixed the issue, it's better to switch to official crypto library. Update config api server Update .travis.yml Got fatal error: checkptr: unsafe pointer conversion in crypto library, the issue was fixed and released in 1.4.1. see go 1.4.1 release milestone for more information: https://github.com/golang/go/issues?q=milestone%3AGo1.14.1+label%3ACherryPickApproved
#37298 has been closed with the decision that checkptr will not warn about misaligned pointers-to-non-pointer types. So I think x/crypto/sha3 can remove |
Change https://golang.org/cl/249378 mentions this issue: |
As of Go 1.14.1, -d=checkptr no longer errors on unaligned reads of non-pointer data. This reverts the code change (but not the test) from CL 222855. Fixes golang/go#37644 Updates golang/go#37298 Change-Id: I935c773a3541ed8dca7eb005d39a082eb5f10eb8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/249378 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
As of Go 1.14.1, -d=checkptr no longer errors on unaligned reads of non-pointer data. This reverts the code change (but not the test) from CL 222855. Fixes golang/go#37644 Updates golang/go#37298 Change-Id: I935c773a3541ed8dca7eb005d39a082eb5f10eb8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/249378 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
As of Go 1.14.1, -d=checkptr no longer errors on unaligned reads of non-pointer data. This reverts the code change (but not the test) from CL 222855. Fixes golang/go#37644 Updates golang/go#37298 Change-Id: I935c773a3541ed8dca7eb005d39a082eb5f10eb8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/249378 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
As of Go 1.14.1, -d=checkptr no longer errors on unaligned reads of non-pointer data. This reverts the code change (but not the test) from CL 222855. Fixes golang/go#37644 Updates golang/go#37298 Change-Id: I935c773a3541ed8dca7eb005d39a082eb5f10eb8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/249378 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
As of Go 1.14.1, -d=checkptr no longer errors on unaligned reads of non-pointer data. This reverts the code change (but not the test) from CL 222855. Fixes golang/go#37644 Updates golang/go#37298 Change-Id: I935c773a3541ed8dca7eb005d39a082eb5f10eb8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/249378 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
As of Go 1.14.1, -d=checkptr no longer errors on unaligned reads of non-pointer data. This reverts the code change (but not the test) from CL 222855. Fixes golang/go#37644 Updates golang/go#37298 Change-Id: I935c773a3541ed8dca7eb005d39a082eb5f10eb8 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/249378 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Go 1.14 is the latest release as of opening this issue, so yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
After upgrading to Go 1.14 I noticed some test failing with the error message:
The error only seems to occur when running tests with the
-race
flag. I was able to isolate the issue and create a somewhat minimal test to reproduce it:The issue does not happen with all possible values for
buf
. I'm not sure what is special about this specific value or what categories of values cause the bug. It seems that shorter values work in general.I'm using
golang.org/x/crypto@v0.0.0-20200302210943-78000ba7a073
which is the latest release as of opening this issue.What did you expect to see?
The minimal test I shared above should pass and not trigger any errors.
What did you see instead?
The test does not pass. Here's the full output:
The text was updated successfully, but these errors were encountered: