Skip to content

Commit 5f4b5f1

Browse files
randall77gopherbot
authored andcommitted
runtime/msan: use different msan routine for copying
__msan_memmove records the fact that we're copying memory, and actually does the copy. Use instead __msan_copy_shadow, which records the fact that we're copying memory, but doesn't actually do the copy itself. We're doing the copy ourselves, so we don't need msan to do it also. More importantly, msan doing the copy clobbers the target before we issue the write barrier, which causes pointers to get lost. Fixes #76138 Change-Id: I17aea739f9444de21fac2bbfd81e48534a39481d Reviewed-on: https://go-review.googlesource.com/c/go/+/719020 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: t hepudds <thepudds1460@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Radu Berinde <radu@cockroachlabs.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
1 parent 0fe6c8e commit 5f4b5f1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/runtime/msan/msan.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ package msan
1313
#include <stdint.h>
1414
#include <sanitizer/msan_interface.h>
1515
16-
extern void __msan_memmove(void*, const void*, uintptr_t);
17-
1816
void __msan_read_go(void *addr, uintptr_t sz) {
1917
__msan_check_mem_is_initialized(addr, sz);
2018
}
@@ -32,7 +30,11 @@ void __msan_free_go(void *addr, uintptr_t sz) {
3230
}
3331
3432
void __msan_memmove_go(void *to, const void *from, uintptr_t sz) {
35-
__msan_memmove(to, from, sz);
33+
// Note: don't use msan_memmove, as it actually does
34+
// the move. We do the move ourselves, so it isn't necessary.
35+
// Also, it clobbers the target before we issue the write
36+
// barrier, which causes pointers to get lost. See issue 76138.
37+
__msan_copy_shadow(to, from, sz);
3638
}
3739
*/
3840
import "C"

0 commit comments

Comments
 (0)