From 43e43c6523f6b35ae3e69b685c8837c7e0aa0cf3 Mon Sep 17 00:00:00 2001 From: Tulio A M Mendes Date: Thu, 12 Feb 2026 00:30:19 -0300 Subject: [PATCH] =?utf8?q?feat:=20guard=20pages=20=E2=80=94=2032KB=20user?= =?utf8?q?=20stack=20with=20unmapped=20guard=20page=20below=20for=20stack?= =?utf8?q?=20overflow=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/arch/x86/elf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/arch/x86/elf.c b/src/arch/x86/elf.c index f7dc4b9..ebe9fa2 100644 --- a/src/arch/x86/elf.c +++ b/src/arch/x86/elf.c @@ -277,8 +277,11 @@ int elf32_load_user_from_initrd(const char* filename, uintptr_t* entry_out, uint } (void)has_interp; + /* 32 KB user stack with a 4 KB guard page below (unmapped). + * Guard page at 0x007FF000 is left unmapped so stack overflow + * triggers a page fault → SIGSEGV instead of silent corruption. */ const uintptr_t user_stack_base = 0x00800000U; - const size_t user_stack_size = 0x1000; + const size_t user_stack_size = 0x8000; /* 8 pages = 32 KB */ int src2 = elf32_map_user_range(new_as, user_stack_base, user_stack_size, VMM_FLAG_RW); if (src2 < 0) { -- 2.43.0