From: Tulio A M Mendes Date: Thu, 12 Feb 2026 03:30:19 +0000 (-0300) Subject: feat: guard pages — 32KB user stack with unmapped guard page below for stack overflow... X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=43e43c6523f6b35ae3e69b685c8837c7e0aa0cf3;p=AdrOS.git feat: guard pages — 32KB user stack with unmapped guard page below for stack overflow detection --- 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) {