Commit dee9e140 authored by Vlad Tsyrklevich's avatar Vlad Tsyrklevich Committed by Commit Bot

Wire in GWP-ASan PartitionAlloc into chrome

Enable GWP-ASan for PartitionAlloc support in chrome if the newly
introduced enable_gwp_asan_partitionalloc flag is set.

CQ-DEPEND=CL:1601972

Bug: 956824
Change-Id: I38ebf62c11449813b71691053597d76ee7006a90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1602317Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarVitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658774}
parent 703b5aa8
...@@ -1496,7 +1496,7 @@ group("browser_dependencies") { ...@@ -1496,7 +1496,7 @@ group("browser_dependencies") {
} }
} }
if (enable_gwp_asan_malloc) { if (enable_gwp_asan_malloc || enable_gwp_asan_partitionalloc) {
public_deps += [ "//components/gwp_asan/client" ] public_deps += [ "//components/gwp_asan/client" ]
} }
...@@ -1542,7 +1542,7 @@ group("child_dependencies") { ...@@ -1542,7 +1542,7 @@ group("child_dependencies") {
public_deps += [ "//components/nacl/renderer/plugin:nacl_trusted_plugin" ] public_deps += [ "//components/nacl/renderer/plugin:nacl_trusted_plugin" ]
} }
if (enable_gwp_asan_malloc) { if (enable_gwp_asan_malloc || enable_gwp_asan_partitionalloc) {
public_deps += [ "//components/gwp_asan/client" ] public_deps += [ "//components/gwp_asan/client" ]
} }
...@@ -1897,7 +1897,7 @@ if (is_android) { ...@@ -1897,7 +1897,7 @@ if (is_android) {
deps += [ "//third_party/gvr-android-sdk:gvr_shim" ] deps += [ "//third_party/gvr-android-sdk:gvr_shim" ]
} }
if (enable_gwp_asan_malloc) { if (enable_gwp_asan_malloc || enable_gwp_asan_partitionalloc) {
deps += [ "//components/gwp_asan/client" ] deps += [ "//components/gwp_asan/client" ]
} }
} }
......
...@@ -400,7 +400,7 @@ static_library("test_support") { ...@@ -400,7 +400,7 @@ static_library("test_support") {
deps += [ "//services/ws/public/mojom:constants" ] deps += [ "//services/ws/public/mojom:constants" ]
} }
if (enable_gwp_asan_malloc) { if (enable_gwp_asan_malloc || enable_gwp_asan_partitionalloc) {
deps += [ "//components/gwp_asan/client" ] deps += [ "//components/gwp_asan/client" ]
} }
} }
......
...@@ -166,7 +166,8 @@ ...@@ -166,7 +166,8 @@
#include "chrome/child/pdf_child_init.h" #include "chrome/child/pdf_child_init.h"
#endif #endif
#if BUILDFLAG(ENABLE_GWP_ASAN_MALLOC) #if BUILDFLAG(ENABLE_GWP_ASAN_MALLOC) || \
BUILDFLAG(ENABLE_GWP_ASAN_PARTITIONALLOC)
#include "components/gwp_asan/client/gwp_asan.h" // nogncheck #include "components/gwp_asan/client/gwp_asan.h" // nogncheck
#endif #endif
...@@ -559,15 +560,26 @@ void ChromeMainDelegate::PostTaskSchedulerStart() { ...@@ -559,15 +560,26 @@ void ChromeMainDelegate::PostTaskSchedulerStart() {
void ChromeMainDelegate::PostFieldTrialInitialization() { void ChromeMainDelegate::PostFieldTrialInitialization() {
#if BUILDFLAG(ENABLE_GWP_ASAN_MALLOC) #if BUILDFLAG(ENABLE_GWP_ASAN_MALLOC)
version_info::Channel channel = chrome::GetChannel(); {
bool is_canary_dev = (channel == version_info::Channel::CANARY || version_info::Channel channel = chrome::GetChannel();
channel == version_info::Channel::DEV); bool is_canary_dev = (channel == version_info::Channel::CANARY ||
const base::CommandLine& command_line = channel == version_info::Channel::DEV);
*base::CommandLine::ForCurrentProcess(); const base::CommandLine& command_line =
std::string process_type = *base::CommandLine::ForCurrentProcess();
command_line.GetSwitchValueASCII(switches::kProcessType); std::string process_type =
bool is_browser_process = process_type.empty(); command_line.GetSwitchValueASCII(switches::kProcessType);
gwp_asan::EnableForMalloc(is_canary_dev, is_browser_process); bool is_browser_process = process_type.empty();
gwp_asan::EnableForMalloc(is_canary_dev, is_browser_process);
}
#endif
#if BUILDFLAG(ENABLE_GWP_ASAN_PARTITIONALLOC)
{
version_info::Channel channel = chrome::GetChannel();
bool is_canary_dev = (channel == version_info::Channel::CANARY ||
channel == version_info::Channel::DEV);
gwp_asan::EnableForPartitionAlloc(is_canary_dev);
}
#endif #endif
} }
......
...@@ -7,5 +7,8 @@ import("//components/gwp_asan/buildflags/buildflags.gni") ...@@ -7,5 +7,8 @@ import("//components/gwp_asan/buildflags/buildflags.gni")
buildflag_header("buildflags") { buildflag_header("buildflags") {
header = "buildflags.h" header = "buildflags.h"
flags = [ "ENABLE_GWP_ASAN_MALLOC=$enable_gwp_asan_malloc" ] flags = [
"ENABLE_GWP_ASAN_MALLOC=$enable_gwp_asan_malloc",
"ENABLE_GWP_ASAN_PARTITIONALLOC=$enable_gwp_asan_partitionalloc",
]
} }
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
import("//build/config/allocator.gni") import("//build/config/allocator.gni")
declare_args() { declare_args() {
# Is GWP-ASan malloc() hooking enabled for chrome/ on a given platform. # Is GWP-ASan malloc/PartitionAlloc hooking enabled for chrome/ on a given
# platform.
enable_gwp_asan_malloc = (is_win || is_mac) && use_allocator_shim enable_gwp_asan_malloc = (is_win || is_mac) && use_allocator_shim
enable_gwp_asan_partitionalloc = (is_win || is_mac) && use_partition_alloc
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment