2012-12-11 20:44:43 +08:00
|
|
|
//===-- msan_interface.h --------------------------------------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-12-11 20:44:43 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of MemorySanitizer.
|
|
|
|
//
|
|
|
|
// Public interface header.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef MSAN_INTERFACE_H
|
|
|
|
#define MSAN_INTERFACE_H
|
|
|
|
|
|
|
|
#include <sanitizer/common_interface_defs.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2013-01-29 22:33:29 +08:00
|
|
|
/* Set raw origin for the memory range. */
|
2013-09-10 19:54:51 +08:00
|
|
|
void __msan_set_origin(const volatile void *a, size_t size, uint32_t origin);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
/* Get raw origin for an address. */
|
2013-09-10 19:54:51 +08:00
|
|
|
uint32_t __msan_get_origin(const volatile void *a);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
2015-02-26 23:19:33 +08:00
|
|
|
/* Test that this_id is a descendant of prev_id (or they are simply equal).
|
|
|
|
* "descendant" here means they are part of the same chain, created with
|
|
|
|
* __msan_chain_origin. */
|
|
|
|
int __msan_origin_is_descendant_or_same(uint32_t this_id, uint32_t prev_id);
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
/* Returns non-zero if tracking origins. */
|
2017-12-22 04:51:16 +08:00
|
|
|
int __msan_get_track_origins(void);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
/* Returns the origin id of the latest UMR in the calling thread. */
|
2017-12-22 04:51:16 +08:00
|
|
|
uint32_t __msan_get_umr_origin(void);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
/* Make memory region fully initialized (without changing its contents). */
|
2013-09-10 19:54:51 +08:00
|
|
|
void __msan_unpoison(const volatile void *a, size_t size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
2014-03-21 18:12:17 +08:00
|
|
|
/* Make a null-terminated string fully initialized (without changing its
|
|
|
|
contents). */
|
|
|
|
void __msan_unpoison_string(const volatile char *a);
|
|
|
|
|
2019-05-10 05:50:57 +08:00
|
|
|
/* Make first n parameters of the next function call fully initialized. */
|
|
|
|
void __msan_unpoison_param(size_t n);
|
|
|
|
|
2015-01-22 00:42:30 +08:00
|
|
|
/* Make memory region fully uninitialized (without changing its contents).
|
|
|
|
This is a legacy interface that does not update origin information. Use
|
|
|
|
__msan_allocated_memory() instead. */
|
2013-09-10 19:54:51 +08:00
|
|
|
void __msan_poison(const volatile void *a, size_t size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
/* Make memory region partially uninitialized (without changing its contents).
|
|
|
|
*/
|
2013-09-10 19:54:51 +08:00
|
|
|
void __msan_partial_poison(const volatile void *data, void *shadow,
|
|
|
|
size_t size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
/* Returns the offset of the first (at least partially) poisoned byte in the
|
|
|
|
memory range, or -1 if the whole range is good. */
|
2013-09-10 19:54:51 +08:00
|
|
|
intptr_t __msan_test_shadow(const volatile void *x, size_t size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
2014-04-02 19:50:42 +08:00
|
|
|
/* Checks that memory range is fully initialized, and reports an error if it
|
|
|
|
* is not. */
|
|
|
|
void __msan_check_mem_is_initialized(const volatile void *x, size_t size);
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
/* For testing:
|
|
|
|
__msan_set_expect_umr(1);
|
|
|
|
... some buggy code ...
|
|
|
|
__msan_set_expect_umr(0);
|
|
|
|
The last line will verify that a UMR happened. */
|
|
|
|
void __msan_set_expect_umr(int expect_umr);
|
|
|
|
|
2013-06-21 20:37:58 +08:00
|
|
|
/* Change the value of keep_going flag. Non-zero value means don't terminate
|
|
|
|
program execution when an error is detected. This will not affect error in
|
|
|
|
modules that were compiled without the corresponding compiler flag. */
|
|
|
|
void __msan_set_keep_going(int keep_going);
|
|
|
|
|
2014-01-15 14:49:40 +08:00
|
|
|
/* Print shadow and origin for the memory range to stderr in a human-readable
|
2013-01-29 22:33:29 +08:00
|
|
|
format. */
|
2013-09-10 19:54:51 +08:00
|
|
|
void __msan_print_shadow(const volatile void *x, size_t size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
2014-04-30 17:50:30 +08:00
|
|
|
/* Print shadow for the memory range to stderr in a minimalistic
|
|
|
|
human-readable format. */
|
|
|
|
void __msan_dump_shadow(const volatile void *x, size_t size);
|
|
|
|
|
2013-01-29 22:33:29 +08:00
|
|
|
/* Returns true if running under a dynamic tool (DynamoRio-based). */
|
2017-12-22 04:51:16 +08:00
|
|
|
int __msan_has_dynamic_component(void);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
|
|
|
/* Tell MSan about newly allocated memory (ex.: custom allocator).
|
|
|
|
Memory will be marked uninitialized, with origin at the call site. */
|
2013-09-10 19:54:51 +08:00
|
|
|
void __msan_allocated_memory(const volatile void* data, size_t size);
|
2013-01-29 22:33:29 +08:00
|
|
|
|
2015-07-18 07:28:00 +08:00
|
|
|
/* Tell MSan about newly destroyed memory. Mark memory as uninitialized. */
|
|
|
|
void __sanitizer_dtor_callback(const volatile void* data, size_t size);
|
|
|
|
|
2013-08-02 22:26:58 +08:00
|
|
|
/* This function may be optionally provided by user and should return
|
|
|
|
a string containing Msan runtime options. See msan_flags.h for details. */
|
2017-12-22 04:51:16 +08:00
|
|
|
const char* __msan_default_options(void);
|
2013-08-02 22:26:58 +08:00
|
|
|
|
2015-08-22 06:45:12 +08:00
|
|
|
/* Deprecated. Call __sanitizer_set_death_callback instead. */
|
2014-03-27 22:04:58 +08:00
|
|
|
void __msan_set_death_callback(void (*callback)(void));
|
2013-08-02 22:26:58 +08:00
|
|
|
|
2015-10-13 07:20:24 +08:00
|
|
|
/* Update shadow for the application copy of size bytes from src to dst.
|
|
|
|
Src and dst are application addresses. This function does not copy the
|
|
|
|
actual application memory, it only updates shadow and origin for such
|
|
|
|
copy. Source and destination regions can overlap. */
|
|
|
|
void __msan_copy_shadow(const volatile void *dst, const volatile void *src,
|
|
|
|
size_t size);
|
2018-07-07 01:10:51 +08:00
|
|
|
|
|
|
|
/* Disables uninitialized memory checks in interceptors. */
|
|
|
|
void __msan_scoped_disable_interceptor_checks(void);
|
|
|
|
|
|
|
|
/* Re-enables uninitialized memory checks in interceptors after a previous
|
|
|
|
call to __msan_scoped_disable_interceptor_checks. */
|
|
|
|
void __msan_scoped_enable_interceptor_checks(void);
|
|
|
|
|
2012-12-11 20:44:43 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|