From 22823eed4be7b0456247bb0e6daf66192ba0f9cd Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Mon, 31 Jul 2023 18:01:26 +0000 Subject: [PATCH] Revert "rust: Add SCS sanitizer option for AArch64" This reverts commit 882711357738d2f78e33e001e9b04a9eaaa76654. Reason for revert: hwasan builds breaking Change-Id: I28094e27d5935c6f371fddddf4b6b0334de9b12c --- cc/sanitize.go | 22 +++++++++++----------- cc/vendor_snapshot.go | 2 +- rust/sanitize.go | 31 +------------------------------ 3 files changed, 13 insertions(+), 42 deletions(-) diff --git a/cc/sanitize.go b/cc/sanitize.go index a23e2db89..5c68a9625 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -96,7 +96,7 @@ const ( Hwasan tsan intOverflow - Scs + scs Fuzzer Memtag_heap Memtag_stack @@ -109,7 +109,7 @@ var Sanitizers = []SanitizerType{ Hwasan, tsan, intOverflow, - Scs, + scs, Fuzzer, Memtag_heap, Memtag_stack, @@ -130,7 +130,7 @@ func (t SanitizerType) variationName() string { return "intOverflow" case cfi: return "cfi" - case Scs: + case scs: return "scs" case Memtag_heap: return "memtag_heap" @@ -164,7 +164,7 @@ func (t SanitizerType) name() string { return "integer_overflow" case cfi: return "cfi" - case Scs: + case scs: return "shadow-call-stack" case Fuzzer: return "fuzzer" @@ -175,7 +175,7 @@ func (t SanitizerType) name() string { func (t SanitizerType) registerMutators(ctx android.RegisterMutatorsContext) { switch t { - case cfi, Hwasan, Asan, tsan, Fuzzer, Scs: + case cfi, Hwasan, Asan, tsan, Fuzzer, scs: sanitizer := &sanitizerSplitMutator{t} ctx.TopDown(t.variationName()+"_markapexes", sanitizer.markSanitizableApexesMutator) ctx.Transition(t.variationName(), sanitizer) @@ -212,7 +212,7 @@ func (*Module) SanitizerSupported(t SanitizerType) bool { return true case cfi: return true - case Scs: + case scs: return true case Fuzzer: return true @@ -1012,7 +1012,7 @@ func (s *sanitize) getSanitizerBoolPtr(t SanitizerType) *bool { return s.Properties.SanitizeMutated.Integer_overflow case cfi: return s.Properties.SanitizeMutated.Cfi - case Scs: + case scs: return s.Properties.SanitizeMutated.Scs case Memtag_heap: return s.Properties.SanitizeMutated.Memtag_heap @@ -1033,7 +1033,7 @@ func (sanitize *sanitize) isUnsanitizedVariant() bool { !sanitize.isSanitizerEnabled(Hwasan) && !sanitize.isSanitizerEnabled(tsan) && !sanitize.isSanitizerEnabled(cfi) && - !sanitize.isSanitizerEnabled(Scs) && + !sanitize.isSanitizerEnabled(scs) && !sanitize.isSanitizerEnabled(Memtag_heap) && !sanitize.isSanitizerEnabled(Memtag_stack) && !sanitize.isSanitizerEnabled(Memtag_globals) && @@ -1070,7 +1070,7 @@ func (sanitize *sanitize) SetSanitizer(t SanitizerType, b bool) { sanitize.Properties.SanitizeMutated.Integer_overflow = bPtr case cfi: sanitize.Properties.SanitizeMutated.Cfi = bPtr - case Scs: + case scs: sanitize.Properties.SanitizeMutated.Scs = bPtr case Memtag_heap: sanitize.Properties.SanitizeMutated.Memtag_heap = bPtr @@ -1330,7 +1330,7 @@ func (s *sanitizerSplitMutator) Mutate(mctx android.BottomUpMutatorContext, vari oneMakeVariation := false if c.StaticallyLinked() || c.Header() { - if s.sanitizer != cfi && s.sanitizer != Scs && s.sanitizer != Hwasan { + if s.sanitizer != cfi && s.sanitizer != scs && s.sanitizer != Hwasan { // These sanitizers export only one variation to Make. For the rest, // Make targets can depend on both the sanitized and non-sanitized // versions. @@ -1340,7 +1340,7 @@ func (s *sanitizerSplitMutator) Mutate(mctx android.BottomUpMutatorContext, vari // Shared library. These are the sanitizers that do propagate through shared // library dependencies and therefore can cause multiple variations of a // shared library to be built. - if s.sanitizer != cfi && s.sanitizer != Hwasan && s.sanitizer != Scs && s.sanitizer != Asan { + if s.sanitizer != cfi && s.sanitizer != Hwasan && s.sanitizer != scs && s.sanitizer != Asan { oneMakeVariation = true } } diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go index 2421e2408..9ea337b8d 100644 --- a/cc/vendor_snapshot.go +++ b/cc/vendor_snapshot.go @@ -95,7 +95,7 @@ func isSnapshotAware(cfg android.DeviceConfig, m LinkableInterface, inProprietar if sanitizable.SanitizePropDefined() { // scs exports both sanitized and unsanitized variants for static and header // Always use unsanitized variant of it. - if !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(Scs) { + if !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(scs) { return false } // cfi and hwasan also export both variants. But for static, we capture both. diff --git a/rust/sanitize.go b/rust/sanitize.go index e232b53e7..0f7cf6e5f 100644 --- a/rust/sanitize.go +++ b/rust/sanitize.go @@ -32,7 +32,6 @@ type SanitizeProperties struct { Sanitize struct { Address *bool `android:"arch_variant"` Hwaddress *bool `android:"arch_variant"` - Scs *bool `android:"arch_variant"` // Memory-tagging, only available on arm64 // if diag.memtag unset or false, enables async memory tagging @@ -76,9 +75,6 @@ var fuzzerFlags = []string{ var asanFlags = []string{ "-Z sanitizer=address", } -var scsFlags = []string{ - "-Z sanitizer=shadow-call-stack", -} // See cc/sanitize.go's hwasanGlobalOptions for global hwasan options. var hwasanFlags = []string{ @@ -212,15 +208,9 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { s.Memtag_heap = nil } - // SCS is only supported on AArch64 in Rust. - // TODO: Add riscv when riscv supported. - if (ctx.Arch().ArchType != android.Arm64) || !ctx.toolchain().Bionic() { - s.Scs = nil - } - // TODO:(b/178369775) // For now sanitizing is only supported on devices - if ctx.Os() == android.Android && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer) || Bool(s.Scs)) { + if ctx.Os() == android.Android && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer)) { sanitize.Properties.SanitizerEnabled = true } } @@ -239,10 +229,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags, deps PathDeps) ( flags.RustFlags = append(flags.RustFlags, hwasanFlags...) } else if Bool(sanitize.Properties.Sanitize.Address) { flags.RustFlags = append(flags.RustFlags, asanFlags...) - } else if Bool(sanitize.Properties.Sanitize.Scs) { - flags.RustFlags = append(flags.RustFlags, scsFlags...) } - return flags, deps } @@ -324,9 +311,6 @@ func (sanitize *sanitize) SetSanitizer(t cc.SanitizerType, b bool) { case cc.Memtag_heap: sanitize.Properties.Sanitize.Memtag_heap = boolPtr(b) sanitizerSet = true - case cc.Scs: - sanitize.Properties.Sanitize.Scs = boolPtr(b) - sanitizerSet = true default: panic(fmt.Errorf("setting unsupported sanitizerType %d", t)) } @@ -388,8 +372,6 @@ func (sanitize *sanitize) getSanitizerBoolPtr(t cc.SanitizerType) *bool { return sanitize.Properties.Sanitize.Hwaddress case cc.Memtag_heap: return sanitize.Properties.Sanitize.Memtag_heap - case cc.Scs: - return sanitize.Properties.Sanitize.Scs default: return nil } @@ -402,10 +384,6 @@ func (sanitize *sanitize) AndroidMk(ctx AndroidMkContext, entries *android.Andro if sanitize.isSanitizerEnabled(cc.Hwasan) { entries.SubName += ".hwasan" } - if sanitize.isSanitizerEnabled(cc.Scs) { - entries.SubName += ".scs" - } - } } @@ -426,13 +404,6 @@ func (mod *Module) SanitizerSupported(t cc.SanitizerType) bool { return true case cc.Memtag_heap: return true - case cc.Scs: - // SCS is only supported on AArch64 in Rust. - // TODO: Add riscv when riscv supported. - if mod.Target().Arch.ArchType == android.Arm64 { - return true - } - return false default: return false }