[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
//===-- scudo_platform.h ----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// Scudo platform specific definitions.
|
2017-12-14 04:41:35 +08:00
|
|
|
/// TODO(kostyak): add tests for the compile time defines.
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef SCUDO_PLATFORM_H_
|
|
|
|
#define SCUDO_PLATFORM_H_
|
|
|
|
|
|
|
|
#include "sanitizer_common/sanitizer_allocator.h"
|
|
|
|
|
|
|
|
#if !SANITIZER_LINUX && !SANITIZER_FUCHSIA
|
|
|
|
# error "The Scudo hardened allocator is not supported on this platform."
|
|
|
|
#endif
|
|
|
|
|
2017-10-14 04:55:31 +08:00
|
|
|
#define SCUDO_TSD_EXCLUSIVE_SUPPORTED (!SANITIZER_ANDROID && !SANITIZER_FUCHSIA)
|
|
|
|
|
|
|
|
#ifndef SCUDO_TSD_EXCLUSIVE
|
|
|
|
// SCUDO_TSD_EXCLUSIVE wasn't defined, use a default TSD model for the platform.
|
|
|
|
# if SANITIZER_ANDROID || SANITIZER_FUCHSIA
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
// Android and Fuchsia use a pool of TSDs shared between threads.
|
2017-10-14 04:55:31 +08:00
|
|
|
# define SCUDO_TSD_EXCLUSIVE 0
|
|
|
|
# elif SANITIZER_LINUX && !SANITIZER_ANDROID
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
// Non-Android Linux use an exclusive TSD per thread.
|
2017-10-14 04:55:31 +08:00
|
|
|
# define SCUDO_TSD_EXCLUSIVE 1
|
|
|
|
# else
|
|
|
|
# error "No default TSD model defined for this platform."
|
|
|
|
# endif // SANITIZER_ANDROID || SANITIZER_FUCHSIA
|
|
|
|
#endif // SCUDO_TSD_EXCLUSIVE
|
|
|
|
|
|
|
|
// If the exclusive TSD model is chosen, make sure the platform supports it.
|
|
|
|
#if SCUDO_TSD_EXCLUSIVE && !SCUDO_TSD_EXCLUSIVE_SUPPORTED
|
|
|
|
# error "The exclusive TSD model is not supported on this platform."
|
|
|
|
#endif
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
|
2017-10-28 04:10:14 +08:00
|
|
|
// Maximum number of TSDs that can be created for the Shared model.
|
|
|
|
#ifndef SCUDO_SHARED_TSD_POOL_SIZE
|
2018-01-18 05:54:48 +08:00
|
|
|
# if SANITIZER_ANDROID
|
|
|
|
# define SCUDO_SHARED_TSD_POOL_SIZE 2U
|
|
|
|
# else
|
|
|
|
# define SCUDO_SHARED_TSD_POOL_SIZE 32U
|
|
|
|
# endif // SANITIZER_ANDROID
|
2017-10-28 04:10:14 +08:00
|
|
|
#endif // SCUDO_SHARED_TSD_POOL_SIZE
|
|
|
|
|
2017-12-14 04:41:35 +08:00
|
|
|
// The following allows the public interface functions to be disabled.
|
|
|
|
#ifndef SCUDO_CAN_USE_PUBLIC_INTERFACE
|
|
|
|
# define SCUDO_CAN_USE_PUBLIC_INTERFACE 1
|
|
|
|
#endif
|
|
|
|
|
2018-01-24 07:07:42 +08:00
|
|
|
// Hooks in the allocation & deallocation paths can become a security concern if
|
|
|
|
// implemented improperly, or if overwritten by an attacker. Use with caution.
|
|
|
|
#ifndef SCUDO_CAN_USE_HOOKS
|
2018-07-03 03:48:01 +08:00
|
|
|
# if SANITIZER_FUCHSIA
|
|
|
|
# define SCUDO_CAN_USE_HOOKS 1
|
|
|
|
# else
|
|
|
|
# define SCUDO_CAN_USE_HOOKS 0
|
|
|
|
# endif // SANITIZER_FUCHSIA
|
|
|
|
#endif // SCUDO_CAN_USE_HOOKS
|
2018-01-24 07:07:42 +08:00
|
|
|
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
namespace __scudo {
|
|
|
|
|
|
|
|
#if SANITIZER_CAN_USE_ALLOCATOR64
|
|
|
|
# if defined(__aarch64__) && SANITIZER_ANDROID
|
2017-11-30 03:52:09 +08:00
|
|
|
const uptr AllocatorSize = 0x4000000000ULL; // 256G.
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
# elif defined(__aarch64__)
|
|
|
|
const uptr AllocatorSize = 0x10000000000ULL; // 1T.
|
|
|
|
# else
|
|
|
|
const uptr AllocatorSize = 0x40000000000ULL; // 4T.
|
|
|
|
# endif
|
|
|
|
#else
|
2017-11-30 03:52:09 +08:00
|
|
|
const uptr RegionSizeLog = SANITIZER_ANDROID ? 19 : 20;
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
#endif // SANITIZER_CAN_USE_ALLOCATOR64
|
|
|
|
|
2017-11-30 03:52:09 +08:00
|
|
|
#if !defined(SCUDO_SIZE_CLASS_MAP)
|
|
|
|
# define SCUDO_SIZE_CLASS_MAP Default
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SIZE_CLASS_MAP_TYPE SIZE_CLASS_MAP_TYPE_(SCUDO_SIZE_CLASS_MAP)
|
|
|
|
#define SIZE_CLASS_MAP_TYPE_(T) SIZE_CLASS_MAP_TYPE__(T)
|
|
|
|
#define SIZE_CLASS_MAP_TYPE__(T) T##SizeClassMap
|
|
|
|
|
|
|
|
typedef SIZE_CLASS_MAP_TYPE SizeClassMap;
|
|
|
|
|
[scudo] Scudo thread specific data refactor, part 3
Summary:
Previous parts: D38139, D38183.
In this part of the refactor, we abstract the Linux vs Android TSD dissociation
in favor of a Exclusive vs Shared one, allowing for easier platform introduction
and configuration.
Most of this change consist of shuffling the files around to reflect the new
organization.
We introduce `scudo_platform.h` where platform specific definition lie. This
involves the TSD model and the platform specific allocator parameters. In an
upcoming CL, those will be configurable via defines, but we currently stick
with conservative defaults.
Reviewers: alekseyshl, dvyukov
Reviewed By: alekseyshl, dvyukov
Subscribers: srhines, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D38244
llvm-svn: 314224
2017-09-27 01:20:02 +08:00
|
|
|
} // namespace __scudo
|
|
|
|
|
|
|
|
#endif // SCUDO_PLATFORM_H_
|