Source file src/runtime/msan.go
Documentation: runtime
1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build msan 6 // +build msan 7 8 package runtime 9 10 import ( 11 "unsafe" 12 ) 13 14 // Public memory sanitizer API. 15 16 func MSanRead(addr unsafe.Pointer, len int) { 17 msanread(addr, uintptr(len)) 18 } 19 20 func MSanWrite(addr unsafe.Pointer, len int) { 21 msanwrite(addr, uintptr(len)) 22 } 23 24 // Private interface for the runtime. 25 const msanenabled = true 26 27 // If we are running on the system stack, the C program may have 28 // marked part of that stack as uninitialized. We don't instrument 29 // the runtime, but operations like a slice copy can call msanread 30 // anyhow for values on the stack. Just ignore msanread when running 31 // on the system stack. The other msan functions are fine. 32 // 33 //go:nosplit 34 func msanread(addr unsafe.Pointer, sz uintptr) { 35 g := getg() 36 if g == nil || g.m == nil || g == g.m.g0 || g == g.m.gsignal { 37 return 38 } 39 domsanread(addr, sz) 40 } 41 42 //go:noescape 43 func domsanread(addr unsafe.Pointer, sz uintptr) 44 45 //go:noescape 46 func msanwrite(addr unsafe.Pointer, sz uintptr) 47 48 //go:noescape 49 func msanmalloc(addr unsafe.Pointer, sz uintptr) 50 51 //go:noescape 52 func msanfree(addr unsafe.Pointer, sz uintptr) 53 54 //go:noescape 55 func msanmove(dst, src unsafe.Pointer, sz uintptr) 56 57 // These are called from msan_GOARCH.s 58 //go:cgo_import_static __msan_read_go 59 //go:cgo_import_static __msan_write_go 60 //go:cgo_import_static __msan_malloc_go 61 //go:cgo_import_static __msan_free_go 62 //go:cgo_import_static __msan_memmove 63