Skip to content

Commit

Permalink
Make sanitizer suppressions and blacklists fully configurable.
Browse files Browse the repository at this point in the history
This will make it possible to fully utilize the sanitizers in other
projects that may need to maintain their own suppressions and blacklists.

This change also removes the requirement on having {asan,lsan,tsan}_suppressions_file
defined in //build_overrides/build.gni, simplifying the build configs.

BUG=webrtc:5006
TESTED=CQ dry run + additional sanitizer trybots:
mac_chromium_asan_rel_ng
linux_chromium_ubsan_rel_ng
linux_chromium_msan_rel_ng
linux_chromium_tsan_rel_ng
linux_chromium_asan_rel_ng

Review-Url: https://codereview.chromium.org/2580313002
Cr-Commit-Position: refs/heads/master@{#439452}
  • Loading branch information
kjellander authored and Commit bot committed Dec 19, 2016
1 parent 7456f5a commit 83d8599
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 22 deletions.
61 changes: 43 additions & 18 deletions build/config/sanitizers/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,23 @@ static_library("options_sources") {
configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]

if (is_asan) {
if (!defined(asan_suppressions_file)) {
asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
}
sources += [ asan_suppressions_file ]
}

if (is_lsan) {
if (!defined(lsan_suppressions_file)) {
lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
}
sources += [ lsan_suppressions_file ]
}

if (is_tsan) {
if (!defined(tsan_suppressions_file)) {
tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc"
}
sources += [ tsan_suppressions_file ]
}
}
Expand Down Expand Up @@ -307,14 +316,18 @@ config("asan_flags") {
]
}
if (is_win) {
cflags += [ "-fsanitize-blacklist=" +
rebase_path("//tools/memory/asan/blacklist_win.txt",
root_build_dir) ]
if (!defined(asan_win_blacklist_path)) {
asan_win_blacklist_path =
rebase_path("//tools/memory/asan/blacklist_win.txt", root_build_dir)
}
cflags += [ "-fsanitize-blacklist=$asan_win_blacklist_path" ]
} else {
# TODO(rnk): Remove this as discussed in http://crbug.com/427202.
cflags +=
[ "-fsanitize-blacklist=" +
rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir) ]
if (!defined(asan_blacklist_path)) {
asan_blacklist_path =
rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir)
}
cflags += [ "-fsanitize-blacklist=$asan_blacklist_path" ]
}
}
}
Expand Down Expand Up @@ -348,8 +361,10 @@ config("link_shared_library") {
config("cfi_flags") {
cflags = []
if (is_cfi && !is_nacl) {
cfi_blacklist_path =
rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
if (!defined(cfi_blacklist_path)) {
cfi_blacklist_path =
rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
}
cflags += [
"-fsanitize=cfi-vcall",
"-fsanitize-blacklist=$cfi_blacklist_path",
Expand Down Expand Up @@ -406,8 +421,10 @@ config("lsan_flags") {
config("msan_flags") {
if (is_msan) {
assert(is_linux, "msan only supported on linux x86_64")
msan_blacklist_path =
rebase_path("//tools/msan/blacklist.txt", root_build_dir)
if (!defined(msan_blacklist_path)) {
msan_blacklist_path =
rebase_path("//tools/msan/blacklist.txt", root_build_dir)
}
cflags = [
"-fsanitize=memory",
"-fsanitize-memory-track-origins=$msan_track_origins",
Expand All @@ -419,8 +436,10 @@ config("msan_flags") {
config("tsan_flags") {
if (is_tsan) {
assert(is_linux, "tsan only supported on linux x86_64")
tsan_blacklist_path =
rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
if (!defined(tsan_blacklist_path)) {
tsan_blacklist_path =
rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
}
cflags = [
"-fsanitize=thread",
"-fsanitize-blacklist=$tsan_blacklist_path",
Expand All @@ -434,8 +453,10 @@ config("tsan_flags") {
config("ubsan_flags") {
cflags = []
if (is_ubsan) {
ubsan_blacklist_path =
rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
if (!defined(ubsan_blacklist_path)) {
ubsan_blacklist_path =
rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
}
cflags += [
# Yasm dies with an "Illegal instruction" error when bounds checking is
# enabled. See http://crbug.com/489901
Expand Down Expand Up @@ -481,8 +502,10 @@ config("ubsan_no_recover") {

config("ubsan_security_flags") {
if (is_ubsan_security) {
ubsan_security_blacklist_path =
rebase_path("//tools/ubsan/security_blacklist.txt", root_build_dir)
if (!defined(ubsan_security_blacklist_path)) {
ubsan_security_blacklist_path =
rebase_path("//tools/ubsan/security_blacklist.txt", root_build_dir)
}
cflags = [
"-fsanitize=signed-integer-overflow,shift,vptr,function,vla-bound",
"-fsanitize-blacklist=$ubsan_security_blacklist_path",
Expand All @@ -498,8 +521,10 @@ config("ubsan_null_flags") {

config("ubsan_vptr_flags") {
if (is_ubsan_vptr) {
ubsan_vptr_blacklist_path =
rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
if (!defined(ubsan_vptr_blacklist_path)) {
ubsan_vptr_blacklist_path =
rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
}
cflags = [
"-fsanitize=vptr",
"-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
Expand Down
17 changes: 13 additions & 4 deletions build_overrides/build.gni
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ enable_java_templates = true
# Some non-Chromium builds don't use Chromium's third_party/binutils.
linux_use_bundled_binutils_override = true

# Allows different projects to specify their own suppressions files.
asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc"
# Allows different projects to specify their own suppressions and blacklist
# files for sanitizer tools.
# asan_suppressions_file = "path/to/asan_suppressions.cc"
# asan_blacklist_path = "path/to/asan/blacklist.txt"
# asan_win_blacklist_path = "path/to/asan/blacklist_win.txt"
# lsan_suppressions_file = "path/to/lsan_suppressions.cc"
# tsan_suppressions_file = "path/to/tsan_suppressions.cc"
# tsan_blacklist_path = "path/to/tsan/ignores.txt"
# msan_blacklist_path = "path/to/msan/blacklist.txt"
# ubsan_blacklist_path = "path/to/ubsan/blacklist.txt"
# ubsan_vptr_blacklist_path = "path/to/ubsan/vptr_blacklist.txt"
# ubsan_security_blacklist_path = "path/to/ubsan/security_blacklist.txt"
# cfi_blacklist_path = "path/to/cfi/blacklist.txt"

# Uncomment these to specify a different lint suppressions file for android
# lint_suppressions_file = path/to/your/suppressions/file/suppressions.xml
Expand Down

0 comments on commit 83d8599

Please sign in to comment.