msan.cc revision 7847d77b246635211c3bf465421d49d7af5226c1
15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//===-- msan.cc -----------------------------------------------------------===//
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//                     The LLVM Compiler Infrastructure
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// License. See LICENSE.TXT for details.
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//===----------------------------------------------------------------------===//
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//
10c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch// This file is a part of MemorySanitizer.
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//
125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// MemorySanitizer runtime.
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)//===----------------------------------------------------------------------===//
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "msan.h"
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sanitizer_common/sanitizer_atomic.h"
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sanitizer_common/sanitizer_common.h"
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sanitizer_common/sanitizer_flags.h"
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sanitizer_common/sanitizer_libc.h"
205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sanitizer_common/sanitizer_procmaps.h"
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sanitizer_common/sanitizer_stacktrace.h"
225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "sanitizer_common/sanitizer_symbolizer.h"
235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "interception/interception.h"
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// ACHTUNG! No system header includes in this file.
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using namespace __sanitizer;
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Globals.
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)static THREADLOCAL int msan_expect_umr = 0;
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)static THREADLOCAL int msan_expected_umr_found = 0;
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)static int msan_running_under_dr = 0;
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SANITIZER_INTERFACE_ATTRIBUTE
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)THREADLOCAL u64 __msan_param_tls[kMsanParamTlsSizeInWords];
38effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SANITIZER_INTERFACE_ATTRIBUTE
40effb81e5f8246d0db0270817048dc992db66e9fbBen MurdochTHREADLOCAL u32 __msan_param_origin_tls[kMsanParamTlsSizeInWords];
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)SANITIZER_INTERFACE_ATTRIBUTE
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)THREADLOCAL u64 __msan_retval_tls[kMsanRetvalTlsSizeInWords];
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
45SANITIZER_INTERFACE_ATTRIBUTE
46THREADLOCAL u32 __msan_retval_origin_tls;
47
48SANITIZER_INTERFACE_ATTRIBUTE
49THREADLOCAL u64 __msan_va_arg_tls[kMsanParamTlsSizeInWords];
50
51SANITIZER_INTERFACE_ATTRIBUTE
52THREADLOCAL u64 __msan_va_arg_overflow_size_tls;
53
54SANITIZER_INTERFACE_ATTRIBUTE
55THREADLOCAL u32 __msan_origin_tls;
56
57static THREADLOCAL struct {
58  uptr stack_top, stack_bottom;
59} __msan_stack_bounds;
60
61static THREADLOCAL bool is_in_symbolizer;
62static THREADLOCAL bool is_in_loader;
63
64extern "C" SANITIZER_WEAK_ATTRIBUTE const int __msan_track_origins;
65
66int __msan_get_track_origins() {
67  return &__msan_track_origins ? __msan_track_origins : 0;
68}
69
70extern "C" SANITIZER_WEAK_ATTRIBUTE const int __msan_keep_going;
71
72namespace __msan {
73
74static bool IsRunningUnderDr() {
75  bool result = false;
76  MemoryMappingLayout proc_maps(/*cache_enabled*/true);
77  const sptr kBufSize = 4095;
78  char *filename = (char*)MmapOrDie(kBufSize, __FUNCTION__);
79  while (proc_maps.Next(/* start */0, /* end */0, /* file_offset */0,
80                        filename, kBufSize, /* protection */0)) {
81    if (internal_strstr(filename, "libdynamorio") != 0) {
82      result = true;
83      break;
84    }
85  }
86  UnmapOrDie(filename, kBufSize);
87  return result;
88}
89
90void EnterSymbolizer() { is_in_symbolizer = true; }
91void ExitSymbolizer()  { is_in_symbolizer = false; }
92bool IsInSymbolizer() { return is_in_symbolizer; }
93
94void EnterLoader() { is_in_loader = true; }
95void ExitLoader()  { is_in_loader = false; }
96
97extern "C" {
98SANITIZER_INTERFACE_ATTRIBUTE
99bool __msan_is_in_loader() { return is_in_loader; }
100}
101
102static Flags msan_flags;
103
104Flags *flags() {
105  return &msan_flags;
106}
107
108int msan_inited = 0;
109bool msan_init_is_running;
110
111int msan_report_count = 0;
112
113// Array of stack origins.
114// FIXME: make it resizable.
115static const uptr kNumStackOriginDescrs = 1024 * 1024;
116static const char *StackOriginDescr[kNumStackOriginDescrs];
117static atomic_uint32_t NumStackOriginDescrs;
118
119static void ParseFlagsFromString(Flags *f, const char *str) {
120  ParseCommonFlagsFromString(str);
121  ParseFlag(str, &f->poison_heap_with_zeroes, "poison_heap_with_zeroes");
122  ParseFlag(str, &f->poison_stack_with_zeroes, "poison_stack_with_zeroes");
123  ParseFlag(str, &f->poison_in_malloc, "poison_in_malloc");
124  ParseFlag(str, &f->exit_code, "exit_code");
125  if (f->exit_code < 0 || f->exit_code > 127) {
126    Printf("Exit code not in [0, 128) range: %d\n", f->exit_code);
127    Die();
128  }
129  ParseFlag(str, &f->report_umrs, "report_umrs");
130  ParseFlag(str, &f->verbosity, "verbosity");
131  ParseFlag(str, &f->wrap_signals, "wrap_signals");
132
133  // keep_going is an old name for halt_on_error,
134  // and it has inverse meaning.
135  f->halt_on_error = !f->halt_on_error;
136  ParseFlag(str, &f->halt_on_error, "keep_going");
137  f->halt_on_error = !f->halt_on_error;
138  ParseFlag(str, &f->halt_on_error, "halt_on_error");
139}
140
141static void InitializeFlags(Flags *f, const char *options) {
142  CommonFlags *cf = common_flags();
143  cf->external_symbolizer_path = GetEnv("MSAN_SYMBOLIZER_PATH");
144  cf->strip_path_prefix = "";
145  cf->fast_unwind_on_fatal = false;
146  cf->fast_unwind_on_malloc = true;
147  cf->malloc_context_size = 20;
148  cf->handle_ioctl = true;
149  cf->log_path = 0;
150
151  internal_memset(f, 0, sizeof(*f));
152  f->poison_heap_with_zeroes = false;
153  f->poison_stack_with_zeroes = false;
154  f->poison_in_malloc = true;
155  f->exit_code = 77;
156  f->report_umrs = true;
157  f->verbosity = 0;
158  f->wrap_signals = true;
159  f->halt_on_error = !&__msan_keep_going;
160
161  // Override from user-specified string.
162  if (__msan_default_options)
163    ParseFlagsFromString(f, __msan_default_options());
164  ParseFlagsFromString(f, options);
165}
166
167static void GetCurrentStackBounds(uptr *stack_top, uptr *stack_bottom) {
168  if (__msan_stack_bounds.stack_top == 0) {
169    // Break recursion (GetStackTrace -> GetThreadStackTopAndBottom ->
170    // realloc -> GetStackTrace).
171    __msan_stack_bounds.stack_top = __msan_stack_bounds.stack_bottom = 1;
172    GetThreadStackTopAndBottom(/* at_initialization */false,
173                               &__msan_stack_bounds.stack_top,
174                               &__msan_stack_bounds.stack_bottom);
175  }
176  *stack_top = __msan_stack_bounds.stack_top;
177  *stack_bottom = __msan_stack_bounds.stack_bottom;
178}
179
180void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp,
181                   bool fast) {
182  if (!fast) {
183    // Block reports from our interceptors during _Unwind_Backtrace.
184    SymbolizerScope sym_scope;
185    return stack->SlowUnwindStack(pc, max_s);
186  }
187
188  uptr stack_top, stack_bottom;
189  GetCurrentStackBounds(&stack_top, &stack_bottom);
190  stack->size = 0;
191  stack->trace[0] = pc;
192  stack->max_size = max_s;
193  stack->FastUnwindStack(pc, bp, stack_top, stack_bottom);
194}
195
196void PrintWarning(uptr pc, uptr bp) {
197  PrintWarningWithOrigin(pc, bp, __msan_origin_tls);
198}
199
200bool OriginIsValid(u32 origin) {
201  return origin != 0 && origin != (u32)-1;
202}
203
204void PrintWarningWithOrigin(uptr pc, uptr bp, u32 origin) {
205  if (msan_expect_umr) {
206    // Printf("Expected UMR\n");
207    __msan_origin_tls = origin;
208    msan_expected_umr_found = 1;
209    return;
210  }
211
212  ++msan_report_count;
213
214  StackTrace stack;
215  GetStackTrace(&stack, kStackTraceMax, pc, bp,
216                common_flags()->fast_unwind_on_fatal);
217
218  u32 report_origin =
219    (__msan_get_track_origins() && OriginIsValid(origin)) ? origin : 0;
220  ReportUMR(&stack, report_origin);
221
222  if (__msan_get_track_origins() && !OriginIsValid(origin)) {
223    Printf("  ORIGIN: invalid (%x). Might be a bug in MemorySanitizer, "
224           "please report to MemorySanitizer developers.\n",
225           origin);
226  }
227}
228
229void UnpoisonParam(uptr n) {
230  internal_memset(__msan_param_tls, 0, n * sizeof(*__msan_param_tls));
231}
232
233// Backup MSan runtime TLS state.
234// Implementation must be async-signal-safe.
235// Instances of this class may live on the signal handler stack, and data size
236// may be an issue.
237void ScopedThreadLocalStateBackup::Backup() {
238  va_arg_overflow_size_tls = __msan_va_arg_overflow_size_tls;
239}
240
241void ScopedThreadLocalStateBackup::Restore() {
242  // A lame implementation that only keeps essential state and resets the rest.
243  __msan_va_arg_overflow_size_tls = va_arg_overflow_size_tls;
244
245  internal_memset(__msan_param_tls, 0, sizeof(__msan_param_tls));
246  internal_memset(__msan_retval_tls, 0, sizeof(__msan_retval_tls));
247  internal_memset(__msan_va_arg_tls, 0, sizeof(__msan_va_arg_tls));
248
249  if (__msan_get_track_origins()) {
250    internal_memset(&__msan_retval_origin_tls, 0, sizeof(__msan_retval_tls));
251    internal_memset(__msan_param_origin_tls, 0,
252                    sizeof(__msan_param_origin_tls));
253  }
254}
255
256void UnpoisonThreadLocalState() {
257}
258
259}  // namespace __msan
260
261// Interface.
262
263using namespace __msan;
264
265void __msan_warning() {
266  GET_CALLER_PC_BP_SP;
267  (void)sp;
268  PrintWarning(pc, bp);
269  if (__msan::flags()->halt_on_error) {
270    Printf("Exiting\n");
271    Die();
272  }
273}
274
275void __msan_warning_noreturn() {
276  GET_CALLER_PC_BP_SP;
277  (void)sp;
278  PrintWarning(pc, bp);
279  Printf("Exiting\n");
280  Die();
281}
282
283void __msan_init() {
284  if (msan_inited) return;
285  msan_init_is_running = 1;
286  SanitizerToolName = "MemorySanitizer";
287
288  InstallAtExitHandler();
289  SetDieCallback(MsanDie);
290  InitTlsSize();
291  InitializeInterceptors();
292
293  if (MSAN_REPLACE_OPERATORS_NEW_AND_DELETE)
294    ReplaceOperatorsNewAndDelete();
295  const char *msan_options = GetEnv("MSAN_OPTIONS");
296  InitializeFlags(&msan_flags, msan_options);
297  __sanitizer_set_report_path(common_flags()->log_path);
298  if (StackSizeIsUnlimited()) {
299    if (flags()->verbosity)
300      Printf("Unlimited stack, doing reexec\n");
301    // A reasonably large stack size. It is bigger than the usual 8Mb, because,
302    // well, the program could have been run with unlimited stack for a reason.
303    SetStackSizeLimitInBytes(32 * 1024 * 1024);
304    ReExec();
305  }
306
307  if (flags()->verbosity)
308    Printf("MSAN_OPTIONS: %s\n", msan_options ? msan_options : "<empty>");
309
310  msan_running_under_dr = IsRunningUnderDr();
311  __msan_clear_on_return();
312  if (__msan_get_track_origins() && flags()->verbosity > 0)
313    Printf("msan_track_origins\n");
314  if (!InitShadow(/* prot1 */ false, /* prot2 */ true, /* map_shadow */ true,
315                  __msan_get_track_origins())) {
316    // FIXME: prot1 = false is only required when running under DR.
317    Printf("FATAL: MemorySanitizer can not mmap the shadow memory.\n");
318    Printf("FATAL: Make sure to compile with -fPIE and to link with -pie.\n");
319    Printf("FATAL: Disabling ASLR is known to cause this error.\n");
320    Printf("FATAL: If running under GDB, try "
321           "'set disable-randomization off'.\n");
322    DumpProcessMap();
323    Die();
324  }
325
326  const char *external_symbolizer = common_flags()->external_symbolizer_path;
327  bool symbolizer_started =
328      getSymbolizer()->InitializeExternal(external_symbolizer);
329  if (external_symbolizer && external_symbolizer[0]) {
330    CHECK(symbolizer_started);
331  }
332
333  GetThreadStackTopAndBottom(/* at_initialization */true,
334                             &__msan_stack_bounds.stack_top,
335                             &__msan_stack_bounds.stack_bottom);
336  if (flags()->verbosity)
337    Printf("MemorySanitizer init done\n");
338  msan_init_is_running = 0;
339  msan_inited = 1;
340}
341
342void __msan_set_exit_code(int exit_code) {
343  flags()->exit_code = exit_code;
344}
345
346void __msan_set_keep_going(int keep_going) {
347  flags()->halt_on_error = !keep_going;
348}
349
350void __msan_set_expect_umr(int expect_umr) {
351  if (expect_umr) {
352    msan_expected_umr_found = 0;
353  } else if (!msan_expected_umr_found) {
354    GET_CALLER_PC_BP_SP;
355    (void)sp;
356    StackTrace stack;
357    GetStackTrace(&stack, kStackTraceMax, pc, bp,
358                  common_flags()->fast_unwind_on_fatal);
359    ReportExpectedUMRNotFound(&stack);
360    Die();
361  }
362  msan_expect_umr = expect_umr;
363}
364
365void __msan_print_shadow(const void *x, uptr size) {
366  unsigned char *s = (unsigned char*)MEM_TO_SHADOW(x);
367  u32 *o = (u32*)MEM_TO_ORIGIN(x);
368  for (uptr i = 0; i < size; i++) {
369    Printf("%x%x ", s[i] >> 4, s[i] & 0xf);
370  }
371  Printf("\n");
372  if (__msan_get_track_origins()) {
373    for (uptr i = 0; i < size / 4; i++) {
374      Printf(" o: %x ", o[i]);
375    }
376    Printf("\n");
377  }
378}
379
380void __msan_print_param_shadow() {
381  for (int i = 0; i < 16; i++) {
382    Printf("#%d:%zx ", i, __msan_param_tls[i]);
383  }
384  Printf("\n");
385}
386
387sptr __msan_test_shadow(const void *x, uptr size) {
388  unsigned char *s = (unsigned char*)MEM_TO_SHADOW((uptr)x);
389  for (uptr i = 0; i < size; ++i)
390    if (s[i])
391      return i;
392  return -1;
393}
394
395int __msan_set_poison_in_malloc(int do_poison) {
396  int old = flags()->poison_in_malloc;
397  flags()->poison_in_malloc = do_poison;
398  return old;
399}
400
401int  __msan_has_dynamic_component() {
402  return msan_running_under_dr;
403}
404
405NOINLINE
406void __msan_clear_on_return() {
407  __msan_param_tls[0] = 0;
408}
409
410static void* get_tls_base() {
411  u64 p;
412  asm("mov %%fs:0, %0"
413      : "=r"(p) ::);
414  return (void*)p;
415}
416
417int __msan_get_retval_tls_offset() {
418  // volatile here is needed to avoid UB, because the compiler thinks that we
419  // are doing address arithmetics on unrelated pointers, and takes some
420  // shortcuts
421  volatile sptr retval_tls_p = (sptr)&__msan_retval_tls;
422  volatile sptr tls_base_p = (sptr)get_tls_base();
423  return retval_tls_p - tls_base_p;
424}
425
426int __msan_get_param_tls_offset() {
427  // volatile here is needed to avoid UB, because the compiler thinks that we
428  // are doing address arithmetics on unrelated pointers, and takes some
429  // shortcuts
430  volatile sptr param_tls_p = (sptr)&__msan_param_tls;
431  volatile sptr tls_base_p = (sptr)get_tls_base();
432  return param_tls_p - tls_base_p;
433}
434
435void __msan_partial_poison(const void* data, void* shadow, uptr size) {
436  internal_memcpy((void*)MEM_TO_SHADOW((uptr)data), shadow, size);
437}
438
439void __msan_load_unpoisoned(void *src, uptr size, void *dst) {
440  internal_memcpy(dst, src, size);
441  __msan_unpoison(dst, size);
442}
443
444void __msan_set_origin(const void *a, uptr size, u32 origin) {
445  // Origin mapping is 4 bytes per 4 bytes of application memory.
446  // Here we extend the range such that its left and right bounds are both
447  // 4 byte aligned.
448  if (!__msan_get_track_origins()) return;
449  uptr x = MEM_TO_ORIGIN((uptr)a);
450  uptr beg = x & ~3UL;  // align down.
451  uptr end = (x + size + 3) & ~3UL;  // align up.
452  u64 origin64 = ((u64)origin << 32) | origin;
453  // This is like memset, but the value is 32-bit. We unroll by 2 two write
454  // 64-bits at once. May want to unroll further to get 128-bit stores.
455  if (beg & 7ULL) {
456    *(u32*)beg = origin;
457    beg += 4;
458  }
459  for (uptr addr = beg; addr < (end & ~7UL); addr += 8)
460    *(u64*)addr = origin64;
461  if (end & 7ULL)
462    *(u32*)(end - 4) = origin;
463}
464
465// 'descr' is created at compile time and contains '----' in the beginning.
466// When we see descr for the first time we replace '----' with a uniq id
467// and set the origin to (id | (31-th bit)).
468void __msan_set_alloca_origin(void *a, uptr size, const char *descr) {
469  static const u32 dash = '-';
470  static const u32 first_timer =
471      dash + (dash << 8) + (dash << 16) + (dash << 24);
472  u32 *id_ptr = (u32*)descr;
473  bool print = false;  // internal_strstr(descr + 4, "AllocaTOTest") != 0;
474  u32 id = *id_ptr;
475  if (id == first_timer) {
476    id = atomic_fetch_add(&NumStackOriginDescrs,
477                          1, memory_order_relaxed);
478    *id_ptr = id;
479    CHECK_LT(id, kNumStackOriginDescrs);
480    StackOriginDescr[id] = descr + 4;
481    if (print)
482      Printf("First time: id=%d %s \n", id, descr + 4);
483  }
484  id |= 1U << 31;
485  if (print)
486    Printf("__msan_set_alloca_origin: descr=%s id=%x\n", descr + 4, id);
487  __msan_set_origin(a, size, id);
488}
489
490const char *__msan_get_origin_descr_if_stack(u32 id) {
491  if ((id >> 31) == 0) return 0;
492  id &= (1U << 31) - 1;
493  CHECK_LT(id, kNumStackOriginDescrs);
494  return StackOriginDescr[id];
495}
496
497
498u32 __msan_get_origin(const void *a) {
499  if (!__msan_get_track_origins()) return 0;
500  uptr x = (uptr)a;
501  uptr aligned = x & ~3ULL;
502  uptr origin_ptr = MEM_TO_ORIGIN(aligned);
503  return *(u32*)origin_ptr;
504}
505
506u32 __msan_get_umr_origin() {
507  return __msan_origin_tls;
508}
509
510u16 __sanitizer_unaligned_load16(const uu16 *p) {
511  __msan_retval_tls[0] = *(uu16 *)MEM_TO_SHADOW((uptr)p);
512  return *p;
513}
514u32 __sanitizer_unaligned_load32(const uu32 *p) {
515  __msan_retval_tls[0] = *(uu32 *)MEM_TO_SHADOW((uptr)p);
516  return *p;
517}
518u64 __sanitizer_unaligned_load64(const uu64 *p) {
519  __msan_retval_tls[0] = *(uu64 *)MEM_TO_SHADOW((uptr)p);
520  return *p;
521}
522void __sanitizer_unaligned_store16(uu16 *p, u16 x) {
523  *(uu16 *)MEM_TO_SHADOW((uptr)p) = __msan_param_tls[1];
524  *p = x;
525}
526void __sanitizer_unaligned_store32(uu32 *p, u32 x) {
527  *(uu32 *)MEM_TO_SHADOW((uptr)p) = __msan_param_tls[1];
528  *p = x;
529}
530void __sanitizer_unaligned_store64(uu64 *p, u64 x) {
531  *(uu64 *)MEM_TO_SHADOW((uptr)p) = __msan_param_tls[1];
532  *p = x;
533}
534
535#if !SANITIZER_SUPPORTS_WEAK_HOOKS
536extern "C" {
537SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
538const char* __msan_default_options() { return ""; }
539}  // extern "C"
540#endif
541
542