Small changes

- hardenDefconfig: more options from Alexander Popov's checker
- 17.1: A2DP fix from GrapheneOS when hardened_malloc is in use
This commit is contained in:
Tad 2020-05-23 18:06:22 -04:00
parent 4b376037e0
commit 4c1577724f
3 changed files with 43 additions and 2 deletions

View File

@ -0,0 +1,38 @@
From 1618789e3f5e0b844916524da2229a3e08ceabfa Mon Sep 17 00:00:00 2001
From: Oscar Mira <valldrac@pm.me>
Date: Sun, 10 May 2020 01:56:34 +0200
Subject: [PATCH] Fix AudioPolicy device entries order to support
SLOT_RANDOMIZE
Fix GrapheneOS/os_issue_tracker#137
---
.../include/DeviceDescriptor.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
index 33e506f1b..5f9f8b558 100644
--- a/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
+++ b/services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h
@@ -206,6 +206,22 @@ class DeviceVector : public SortedVector<sp<DeviceDescriptor> >
void dump(String8 *dst, const String8 &tag, int spaces = 0, bool verbose = true) const;
+protected:
+ // Sorts devices by type.
+ int do_compare(const void* lhs, const void* rhs) const override
+ {
+ const auto& l = *reinterpret_cast<const sp<DeviceDescriptor>*>(lhs);
+ const auto& r = *reinterpret_cast<const sp<DeviceDescriptor>*>(rhs);
+
+ audio_devices_t lt = l->type();
+ audio_devices_t rt = r->type();
+
+ if (lt == rt) {
+ return 0;
+ }
+ return lt > rt ? 1 : -1;
+ }
+
private:
void refreshTypes();
audio_devices_t mDeviceTypes;

View File

