From a00fa2349e4c4de7e071afab2f4d4ab496d02b27 Mon Sep 17 00:00:00 2001 From: Tad Date: Tue, 2 Aug 2022 19:44:57 -0400 Subject: [PATCH] Switch to a memory efficient hardened_malloc variant This should help 64-bit devices with <4GB RAM substantially, at reduced hardening. clark for example only has 2.5GB of usable memory and idles at 1.6GB used. After this change, idle usage drops to 1.1GB! Signed-off-by: Tad --- Scripts/Common/Optimize.sh | 9 +++++++++ Scripts/init.sh | 1 + 2 files changed, 10 insertions(+) diff --git a/Scripts/Common/Optimize.sh b/Scripts/Common/Optimize.sh index fc3c0226..c68f7307 100644 --- a/Scripts/Common/Optimize.sh +++ b/Scripts/Common/Optimize.sh @@ -23,6 +23,15 @@ source "$DOS_SCRIPTS_COMMON/Shell.sh"; echo "Optimizing..."; +if [ "$DOS_GRAPHENE_MALLOC_MEMORY_EFFICIENT" = true ]; then +if enter "external/hardened_malloc"; then +#Taken from upstream's light variant +sed -i 's/SLAB_QUARANTINE_RANDOM_LENGTH=1/SLAB_QUARANTINE_RANDOM_LENGTH=0/' Android.bp; +sed -i 's/SLAB_QUARANTINE_QUEUE_LENGTH=1/SLAB_QUARANTINE_QUEUE_LENGTH=0/' Android.bp; +sed -i 's/GUARD_SLABS_INTERVAL=1/GUARD_SLABS_INTERVAL=8/' Android.bp; +fi; +fi; + if enter "frameworks/base"; then sed -i 's/ScaleSetting = 1.0f;/ScaleSetting = 0.5f;/' services/java/com/android/server/wm/WindowManagerService.java &>/dev/null || true; sed -i 's/AnimationScale = 1.0f;/AnimationScale = 0.5f;/' services/java/com/android/server/wm/WindowManagerService.java &>/dev/null || true; diff --git a/Scripts/init.sh b/Scripts/init.sh index a3a81400..212c7135 100644 --- a/Scripts/init.sh +++ b/Scripts/init.sh @@ -61,6 +61,7 @@ export DOS_GPS_GLONASS_FORCED=false; #Enables GLONASS on all devices export DOS_GRAPHENE_BIONIC=true; #Enables the bionic hardening patchset on 16.0+17.1+18.1+19.1 export DOS_GRAPHENE_CONSTIFY=true; #Enables 'Constify JNINativeMethod tables' patchset on 16.0+17.1+18.1+19.1 export DOS_GRAPHENE_MALLOC=true; #Enables use of GrapheneOS' hardened memory allocator on 64-bit platforms on 16.0+17.1+18.1+19.1 +export DOS_GRAPHENE_MALLOC_MEMORY_EFFICIENT=true; #Disables slab quarantines and raises the guard slab interval from 1 to 8 to reduce memory usage at cost of reduced hardening export DOS_GRAPHENE_EXEC=true; #Enables use of GrapheneOS' exec spawning feature on 16.0+17.1+18.1+19.1 export DOS_HOSTS_BLOCKING=true; #Set false to prevent inclusion of a HOSTS file export DOS_HOSTS_BLOCKING_LIST="https://divested.dev/hosts-wildcards"; #Must be in the format "127.0.0.1 bad.domain.tld"