From 038ab89982eb5d615f1f2d5ab6f0e03741b7111e Mon Sep 17 00:00:00 2001 From: Tad Date: Wed, 15 Sep 2021 11:48:07 -0400 Subject: [PATCH] More kernel cmdline work Signed-off-by: Tad --- Scripts/Common/Functions.sh | 6 ++---- Scripts/Common/Post.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Scripts/Common/Functions.sh b/Scripts/Common/Functions.sh index 1e96a74a..ce20095f 100644 --- a/Scripts/Common/Functions.sh +++ b/Scripts/Common/Functions.sh @@ -492,9 +492,7 @@ export -f hardenUserdata; hardenBootArgs() { cd "$DOS_BUILD_BASE$1"; - #Unavailable: kpti=on pti=on (4.15) page_alloc.shuffle=1 (5.2) init_on_alloc=1 (5.3) init_on_free=1 (5.3) lockdown=confidentiality (5.4) - # 4.4 - sed -i 's/BOARD_KERNEL_CMDLINE := /BOARD_KERNEL_CMDLINE := slub_debug=FZP page_poison=1 /' BoardConfig*.mk */BoardConfig*.mk &>/dev/null || true; + sed -i 's/BOARD_KERNEL_CMDLINE := /BOARD_KERNEL_CMDLINE := slub_debug=FZP /' BoardConfig*.mk */BoardConfig*.mk &>/dev/null || true; #TODO: inline this echo "Hardened kernel command line arguments for $1"; cd "$DOS_BUILD_BASE"; } @@ -699,7 +697,7 @@ hardenDefconfig() { optionsYes+=("IO_STRICT_DEVMEM"); #Linux 4.6 - optionsYes+=("ARM64_UAO" "PAGE_POISONING" "PAGE_POISONING_NO_SANITY"); + optionsYes+=("ARM64_UAO" "PAGE_POISONING" "PAGE_POISONING_ENABLE_DEFAULT" "PAGE_POISONING_NO_SANITY"); #Linux 4.7 optionsYes+=("ASYMMETRIC_KEY_TYPE" "RANDOMIZE_BASE" "SLAB_FREELIST_RANDOM"); diff --git a/Scripts/Common/Post.sh b/Scripts/Common/Post.sh index b49a29f0..db84c963 100644 --- a/Scripts/Common/Post.sh +++ b/Scripts/Common/Post.sh @@ -15,6 +15,8 @@ #You should have received a copy of the GNU General Public License #along with this program. If not, see . +echo "Post tweaks..."; + #Resurrect dm-verity sed -i 's/^\treturn VERITY_STATE_DISABLE;//' kernel/*/*/drivers/md/dm-android-verity.c &>/dev/null || true; #sed -i 's/#if 0/#if 1/' kernel/*/*/drivers/power/reset/msm-poweroff.c &>/dev/null || true; @@ -27,3 +29,12 @@ sed -i 's/set_dload_mode(in_panic)/set_dload_mode(0)/' kernel/*/*/arch/arm/mach- sed -i 's/static int slub_nomerge;/static int slub_nomerge = 1;/' kernel/*/*/mm/slub.c &>/dev/null || true; #2.6.22-3.17 sed -i 's/static int slab_nomerge;/static int slab_nomerge = 1;/' kernel/*/*/mm/slab_common.c &>/dev/null || true; #3.18-4.12 sed -i 's/static bool slab_nomerge = !IS_ENABLED(CONFIG_SLAB_MERGE_DEFAULT);/static bool slab_nomerge = true;/' kernel/*/*/mm/slab_common.c &>/dev/null || true; #4.13+ +sed -i 's/static bool slab_nomerge __ro_after_init = !IS_ENABLED(CONFIG_SLAB_MERGE_DEFAULT);/static bool slab_nomerge __ro_after_init = true;/' kernel/*/*/mm/slab_common.c &>/dev/null || true; #4.13+ + +#Enable page poisoning +#Commented as set by defconfig +#sed -i 's/= IS_ENABLED(CONFIG_PAGE_POISONING_ENABLE_DEFAULT);/= true;/' kernel/*/*/mm/page_poison.c &>/dev/null || true; #4.4+ #XXX: shouldn't be enabled past 5.3 + + +cd "$DOS_BUILD_BASE"; +echo "Post tweaks complete!";