1//===-- msan_poisoning.h ----------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of MemorySanitizer.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MSAN_POISONING_H
14#define MSAN_POISONING_H
15
16#include "msan.h"
17
18namespace __msan {
19
20// Return origin for the first poisoned byte in the memory range, or 0.
21u32 GetOriginIfPoisoned(uptr addr, uptr size);
22
23// Walk [addr, addr+size) app memory region, copying origin tags from the
24// corresponding positions in [src_origin, src_origin+size) where the
25// corresponding shadow in [src_shadow, src_shadow+size) is non-zero.
26void SetOriginIfPoisoned(uptr addr, uptr src_shadow, uptr size, u32 src_origin);
27
28// Copy origin from src (app address) to dst (app address), creating chained
29// origin ids as necessary, without overriding origin for fully initialized
30// quads.
31void CopyOrigin(const void *dst, const void *src, uptr size, StackTrace *stack);
32
33// memmove() shadow and origin. Dst and src are application addresses.
34// See CopyOrigin() for the origin copying logic.
35void MoveShadowAndOrigin(const void *dst, const void *src, uptr size,
36 StackTrace *stack);
37
38// memcpy() shadow and origin. Dst and src are application addresses.
39// See CopyOrigin() for the origin copying logic.
40void CopyShadowAndOrigin(const void *dst, const void *src, uptr size,
41 StackTrace *stack);
42
43// memcpy() app memory, and do "the right thing" to the corresponding shadow and
44// origin regions.
45void CopyMemory(void *dst, const void *src, uptr size, StackTrace *stack);
46
47// Fill shadow will value. Ptr is an application address.
48void SetShadow(const void *ptr, uptr size, u8 value);
49
50// Set origin for the memory region.
51void SetOrigin(const void *dst, uptr size, u32 origin);
52
53// Mark memory region uninitialized, with origins.
54void PoisonMemory(const void *dst, uptr size, StackTrace *stack);
55
56} // namespace __msan
57
58#endif // MSAN_POISONING_H
59