[PATCH] mm/mmap: Define DEFAULT_STACK_GUARD_GAP
From: Anshuman Khandual
Date: Sun Aug 27 2023 - 23:53:50 EST
This just defines a macro constant i.e DEFAULT_STACK_GUARD_GAP representing
the default gap, guarding the stack mapping. This does not cause functional
changes.
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
Signed-off-by: Anshuman Khandual <anshuman.khandual@xxxxxxx>
---
include/linux/mman.h | 3 +++
mm/mmap.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/mman.h b/include/linux/mman.h
index cee1e4b566d8..cbcd20a071c0 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -8,6 +8,9 @@
#include <linux/atomic.h>
#include <uapi/linux/mman.h>
+/* Default gap for stack mapping is 256 pages */
+#define DEFAULT_STACK_GUARD_GAP (256UL << PAGE_SHIFT)
+
/*
* Arrange for legacy / undefined architecture specific flags to be
* ignored by mmap handling code.
diff --git a/mm/mmap.c b/mm/mmap.c
index 3937479d0e07..8679750333bb 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2120,7 +2120,7 @@ int expand_downwards(struct vm_area_struct *vma, unsigned long address)
}
/* enforced gap between the expanding stack and other mappings. */
-unsigned long stack_guard_gap = 256UL<<PAGE_SHIFT;
+unsigned long stack_guard_gap = DEFAULT_STACK_GUARD_GAP;
static int __init cmdline_parse_stack_guard_gap(char *p)
{
--
2.30.2