ANDROID: 16K: x86_64: Allow stack randomization of twice page-size

In page-compat mode, let stack randomization be 2x__PAGE_SIZE instead of
the hard coded 8KB.

Bug: 383389337
Bug: 315325080
Bug: 302403436
Change-Id: I9ab3c03a9a0fcd7210a1f0dc7834975ae2807473
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
Kalesh Singh
2023-11-20 16:39:52 -08:00
committed by Carlos Llamas
parent f51703f4c1
commit 181bc19bef

View File

@@ -4,6 +4,7 @@
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/page_size_compat.h>
#include <linux/smp.h>
#include <linux/cpu.h>
#include <linux/prctl.h>
@@ -1006,7 +1007,7 @@ early_param("idle", idle_setup);
unsigned long arch_align_stack(unsigned long sp)
{
if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
sp -= get_random_u32_below(8192);
sp -= get_random_u32_below(__PAGE_SIZE << 1);
return sp & ~0xf;
}