]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.19] runtime: use 1-byte load for address checking in racecallatomic
authorCherry Mui <cherryyz@google.com>
Thu, 15 Jun 2023 22:16:51 +0000 (18:16 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 22 Jun 2023 15:15:07 +0000 (15:15 +0000)
commitc9d5dd5466b017eb91d6d10e5fb71434acd94f36
tree5b6c70c0336af7f214968e1ef2714ffdc2daf686
parentf394cd77762c611e6a83f8c3688aee48533ef44d
[release-branch.go1.19] runtime: use 1-byte load for address checking in racecallatomic

In racecallatomic, we do a load before calling into TSAN, so if
the address is invalid we fault on the Go stack. We currently use
a 8-byte load instruction, regardless of the data size that the
atomic operation is performed on. So if, say, we are doing a
LoadUint32 at an address that is the last 4 bytes of a memory
mapping, we may fault unexpectedly. Do a 1-byte load instead.
(Ideally we should do a load with the right size, so we fault
correctly if we're given an unaligned address for a wide load
across a page boundary. Leave that for another CL.)

Fix AMD64, ARM64, and PPC64. The code already uses 1-byte load
on S390X.

Fixes #60844.
Updates #60825.

Change-Id: I3dee93eb08ba180c85e86a9d2e71b5b520e8dcf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/503937
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
(cherry picked from commit 1a7709d6af76c06d465c5e969b502fc206f8e687)
Reviewed-on: https://go-review.googlesource.com/c/go/+/503977
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/runtime/race/race_linux_test.go
src/runtime/race_amd64.s
src/runtime/race_arm64.s
src/runtime/race_ppc64le.s