Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a0e2d20 authored by Liz Kammer's avatar Liz Kammer Committed by Gerrit Code Review
Browse files

Merge changes If89b7d0b,I630c06f0,Id861a62b,If71bb468

* changes:
  Iterate over sanitizers
  Update memtag code behavior to match comment.
  Reorganize memtag tests for clarity.
  Add comments to sanitizer properties.
parents ec044175 75db9318
Loading
Loading
Loading
Loading
+3 −19
Original line number Original line Diff line number Diff line
@@ -53,25 +53,9 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
	})
	})


	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
		ctx.TopDown("asan_deps", sanitizerDepsMutator(Asan))
		for _, san := range Sanitizers {
		ctx.BottomUp("asan", sanitizerMutator(Asan)).Parallel()
			san.registerMutators(ctx)

		}
		ctx.TopDown("hwasan_deps", sanitizerDepsMutator(Hwasan))
		ctx.BottomUp("hwasan", sanitizerMutator(Hwasan)).Parallel()

		ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(Fuzzer))
		ctx.BottomUp("fuzzer", sanitizerMutator(Fuzzer)).Parallel()

		// cfi mutator shouldn't run before sanitizers that return true for
		// incompatibleWithCfi()
		ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi))
		ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel()

		ctx.TopDown("scs_deps", sanitizerDepsMutator(scs))
		ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel()

		ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
		ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()


		ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
		ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
		ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
		ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
+87 −28
Original line number Original line Diff line number Diff line
@@ -79,12 +79,23 @@ const (
	Hwasan
	Hwasan
	tsan
	tsan
	intOverflow
	intOverflow
	cfi
	scs
	scs
	Fuzzer
	Fuzzer
	memtag_heap
	memtag_heap
	cfi // cfi is last to prevent it running before incompatible mutators
)
)


var Sanitizers = []SanitizerType{
	Asan,
	Hwasan,
	tsan,
	intOverflow,
	scs,
	Fuzzer,
	memtag_heap,
	cfi, // cfi is last to prevent it running before incompatible mutators
}

