Add support for misc_undefined diagnostics

Setting Sanitize.Diag.Undefined to true does not enable diagnostics for
all possible UBSan sanitizers that might be declared in Sanitize.Misc_undefined
(specifically unsigned-integer-overflow and nullability-*). This adds an
equivalent Sanitize.Diag.Misc_undefined string array to allow diagnostics to
be enabled in these sanitizers.

Bug: 62546512
Test: make works and device boots.
Test: Tested an Android.bp generated binary with the new field enabling
unsigned-integer-overflow diagnostics.

Change-Id: I9aa7cb2555ab4f94ae1aa290715a617718d936ff
This commit is contained in:
Ivan Lozano 2017-06-13 10:24:34 -07:00
parent aac67d38b2
commit 651275ba90

View file

@ -85,8 +85,9 @@ type SanitizeProperties struct {
// Replaces abort() on error with a human-readable error message.
// Address and Thread sanitizers always run in diagnostic mode.
Diag struct {
Undefined *bool `android:"arch_variant"`
Cfi *bool `android:"arch_variant"`
Undefined *bool `android:"arch_variant"`
Cfi *bool `android:"arch_variant"`
Misc_undefined []string `android:"arch_variant"`
}
// value to pass to -fsanitize-recover=
@ -287,13 +288,12 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...)
}
if Bool(sanitize.Properties.Sanitize.Diag.Undefined) &&
(Bool(sanitize.Properties.Sanitize.All_undefined) ||
Bool(sanitize.Properties.Sanitize.Undefined) ||
len(sanitize.Properties.Sanitize.Misc_undefined) > 0) {
if Bool(sanitize.Properties.Sanitize.Diag.Undefined) {
diagSanitizers = append(diagSanitizers, "undefined")
}
diagSanitizers = append(diagSanitizers, sanitize.Properties.Sanitize.Diag.Misc_undefined...)
if Bool(sanitize.Properties.Sanitize.Address) {
if ctx.Arch().ArchType == android.Arm {
// Frame pointer based unwinder in ASan requires ARM frame setup.