diff options
| author | Keith Randall <khr@golang.org> | 2026-03-03 07:47:46 -0800 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2026-03-03 09:51:17 -0800 |
| commit | 1a0e1fb616c997ffdb10b30a1c51397d803616da (patch) | |
| tree | 46515cea0bf587123d2f0e77a924689e0197b8bc /src/internal/bytealg | |
| parent | b5c2bd7e050ceb00b1f240d8759e1ed9ebcfa4c7 (diff) | |
| download | go-1a0e1fb616c997ffdb10b30a1c51397d803616da.tar.xz | |
internal/bytealg: on android/arm64, don't read outside 16-byte regions
CL 749062 attempted this, but handled only the case of reading
past the end. This CL handles the case of reading before the beginning.
Update #59090
Change-Id: Ia21166a9a3fb20ac9003c192589a3d92304c9ee4
Reviewed-on: https://go-review.googlesource.com/c/go/+/751020
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/internal/bytealg')
| -rw-r--r-- | src/internal/bytealg/indexbyte_arm64.s | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/internal/bytealg/indexbyte_arm64.s b/src/internal/bytealg/indexbyte_arm64.s index 1101122ec0..458479e56b 100644 --- a/src/internal/bytealg/indexbyte_arm64.s +++ b/src/internal/bytealg/indexbyte_arm64.s @@ -35,7 +35,8 @@ TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32 CBZ R1, fail #ifdef GOOS_android - ADD R0, R1, R20 // R20 = end of data + ADD R0, R1, R20 // R20 = end of data + BIC $0xf, R0, R21 // R21 = earliest we can read #endif MOVD R0, R11 // Magic constant 0x40100401 allows us to identify @@ -57,7 +58,10 @@ TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32 #ifdef GOOS_android // Android requires us to not read outside an aligned 16-byte // region because MTE might be enforced. - VLD1.P (R3), [V1.B16] + CMP R21, R3 + BLO 2(PC) + VLD1 (R3), [V1.B16] + ADD $0x10, R3 CMP R3, R20 BLS 2(PC) VLD1 (R3), [V2.B16] @@ -85,7 +89,10 @@ TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32 loop: #ifdef GOOS_android - VLD1.P (R3), [V1.B16] + CMP R21, R3 + BLO 2(PC) + VLD1 (R3), [V1.B16] + ADD $0x10, R3 CMP R3, R20 BLS 2(PC) VLD1 (R3), [V2.B16] |
