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