1 //===-- msan_poisoning.h ----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of MemorySanitizer.
11 //===----------------------------------------------------------------------===//
13 #ifndef MSAN_POISONING_H
14 #define MSAN_POISONING_H
20 // Return origin for the first poisoned byte in the memory range, or 0.
21 u32
GetOriginIfPoisoned(uptr addr
, uptr size
);
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.
26 void SetOriginIfPoisoned(uptr addr
, uptr src_shadow
, uptr size
, u32 src_origin
);
28 // Copy origin from src (app address) to dst (app address), creating chained
29 // origin ids as necessary, without overriding origin for fully initialized
31 void CopyOrigin(const void *dst
, const void *src
, uptr size
, StackTrace
*stack
);
33 // memmove() shadow and origin. Dst and src are application addresses.
34 // See CopyOrigin() for the origin copying logic.
35 void MoveShadowAndOrigin(const void *dst
, const void *src
, uptr size
,
38 // memcpy() shadow and origin. Dst and src are application addresses.
39 // See CopyOrigin() for the origin copying logic.
40 void CopyShadowAndOrigin(const void *dst
, const void *src
, uptr size
,
43 // memcpy() app memory, and do "the right thing" to the corresponding shadow and
45 void CopyMemory(void *dst
, const void *src
, uptr size
, StackTrace
*stack
);
47 // Fill shadow will value. Ptr is an application address.
48 void SetShadow(const void *ptr
, uptr size
, u8 value
);
50 // Set origin for the memory region.
51 void SetOrigin(const void *dst
, uptr size
, u32 origin
);
53 // Mark memory region uninitialized, with origins.
54 void PoisonMemory(const void *dst
, uptr size
, StackTrace
*stack
);
58 #endif // MSAN_POISONING_H