From f5b77a7e2fa0f7ff346c665974a8eded367b1bc2 Mon Sep 17 00:00:00 2001 From: Junyang Shao Date: Fri, 6 Mar 2026 00:03:45 +0000 Subject: cmd/compile: fix loopbce overflow check logic addWillOverflow and subWillOverflow has an implicit assumption that y is positive, using it outside of addU and subU is really incorrect. This CL fixes those incorrect usage to use the correct logic in place. Thanks to Jakub Ciolek for reporting this issue. Fixes #78333 Fixes CVE-2026-27143 Change-Id: I263e8e7ac227e2a68109eb7bbd45f66569ed22ec Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/3700 Reviewed-by: Damien Neil Reviewed-by: Neal Patel Reviewed-on: https://go-review.googlesource.com/c/go/+/763765 Reviewed-by: Jakub Ciolek Reviewed-by: Russ Cox LUCI-TryBot-Result: Go LUCI Auto-Submit: David Chase --- test/loopbce.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/loopbce.go') diff --git a/test/loopbce.go b/test/loopbce.go index ca09e7e7f7..3ef08a2b8d 100644 --- a/test/loopbce.go +++ b/test/loopbce.go @@ -469,6 +469,34 @@ func stride2(x *[7]int) int { return s } +// This loop should not be proved anything. +func smallIntUp(arr *[128]int) { + for i := int8(0); i <= int8(120); i += int8(10) { + arr[i] = int(i) + } +} + +// This loop should not be proved anything. +func smallIntDown(arr *[128]int) { + for i := int8(0); i >= int8(-120); i -= int8(10) { + arr[127+i] = int(i) + } +} + +// This loop should not be proved anything. +func smallUintUp(arr *[128]int) { + for i := uint8(0); i <= uint8(250); i += uint8(10) { + arr[i] = int(i) + } +} + +// This loop should not be proved anything. +func smallUintDown(arr *[128]int) { + for i := uint8(255); i >= uint8(0); i -= uint8(10) { + arr[127+i] = int(i) + } +} + //go:noinline func useString(a string) { } -- cgit v1.3