@ -582,7 +582,7 @@ hardenDefconfig() {
#Enable supported options
#Disabled: CONFIG_DEBUG_SG (bootloops - https://patchwork.kernel.org/patch/8989981)
declare -a optionsYes=("CONFIG_ARM64_PTR_AUTH" "CONFIG_ARM64_SW_TTBR0_PAN" "CONFIG_ARM64_UAO" "CONFIG_ARM_SMMU" "CONFIG_ASYMMETRIC_KEY_TYPE" "CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE" "CONFIG_BUG" "CONFIG_BUG_ON_DATA_CORRUPTION" "CONFIG_CC_STACKPROTECTOR" "CONFIG_CC_STACKPROTECTOR_STRONG" "CONFIG_CPU_SW_DOMAIN_PAN" "CONFIG_DEBUG_CREDENTIALS" "CONFIG_DEBUG_KERNEL" "CONFIG_DEBUG_LIST" "CONFIG_DEBUG_NOTIFIERS" "CONFIG_DEBUG_RODATA" "CONFIG_DEBUG_SET_MODULE_RONX" "CONFIG_DEBUG_VIRTUAL" "CONFIG_DEBUG_WX" "CONFIG_DM_ANDROID_VERITY" "CONFIG_DM_VERITY" "CONFIG_DM_VERITY_FEC" "CONFIG_EXYNOS_IOMMU" "CONFIG_FORTIFY_SOURCE" "CONFIG_HARDEN_BRANCH_PREDICTOR" "CONFIG_HARDENED_USERCOPY" "CONFIG_HARDEN_EL2_VECTORS" "CONFIG_INIT_STACK_ALL" "CONFIG_INTEL_IOMMU_DEFAULT_ON" "CONFIG_IOMMU_API" "CONFIG_IOMMU_HELPER" "CONFIG_IOMMU_PGTABLES_L2" "CONFIG_IOMMU_SUPPORT" "CONFIG_IO_STRICT_DEVMEM" "CONFIG_IPV6_PRIVACY" "CONFIG_KAISER" "CONFIG_KGSL_PER_PROCESS_PAGE_TABLE" "CONFIG_LEGACY_VSYSCALL_NONE" "CONFIG_MMC_SECDISCARD" "CONFIG_MSM_IOMMU" "CONFIG_MSM_KGSL_MMU_PAGE_FAULT" "CONFIG_MSM_TZ_SMMU" "CONFIG_MTK_IOMMU" "CONFIG_OF_IOMMU" "CONFIG_OMAP_IOMMU" "CONFIG_PAGE_POISONING" "CONFIG_PAGE_POISONING_NO_SANITY" "CONFIG_PAGE_POISONING_ZERO" "CONFIG_PAGE_TABLE_ISOLATION" "CONFIG_PANIC_ON_OOPS" "CONFIG_PKCS7_MESSAGE_PARSER" "CONFIG_QCOM_IOMMU" "CONFIG_RANDOMIZE_BASE" "CONFIG_RANDOMIZE_MEMORY" "CONFIG_REFCOUNT_FULL" "CONFIG_RETPOLINE" "CONFIG_SCHED_STACK_END_CHECK" "CONFIG_SECCOMP" "CONFIG_SECCOMP_FILTER" "CONFIG_SECURITY" "CONFIG_SECURITY_DMESG_RESTRICT" "CONFIG_SECURITY_PERF_EVENTS_RESTRICT" "CONFIG_SECURITY_YAMA" "CONFIG_SECURITY_YAMA_STACKED" "CONFIG_SHUFFLE_PAGE_ALLOCATOR" "CONFIG_SLAB_FREELIST_HARDENED" "CONFIG_SLAB_FREELIST_RANDOM" "CONFIG_SLAB_HARDENED" "CONFIG_SLUB_DEBUG" "CONFIG_SLUB_HARDENED" "CONFIG_STACKPROTECTOR" "CONFIG_STACKPROTECTOR_STRONG" "CONFIG_STATIC_USERMODEHELPER" "CONFIG_STRICT_DEVMEM" "CONFIG_STRICT_KERNEL_RWX" "CONFIG_STRICT_MEMORY_RWX" "CONFIG_STRICT_MODULE_RWX" "CONFIG_SYN_COOKIES" "CONFIG_SYSTEM_TRUSTED_KEYRING" "CONFIG_TEGRA_IOMMU_GART" "CONFIG_TEGRA_IOMMU_SMMU" "CONFIG_THREAD_INFO_IN_TASK" "CONFIG_UNMAP_KERNEL_AT_EL0" "CONFIG_VMAP_STACK" "CONFIG_X509_CERTIFICATE_PARSER")
declare -a optionsYes=("CONFIG_ARM64_PTR_AUTH" "CONFIG_ARM64_SW_TTBR0_PAN" "CONFIG_ARM64_UAO" "CONFIG_ARM_SMMU" "CONFIG_ASYMMETRIC_KEY_TYPE" "CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE" "CONFIG_BUG" "CONFIG_BUG_ON_DATA_CORRUPTION" "CONFIG_CC_STACKPROTECTOR" "CONFIG_CC_STACKPROTECTOR_STRONG" "CONFIG_CPU_SW_DOMAIN_PAN" "CONFIG_DEBUG_CREDENTIALS" "CONFIG_DEBUG_KERNEL" "CONFIG_DEBUG_LIST" "CONFIG_DEBUG_NOTIFIERS" "CONFIG_DEBUG_RODATA" "CONFIG_DEBUG_SET_MODULE_RONX" "CONFIG_DEBUG_VIRTUAL" "CONFIG_DEBUG_WX" "CONFIG_DM_ANDROID_VERITY" "CONFIG_DM_VERITY" "CONFIG_DM_VERITY_FEC" "CONFIG_EXYNOS_IOMMU" "CONFIG_FORTIFY_SOURCE" "CONFIG_HARDEN_BRANCH_PREDICTOR" "CONFIG_HARDENED_USERCOPY" "CONFIG_HARDEN_EL2_VECTORS" "CONFIG_INIT_ON_ALLOC_DEFAULT_ON" "CONFIG_INIT_ON_FREE_DEFAULT_ON" "CONFIG_INIT_STACK_ALL" "CONFIG_INTEL_IOMMU_DEFAULT_ON" "CONFIG_IOMMU_API" "CONFIG_IOMMU_HELPER" "CONFIG_IOMMU_PGTABLES_L2" "CONFIG_IOMMU_SUPPORT" "CONFIG_IO_STRICT_DEVMEM" "CONFIG_IPV6_PRIVACY" "CONFIG_KAISER" "CONFIG_KGSL_PER_PROCESS_PAGE_TABLE" "CONFIG_LEGACY_VSYSCALL_NONE" "CONFIG_MMC_SECDISCARD" "CONFIG_MSM_IOMMU" "CONFIG_MSM_KGSL_MMU_PAGE_FAULT" "CONFIG_MSM_TZ_SMMU" "CONFIG_MTK_IOMMU" "CONFIG_OF_IOMMU" "CONFIG_OMAP_IOMMU" "CONFIG_PAGE_POISONING" "CONFIG_PAGE_POISONING_NO_SANITY" "CONFIG_PAGE_POISONING_ZERO" "CONFIG_PAGE_TABLE_ISOLATION" "CONFIG_PANIC_ON_OOPS" "CONFIG_PKCS7_MESSAGE_PARSER" "CONFIG_QCOM_IOMMU" "CONFIG_RANDOMIZE_BASE" "CONFIG_RANDOMIZE_MEMORY" "CONFIG_REFCOUNT_FULL" "CONFIG_RETPOLINE" "CONFIG_RODATA_FULL_DEFAULT_ENABLED" "CONFIG_SCHED_STACK_END_CHECK" "CONFIG_SECCOMP" "CONFIG_SECCOMP_FILTER" "CONFIG_SECURITY" "CONFIG_SECURITY_DMESG_RESTRICT" "CONFIG_SECURITY_PERF_EVENTS_RESTRICT" "CONFIG_SECURITY_YAMA" "CONFIG_SECURITY_YAMA_STACKED" "CONFIG_SHUFFLE_PAGE_ALLOCATOR" "CONFIG_SLAB_FREELIST_HARDENED" "CONFIG_SLAB_FREELIST_RANDOM" "CONFIG_SLAB_HARDENED" "CONFIG_SLUB_DEBUG" "CONFIG_SLUB_HARDENED" "CONFIG_STACKPROTECTOR" "CONFIG_STACKPROTECTOR_PER_TASK" "CONFIG_STACKPROTECTOR_STRONG" "CONFIG_STATIC_USERMODEHELPER" "CONFIG_STRICT_DEVMEM" "CONFIG_STRICT_KERNEL_RWX" "CONFIG_STRICT_MEMORY_RWX" "CONFIG_STRICT_MODULE_RWX" "CONFIG_SYN_COOKIES" "CONFIG_SYSTEM_TRUSTED_KEYRING" "CONFIG_TEGRA_IOMMU_GART" "CONFIG_TEGRA_IOMMU_SMMU" "CONFIG_THREAD_INFO_IN_TASK" "CONFIG_UNMAP_KERNEL_AT_EL0" "CONFIG_VMAP_STACK" "CONFIG_X509_CERTIFICATE_PARSER")
#optionsYes+=("CONFIG_GCC_PLUGINS" "CONFIG_GCC_PLUGIN_LATENT_ENTROPY" "CONFIG_GCC_PLUGIN_RANDSTRUCT" "CONFIG_GCC_PLUGIN_STRUCTLEAK" "CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL");
optionsYes+=("CONFIG_PAGE_SANITIZE" "CONFIG_PAGE_SANITIZE_VERIFY" "CONFIG_SLAB_CANARY" "CONFIG_SLAB_SANITIZE" "CONFIG_SLAB_SANITIZE_VERIFY");
#if [ "$DOS_DEBLOBBER_REPLACE_TIME" = true ]; then optionsYes+=("CONFIG_RTC_DRV_MSM" "CONFIG_RTC_DRV_PM8XXX" "CONFIG_RTC_DRV_MSM7X00A" "CONFIG_RTC_DRV_QPNP"); fi;
@ -598,7 +598,7 @@ hardenDefconfig() {
done
#Disable supported options
#Disabled: CONFIG_MSM_SMP2P_TEST, CONFIG_MAGIC_SYSRQ (breaks compile on many kernels), CONFIG_KALLSYMS (breaks boot on select devices), CONFIG_IKCONFIG (breaks recovery)
declare -a optionsNo=("CONFIG_ACPI_APEI_EINJ" "CONFIG_ACPI_CUSTOM_METHOD" "CONFIG_ACPI_TABLE_UPGRADE" "CONFIG_BINFMT_AOUT" "CONFIG_BINFMT_MISC" "CONFIG_CHECKPOINT_RESTORE" "CONFIG_COMPAT_BRK" "CONFIG_COMPAT_VDSO" "CONFIG_CP_ACCESS64" "CONFIG_DEVKMEM" "CONFIG_DEVMEM" "CONFIG_DEVPORT" "CONFIG_EARJACK_DEBUGGER" "CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE" "CONFIG_HARDENED_USERCOPY_FALLBACK" "CONFIG_HIBERNATION" "CONFIG_HWPOISON_INJECT" "CONFIG_IA32_EMULATION" "CONFIG_IOMMU_NON_SECURE" "CONFIG_IP_DCCP" "CONFIG_IP_SCTP" "CONFIG_KEXEC" "CONFIG_KEXEC_FILE" "CONFIG_KSM" "CONFIG_LDISC_AUTOLOAD" "CONFIG_LEGACY_PTYS" "CONFIG_LIVEPATCH" "CONFIG_MEM_SOFT_DIRTY" "CONFIG_MMIOTRACE" "CONFIG_MMIOTRACE_TEST" "CONFIG_MODIFY_LDT_SYSCALL" "CONFIG_MSM_BUSPM_DEV" "CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG" "CONFIG_NOTIFIER_ERROR_INJECTION" "CONFIG_OABI_COMPAT" "CONFIG_PAGE_OWNER" "CONFIG_PROC_KCORE" "CONFIG_PROC_PAGE_MONITOR" "CONFIG_PROC_VMCORE" "CONFIG_RDS" "CONFIG_RDS_TCP" "CONFIG_SECURITY_SELINUX_DISABLE" "CONFIG_SLAB_MERGE_DEFAULT" "CONFIG_TIMER_STATS" "CONFIG_TSC" "CONFIG_TSPP2" "CONFIG_UKSM" "CONFIG_UPROBES" "CONFIG_USELIB" "CONFIG_USERFAULTFD" "CONFIG_WLAN_FEATURE_MEMDUMP" "CONFIG_X86_PTDUMP" "CONFIG_X86_VSYSCALL_EMULATION" "CONFIG_ZSMALLOC_STAT");
declare -a optionsNo=("CONFIG_ACPI_APEI_EINJ" "CONFIG_ACPI_CUSTOM_METHOD" "CONFIG_ACPI_TABLE_UPGRADE" "CONFIG_AIO" "CONFIG_BINFMT_AOUT" "CONFIG_BINFMT_MISC" "CONFIG_CHECKPOINT_RESTORE" "CONFIG_COMPAT_BRK" "CONFIG_COMPAT_VDSO" "CONFIG_CP_ACCESS64" "CONFIG_DEBUG_KMEMLEAK" "CONFIG_DEVKMEM" "CONFIG_DEVMEM" "CONFIG_DEVPORT" "CONFIG_EARJACK_DEBUGGER" "CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE" "CONFIG_HARDENED_USERCOPY_FALLBACK" "CONFIG_HIBERNATION" "CONFIG_HWPOISON_INJECT" "CONFIG_IA32_EMULATION" "CONFIG_IOMMU_NON_SECURE" "CONFIG_INPUT_EVBUG" "CONFIG_IP_DCCP" "CONFIG_IP_SCTP" "CONFIG_KEXEC" "CONFIG_KEXEC_FILE" "CONFIG_KSM" "CONFIG_LDISC_AUTOLOAD" "CONFIG_LEGACY_PTYS" "CONFIG_LIVEPATCH" "CONFIG_MEM_SOFT_DIRTY" "CONFIG_MMIOTRACE" "CONFIG_MMIOTRACE_TEST" "CONFIG_MODIFY_LDT_SYSCALL" "CONFIG_MSM_BUSPM_DEV" "CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG" "CONFIG_NOTIFIER_ERROR_INJECTION" "CONFIG_OABI_COMPAT" "CONFIG_PAGE_OWNER" "CONFIG_PROC_KCORE" "CONFIG_PROC_PAGE_MONITOR" "CONFIG_PROC_VMCORE" "CONFIG_RDS" "CONFIG_RDS_TCP" "CONFIG_SECURITY_SELINUX_DISABLE" "CONFIG_SECURITY_WRITABLE_HOOKS" "CONFIG_SLAB_MERGE_DEFAULT" "CONFIG_STACKLEAK_METRICS" "CONFIG_STACKLEAK_RUNTIME_DISABLE" "CONFIG_TIMER_STATS" "CONFIG_TSC" "CONFIG_TSPP2" "CONFIG_UKSM" "CONFIG_UPROBES" "CONFIG_USELIB" "CONFIG_USERFAULTFD" "CONFIG_VIDEO_VIVID" "CONFIG_WLAN_FEATURE_MEMDUMP" "CONFIG_X86_IOPL_IOPERM" "CONFIG_X86_PTDUMP" "CONFIG_X86_VSYSCALL_EMULATION" "CONFIG_ZSMALLOC_STAT");
if [[ "$1" != *"kernel/htc/msm8994"* ]] && [[ "$1" != *"kernel/samsung/smdk4412"* ]] && [[ "$1" != *"kernel/htc/flounder"* ]] && [[ "$1" != *"kernel/amazon/hdx-common"* ]] && [[ "$1" != *"msm899"* ]] && [[ "$1" != *"sdm8"* ]] && [[ "$1" != *"sdm6"* ]]; then
optionsNo+=("CONFIG_DIAG_CHAR" "CONFIG_DIAG_OVER_USB" "CONFIG_USB_QCOM_DIAG_BRIDGE" "CONFIG_DIAGFWD_BRIDGE_CODE" "CONFIG_DIAG_SDIO_PIPE" "CONFIG_DIAG_HSIC_PIPE");
fi;

View File

@ -77,6 +77,9 @@ sed -i '12iLOCAL_SDK_VERSION := current' pico/Android.mk; #Fix build under Pie
sed -i 's/about to delete/unable to delete/' pico/src/com/svox/pico/LangPackUninstaller.java;
awk -i inplace '!/deletePackage/' pico/src/com/svox/pico/LangPackUninstaller.java;
enterAndClear "frameworks/av";
if [ "$DOS_GRAPHENE_MALLOC" = true ]; then patch -p1 < "$DOS_PATCHES/android_frameworks_av/0001-HM_A2DP_Fix.patch"; fi; #(GrapheneOS)
enterAndClear "frameworks/base";
hardenLocationFWB "$DOS_BUILD_BASE"; #XXX 17REBASE
sed -i 's/DEFAULT_MAX_FILES = 1000;/DEFAULT_MAX_FILES = 0;/' services/core/java/com/android/server/DropBoxManagerService.java; #Disable DropBox