]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
feat: guard pages — 32KB user stack with unmapped guard page below for stack overflow...
authorTulio A M Mendes <[email protected]>
Thu, 12 Feb 2026 03:30:19 +0000 (00:30 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 02:20:50 +0000 (23:20 -0300)
src/arch/x86/elf.c

index f7dc4b9d0a462689df876ab88d4361b34a231fb9..ebe9fa21657cfc0c95789cfa3c38c2c938af0dfd 100644 (file)
@@ -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) {