diff options
| author | fanzha02 <fannie.zhang@arm.com> | 2021-12-30 11:09:42 +0800 |
|---|---|---|
| committer | Fannie Zhang <Fannie.Zhang@arm.com> | 2022-01-05 09:50:29 +0000 |
| commit | 2c58bb2e428c1f587dc30817bc211570f6fd4793 (patch) | |
| tree | f1621f6baa6301e7893c74b4bf40d8287e0e4278 /misc | |
| parent | 301db3f5d2d38a13aafe5bc6efea9a3bdbfc475e (diff) | |
| download | go-2c58bb2e428c1f587dc30817bc211570f6fd4793.tar.xz | |
src/runtime: mark asanread and asanwrite functions as NOSPLIT
The asan runtime functions may run on stacks that cannot grow, and
they do not have large local variables, so it is safe to mark them
as NOSPLIT.
Add test case.
Fixes #50391
Change-Id: Iadcbf1ae0c837d9b64da5be208c7f424e6ba11de
Reviewed-on: https://go-review.googlesource.com/c/go/+/374398
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'misc')
| -rw-r--r-- | misc/cgo/testsanitizers/asan_test.go | 1 | ||||
| -rw-r--r-- | misc/cgo/testsanitizers/testdata/asan5_fail.go | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/misc/cgo/testsanitizers/asan_test.go b/misc/cgo/testsanitizers/asan_test.go index 27bd8a5b1f..1b70bce3d1 100644 --- a/misc/cgo/testsanitizers/asan_test.go +++ b/misc/cgo/testsanitizers/asan_test.go @@ -39,6 +39,7 @@ func TestASAN(t *testing.T) { {src: "asan2_fail.go", memoryAccessError: "heap-buffer-overflow", errorLocation: "asan2_fail.go:31"}, {src: "asan3_fail.go", memoryAccessError: "use-after-poison", errorLocation: "asan3_fail.go:13"}, {src: "asan4_fail.go", memoryAccessError: "use-after-poison", errorLocation: "asan4_fail.go:13"}, + {src: "asan5_fail.go", memoryAccessError: "use-after-poison", errorLocation: "asan5_fail.go:18"}, {src: "asan_useAfterReturn.go"}, } for _, tc := range cases { diff --git a/misc/cgo/testsanitizers/testdata/asan5_fail.go b/misc/cgo/testsanitizers/testdata/asan5_fail.go new file mode 100644 index 0000000000..d6853eab73 --- /dev/null +++ b/misc/cgo/testsanitizers/testdata/asan5_fail.go @@ -0,0 +1,21 @@ +package main + +import ( + "fmt" + "runtime" + "unsafe" +) + +func main() { + p := new([1024 * 1000]int) + p[0] = 10 + r := bar(&p[1024*1000-1]) + fmt.Printf("r value is %d", r) +} + +func bar(a *int) int { + p := unsafe.Add(unsafe.Pointer(a), 2*unsafe.Sizeof(int(1))) + runtime.ASanWrite(p, 8) // BOOM + *((*int)(p)) = 10 + return *((*int)(p)) +} |
