msan_poisoning.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef MSAN_POISONING_H
  13. #define MSAN_POISONING_H
  14. #include "msan.h"
  15. namespace __msan {
  16. // Return origin for the first poisoned byte in the memory range, or 0.
  17. u32 GetOriginIfPoisoned(uptr addr, uptr size);
  18. // Walk [addr, addr+size) app memory region, copying origin tags from the
  19. // corresponding positions in [src_origin, src_origin+size) where the
  20. // corresponding shadow in [src_shadow, src_shadow+size) is non-zero.
  21. void SetOriginIfPoisoned(uptr addr, uptr src_shadow, uptr size, u32 src_origin);
  22. // Copy origin from src (app address) to dst (app address), creating chained
  23. // origin ids as necessary, without overriding origin for fully initialized
  24. // quads.
  25. void CopyOrigin(const void *dst, const void *src, uptr size, StackTrace *stack);
  26. // memmove() shadow and origin. Dst and src are application addresses.
  27. // See CopyOrigin() for the origin copying logic.
  28. void MoveShadowAndOrigin(const void *dst, const void *src, uptr size,
  29. StackTrace *stack);
  30. // memcpy() shadow and origin. Dst and src are application addresses.
  31. // See CopyOrigin() for the origin copying logic.
  32. void CopyShadowAndOrigin(const void *dst, const void *src, uptr size,
  33. StackTrace *stack);
  34. // memcpy() app memory, and do "the right thing" to the corresponding shadow and
  35. // origin regions.
  36. void CopyMemory(void *dst, const void *src, uptr size, StackTrace *stack);
  37. // Fill shadow will value. Ptr is an application address.
  38. void SetShadow(const void *ptr, uptr size, u8 value);
  39. // Set origin for the memory region.
  40. void SetOrigin(const void *dst, uptr size, u32 origin);
  41. // Mark memory region uninitialized, with origins.
  42. void PoisonMemory(const void *dst, uptr size, StackTrace *stack);
  43. } // namespace __msan
  44. #endif // MSAN_POISONING_H