Why should the stack be page aligned?

On Linux, I tried (just for fun) to change the kernel source in process.c to create a stack address that has more entropy, i.e. a line in particular:

sp -= get_random_int() % 8192; 

When I change this too much, the kernel stops or I get some seemingly undefined behavior. I assume this leads to a PAGE_ALIGN () error? I'm not interested in why PAGE_ALIGN (), in particular, fails, or exactly what part of the code in the kernel fails (although it would be nice to know too); I'm more interested in why the stack should be in a certain region in general. What is the architectural reason and motivation for this? Is this related to how GDT / LDT works in protected mode?

Just to understand what I'm asking:

Why should the stack be in the form 0xbfXXXXXX (on a 32-bit version)? Why can't the stack be, for example, 0xaaXXXXXXX or any other value?

+4
source share
1 answer

There is a limit to do_page_fault() regarding how far you can be outside the vma stack before it considers it to be bad access, maybe you will push this?

+4
source

All Articles