11.1Skamil//===-- msan_interface.h --------------------------------------------------===// 21.1Skamil// 31.1Skamil// The LLVM Compiler Infrastructure 41.1Skamil// 51.1Skamil// This file is distributed under the University of Illinois Open Source 61.1Skamil// License. See LICENSE.TXT for details. 71.1Skamil// 81.1Skamil//===----------------------------------------------------------------------===// 91.1Skamil// 101.1Skamil// This file is a part of MemorySanitizer. 111.1Skamil// 121.1Skamil// Public interface header. 131.1Skamil//===----------------------------------------------------------------------===// 141.1Skamil#ifndef MSAN_INTERFACE_H 151.1Skamil#define MSAN_INTERFACE_H 161.1Skamil 171.1Skamil#include <sanitizer/common_interface_defs.h> 181.1Skamil 191.1Skamil#ifdef __cplusplus 201.1Skamilextern "C" { 211.1Skamil#endif 221.1Skamil /* Set raw origin for the memory range. */ 231.1Skamil void __msan_set_origin(const volatile void *a, size_t size, uint32_t origin); 241.1Skamil 251.1Skamil /* Get raw origin for an address. */ 261.1Skamil uint32_t __msan_get_origin(const volatile void *a); 271.1Skamil 281.1Skamil /* Test that this_id is a descendant of prev_id (or they are simply equal). 291.1Skamil * "descendant" here means they are part of the same chain, created with 301.1Skamil * __msan_chain_origin. */ 311.1Skamil int __msan_origin_is_descendant_or_same(uint32_t this_id, uint32_t prev_id); 321.1Skamil 331.1Skamil /* Returns non-zero if tracking origins. */ 341.1Skamil int __msan_get_track_origins(void); 351.1Skamil 361.1Skamil /* Returns the origin id of the latest UMR in the calling thread. */ 371.1Skamil uint32_t __msan_get_umr_origin(void); 381.1Skamil 391.1Skamil /* Make memory region fully initialized (without changing its contents). */ 401.1Skamil void __msan_unpoison(const volatile void *a, size_t size); 411.1Skamil 421.1Skamil /* Make a null-terminated string fully initialized (without changing its 431.1Skamil contents). */ 441.1Skamil void __msan_unpoison_string(const volatile char *a); 451.1Skamil 461.1Skamil /* Make memory region fully uninitialized (without changing its contents). 471.1Skamil This is a legacy interface that does not update origin information. Use 481.1Skamil __msan_allocated_memory() instead. */ 491.1Skamil void __msan_poison(const volatile void *a, size_t size); 501.1Skamil 511.1Skamil /* Make memory region partially uninitialized (without changing its contents). 521.1Skamil */ 531.1Skamil void __msan_partial_poison(const volatile void *data, void *shadow, 541.1Skamil size_t size); 551.1Skamil 561.1Skamil /* Returns the offset of the first (at least partially) poisoned byte in the 571.1Skamil memory range, or -1 if the whole range is good. */ 581.1Skamil intptr_t __msan_test_shadow(const volatile void *x, size_t size); 591.1Skamil 601.1Skamil /* Checks that memory range is fully initialized, and reports an error if it 611.1Skamil * is not. */ 621.1Skamil void __msan_check_mem_is_initialized(const volatile void *x, size_t size); 631.1Skamil 641.1Skamil /* For testing: 651.1Skamil __msan_set_expect_umr(1); 661.1Skamil ... some buggy code ... 671.1Skamil __msan_set_expect_umr(0); 681.1Skamil The last line will verify that a UMR happened. */ 691.1Skamil void __msan_set_expect_umr(int expect_umr); 701.1Skamil 711.1Skamil /* Change the value of keep_going flag. Non-zero value means don't terminate 721.1Skamil program execution when an error is detected. This will not affect error in 731.1Skamil modules that were compiled without the corresponding compiler flag. */ 741.1Skamil void __msan_set_keep_going(int keep_going); 751.1Skamil 761.1Skamil /* Print shadow and origin for the memory range to stderr in a human-readable 771.1Skamil format. */ 781.1Skamil void __msan_print_shadow(const volatile void *x, size_t size); 791.1Skamil 801.1Skamil /* Print shadow for the memory range to stderr in a minimalistic 811.1Skamil human-readable format. */ 821.1Skamil void __msan_dump_shadow(const volatile void *x, size_t size); 831.1Skamil 841.1Skamil /* Returns true if running under a dynamic tool (DynamoRio-based). */ 851.1Skamil int __msan_has_dynamic_component(void); 861.1Skamil 871.1Skamil /* Tell MSan about newly allocated memory (ex.: custom allocator). 881.1Skamil Memory will be marked uninitialized, with origin at the call site. */ 891.1Skamil void __msan_allocated_memory(const volatile void* data, size_t size); 901.1Skamil 911.1Skamil /* Tell MSan about newly destroyed memory. Mark memory as uninitialized. */ 921.1Skamil void __sanitizer_dtor_callback(const volatile void* data, size_t size); 931.1Skamil 941.1Skamil /* This function may be optionally provided by user and should return 951.1Skamil a string containing Msan runtime options. See msan_flags.h for details. */ 961.1Skamil const char* __msan_default_options(void); 971.1Skamil 981.1Skamil /* Deprecated. Call __sanitizer_set_death_callback instead. */ 991.1Skamil void __msan_set_death_callback(void (*callback)(void)); 1001.1Skamil 1011.1Skamil /* Update shadow for the application copy of size bytes from src to dst. 1021.1Skamil Src and dst are application addresses. This function does not copy the 1031.1Skamil actual application memory, it only updates shadow and origin for such 1041.1Skamil copy. Source and destination regions can overlap. */ 1051.1Skamil void __msan_copy_shadow(const volatile void *dst, const volatile void *src, 1061.1Skamil size_t size); 1071.1Skamil 1081.1Skamil /* Disables uninitialized memory checks in interceptors. */ 1091.1Skamil void __msan_scoped_disable_interceptor_checks(void); 1101.1Skamil 1111.1Skamil /* Re-enables uninitialized memory checks in interceptors after a previous 1121.1Skamil call to __msan_scoped_disable_interceptor_checks. */ 1131.1Skamil void __msan_scoped_enable_interceptor_checks(void); 1141.1Skamil 1151.1Skamil#ifdef __cplusplus 1161.1Skamil} // extern "C" 1171.1Skamil#endif 1181.1Skamil 1191.1Skamil#endif 120