// Name of the sanitizer variation for this sanitizer type
// Name of the sanitizer variation for this sanitizer type
func (t SanitizerType) variationName() string {
func (t SanitizerType) variationName() string {
	switch t {
	switch t {
@@ -133,6 +144,18 @@ func (t SanitizerType) name() string {
	}
	}
}
}


func (t SanitizerType) registerMutators(ctx android.RegisterMutatorsContext) {
	switch t {
	case Asan, Hwasan, Fuzzer, scs, tsan, cfi:
		ctx.TopDown(t.variationName()+"_deps", sanitizerDepsMutator(t))
		ctx.BottomUp(t.variationName(), sanitizerMutator(t))
	case memtag_heap, intOverflow:
		// do nothing
	default:
		panic(fmt.Errorf("unknown SanitizerType %d", t))
	}
}

func (*Module) SanitizerSupported(t SanitizerType) bool {
func (*Module) SanitizerSupported(t SanitizerType) bool {
	switch t {
	switch t {
	case Asan:
	case Asan:
@@ -160,23 +183,45 @@ func (t SanitizerType) incompatibleWithCfi() bool {
}
}


type SanitizeUserProps struct {
type SanitizeUserProps struct {
	// Prevent use of any sanitizers on this module
	Never *bool `android:"arch_variant"`
	Never *bool `android:"arch_variant"`


	// main sanitizers
	// ASan (Address sanitizer), incompatible with static binaries.
	// Always runs in a diagnostic mode.
	// Use of address sanitizer disables cfi sanitizer.
	// Hwaddress sanitizer takes precedence over this sanitizer.
	Address *bool `android:"arch_variant"`
	Address *bool `android:"arch_variant"`
	// TSan (Thread sanitizer), incompatible with static binaries and 32 bit architectures.
	// Always runs in a diagnostic mode.
	// Use of thread sanitizer disables cfi and scudo sanitizers.
	// Hwaddress sanitizer takes precedence over this sanitizer.
	Thread *bool `android:"arch_variant"`
	Thread *bool `android:"arch_variant"`
	// HWASan (Hardware Address sanitizer).
	// Use of hwasan sanitizer disables cfi, address, thread, and scudo sanitizers.
	Hwaddress *bool `android:"arch_variant"`
	Hwaddress *bool `android:"arch_variant"`


	// local sanitizers
	// Undefined behavior sanitizer
	Undefined        *bool    `android:"arch_variant"`
	All_undefined *bool `android:"arch_variant"`
	All_undefined *bool `android:"arch_variant"`
	// Subset of undefined behavior sanitizer
	Undefined *bool `android:"arch_variant"`
	// List of specific undefined behavior sanitizers to enable
	Misc_undefined []string `android:"arch_variant"`
	Misc_undefined []string `android:"arch_variant"`
	// Fuzzer, incompatible with static binaries.
	Fuzzer *bool `android:"arch_variant"`
	Fuzzer *bool `android:"arch_variant"`
	// safe-stack sanitizer, incompatible with 32-bit architectures.
	Safestack *bool `android:"arch_variant"`
	Safestack *bool `android:"arch_variant"`
	// cfi sanitizer, incompatible with asan, hwasan, fuzzer, or Darwin
	Cfi *bool `android:"arch_variant"`
	Cfi *bool `android:"arch_variant"`
	// signed/unsigned integer overflow sanitizer, incompatible with Darwin.
	Integer_overflow *bool `android:"arch_variant"`
	Integer_overflow *bool `android:"arch_variant"`
	// scudo sanitizer, incompatible with asan, hwasan, tsan
	// This should not be used in Android 11+ : https://source.android.com/devices/tech/debug/scudo
	// deprecated
	Scudo *bool `android:"arch_variant"`
	Scudo *bool `android:"arch_variant"`
	// shadow-call-stack sanitizer, only available on arm64
	Scs *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
	Memtag_heap *bool `android:"arch_variant"`
	Memtag_heap *bool `android:"arch_variant"`


	// A modifier for ASAN and HWASAN for write only instrumentation
	// A modifier for ASAN and HWASAN for write only instrumentation
@@ -186,11 +231,21 @@ type SanitizeUserProps struct {
	// Replaces abort() on error with a human-readable error message.
	// Replaces abort() on error with a human-readable error message.
	// Address and Thread sanitizers always run in diagnostic mode.
	// Address and Thread sanitizers always run in diagnostic mode.
	Diag struct {
	Diag struct {
		// Undefined behavior sanitizer, diagnostic mode
		Undefined *bool `android:"arch_variant"`
		Undefined *bool `android:"arch_variant"`
		// cfi sanitizer, diagnostic mode, incompatible with asan, hwasan, fuzzer, or Darwin
		Cfi *bool `android:"arch_variant"`
		Cfi *bool `android:"arch_variant"`
		// signed/unsigned integer overflow sanitizer, diagnostic mode, incompatible with Darwin.
		Integer_overflow *bool `android:"arch_variant"`
		Integer_overflow *bool `android:"arch_variant"`
		// Memory-tagging, only available on arm64
		// requires sanitizer.memtag: true
		// if set, enables sync memory tagging
		Memtag_heap *bool `android:"arch_variant"`
		Memtag_heap *bool `android:"arch_variant"`
		// List of specific undefined behavior sanitizers to enable in diagnostic mode
		Misc_undefined []string `android:"arch_variant"`
		Misc_undefined []string `android:"arch_variant"`
		// List of sanitizers to pass to -fno-sanitize-recover
		// results in only the first detected error for these sanitizers being reported and program then
		// exits with a non-zero exit code.
		No_recover []string `android:"arch_variant"`
		No_recover []string `android:"arch_variant"`
	} `android:"arch_variant"`
	} `android:"arch_variant"`


@@ -200,7 +255,9 @@ type SanitizeUserProps struct {
		Cfi_assembly_support *bool `android:"arch_variant"`
		Cfi_assembly_support *bool `android:"arch_variant"`
	} `android:"arch_variant"`
	} `android:"arch_variant"`


	// value to pass to -fsanitize-recover=
	// List of sanitizers to pass to -fsanitize-recover
	// allows execution to continue for these sanitizers to detect multiple errors rather than only
	// the first one
	Recover []string
	Recover []string


	// value to pass to -fsanitize-blacklist
	// value to pass to -fsanitize-blacklist
@@ -208,9 +265,7 @@ type SanitizeUserProps struct {
}
}


type SanitizeProperties struct {
type SanitizeProperties struct {
	// Enable AddressSanitizer, ThreadSanitizer, UndefinedBehaviorSanitizer, and
	// Sanitizers are not supported for Fuchsia.
	// others. Please see SanitizerUserProps in build/soong/cc/sanitize.go for
	// details.
	Sanitize          SanitizeUserProps `android:"arch_variant"`
	Sanitize          SanitizeUserProps `android:"arch_variant"`
	SanitizerEnabled  bool              `blueprint:"mutated"`
	SanitizerEnabled  bool              `blueprint:"mutated"`
	SanitizeDep       bool              `blueprint:"mutated"`
	SanitizeDep       bool              `blueprint:"mutated"`
@@ -261,10 +316,14 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
	}
	}


	// cc_test targets default to SYNC MemTag unless explicitly set to ASYNC (via diag: {memtag_heap}).
	// cc_test targets default to SYNC MemTag unless explicitly set to ASYNC (via diag: {memtag_heap}).
	if ctx.testBinary() && s.Memtag_heap == nil {
	if ctx.testBinary() {
		if s.Memtag_heap == nil {
			s.Memtag_heap = proptools.BoolPtr(true)
			s.Memtag_heap = proptools.BoolPtr(true)
		}
		if s.Diag.Memtag_heap == nil {
			s.Diag.Memtag_heap = proptools.BoolPtr(true)
			s.Diag.Memtag_heap = proptools.BoolPtr(true)
		}
		}
	}


	var globalSanitizers []string
	var globalSanitizers []string
	var globalSanitizersDiag []string
	var globalSanitizersDiag []string
+216 −164

File changed.

Preview size limit exceeded, changes collapsed.